Sedece menü anlaşılabilmesi için düzenledim..
" Bahis Eklentisi Menüsünü " Türkçe Yaptım..
Kontrol Ediniz...
Kod: Tümünü seç
#define PLUGINNAME "Last man bets"
#define VERSION "0.9.4"
#define AUTHOR "JGHG"
#define language EDİT "KoRdON*!!."
/*
Copyleft 2004-2005
AMX Mod X versions:
http://www.amxmodx.org/forums/viewtopic.php?p=26590
Idea from miscstats' "Lastman" (by Olo?)
SON MAN bahisleri
=============
İki kişi kalırsa, her takımdan birinde diğer oyunculara kimin kazanacağına dair bir miktar para bahse gireceksiniz.
Bahis koymak için en az 100 $ 'lık (bir cvar vasıtasıyla ayarlanabilir) olmalısınız, ancak bahsinizi, cüzdanınızın yaptığı kadar yükseltebilirsiniz.
Bahsin kazanırsa, diğer bahisçiler için para kazanırsınız. Ne kadar çok bahse girersen, o kadar çok kazanırsın. Eğer kazanırsan. :-)
Her şey tamamen menü yönlendiricidir, herhangi bir komut veya herhangi bir şey öğrenmeye gerek yoktur.
Botlar otomatik olarak bahis oynuyor.
Saksılar: Hiç kimse kazanan oyuncuya bahis yapmazsa, başarısız olan bahisler pota eklenir. Bir bahis kazanmak için bir sonraki oyuncu (aynı bahsi kazanmak için daha fazla para kazanırsa) potu alır.
Harita sonları / sunucu kapatılmadan önce saksı toplanmazsa ;-) çöker; bir sonraki harita için orada olur.
Örnek: Eğer t oyuncusuna 200 $ bahis koyarsanız ve başka bir oyuncu t oyuncusu üzerinden 100 $ bahis oynarsa ve t oyuncu kazanırsa, tüm oyuncuların toplam bahis miktarının 2 / 3ünü alırsınız.
16000 dolardan fazla kazanın: Ödüller kazanın (isteğe bağlı)! 16000 doları aştığınız para için bir şey alırsınız:
Her biri için Aldığınız
---------------------------
$1000 Hayatta kalma süresi (öldüğünüzde yuvarlak son bulmadığı sürece yeniden oynatın, tüm oyuncuların size geri döndüğüne dair bir not yazın - ve kaç tane hayat bıraktıysanız))
$100 Sağlıkta artış (yumurtlama sırasındaki sağlık +100)
$10 Saldırı kılıfı (yumurtlama sırasında 100 zırhınız yoksa tam bir saldırı davası verilir)
KURULUM
============
Her zamanki gibi kurmadan önce, aşağıdaki birkaç tanıma bakabilirsiniz. Bkz. "Aşağıdaki ayarları beğeninize göre ayarlayın"
KULLANIM
=====
Emir yok. Bahis açılan menülerle yapılır ...
Üç tane cvars var:
- lastmanbets_overridemenus
Varsayılan değer 1'dir. Bir oyuncunun halihazırda bir menüsü açıksa (amxmodmenu, wc3 menüsü, vb.) Bahis menüsü açılmaması için bunu 0 olarak ayarlayabilirsiniz. Unutmayın, 0.9 sürümünden itibaren bu, algılamayla ilgili bazı hatalar nedeniyle VGUI menülerini her zaman geçersiz kılar.
- lastmanbets_defaultbet
Varsayılan değer 100'dür. Bu değer, minimum bahsin yerleştirilebilmesi için gerekli olan miktardır. Ayrıca bahisleri arttırma / azaltma aşamalarını baz alır.
- lastmanbets_bettime
Default value is 20 (seconds). Defines how long time the bet menu will stay open - a timer counts down in center of screen. When it reaches 0 whoever still has the bet menu open will have it closed.
VERSIONS
========
Released Version Comment
070820 0.9.4 Tek seferde tüm paralara bahis koymak için menü seçeneği eklendi.
050218 0.9.3 Ekstra yaşamları varsa seyirci olarak tekrar can vermeyin. Teşekkürler "peoplerpoop".
040716 0.9.2 Her bir ödülün size ne kadar mal vereceğini değiştirmek için düzenlemeyi kolaylaştıran bazı tanımlamalar yaptı.
040715 0.9.1 Bahis ilerledikçe, kırmızı / mavi bir hud mesajı, her bir oyuncuya ne kadar para yatırdığını ve her oyuncu kaç tane bahis oynadığını görüntüler. Hudchannels sıkıştırabilir.
040616 0.9 Menü zamanlayıcı + cvar eklendi.
Lastmanbets_overridemenus ayarlanmadığında bahis menüsünün düzgün gösterilmesini sağlamayan başka bir hata düzeltildi. Bazen bir oyuncuya açık olarak VGUI menüsü tespit edildi,
Ancak oyuncunun hiç açık menüsü yoktu. VGUI menüleri her zaman geçersiz kılınmıştır.
040613 0.81 Sabit geçersiz kılma cvar - ters yönde çalıştı gibi görünüyor.
* Cvar adındaki bir yazım hatasının düzeltildiğini unutmayın: lastmanbets_overridemenus <---
040612 0.8 Ödüller devre dışı kaldığında bahis oynamazdı. :-)
040611 0.7 Bazı kodları gezdirdik, bir tanıma yorum yaparak hepsini ödül olmadan derlemek mümkün.
Artık debugmode'da da derlenebilir. Hata ayıklama modülü çıktılarını (sunucu konsoluna) hangi oyuncuların menüyü alması gerekir, kimin yapmadığı ve neden olmadıklarını.
Muhtemel bugfíx (böcek eylemde görmedim ...): birisi yeniden başladığında, oyuncu o anda öldüğünden bahislerin başlamasının imkânsız olması gerekir.
Pot artık tonozdan kazanıyor, dolayısıyla harita bittiğinde toplanmazsa yine de bir sonraki harita için orada olacak.
040607 0.6.1 Bir diğeri, insanların hiçbir zaman menüye çıkmadığı hatayı düzeltmeye çalışıyor (get_player'ın tüm kullanımlarını kaldırdı)
040604 0.6 Bots, sözde lastmanbets_overidemenus ile 1'e ayarlanmış bahis oynamadı. Fixed.
Ödüller eklendi.
Bahisler başlamak üzereyken yerlilerden (get_player) aniden garip bir davranış buldular, hurdaya atmaya ve elle işler yapmaya karar verdiler: -P.
040601 0.5 Tur sona erdikten sonra (bomba patladı, etkisiz hale getirildi, rehineler kurtarıldı vb.), 1vs1'lik bir durum ortaya çıkarsa bahisler kısaca başlatılabilir
Birisi yuvarlak sona erdikten sonra birini öldürdüyse. Düzeltilmeli.
Diğer tweaks ve hata düzeltmeleri.
Daha hızlı "wild" bahis için bahis yaparken iki yeni seçenek ekledi.
Cvar lastmanbets_defaultbet yapıldı.
040531 0.4.2 Lastmanbets_overridemenus cvar eklendi.
040530 0.4.1 Bir kullanıcı zaten açık bir menüye sahipse, o kullanıcı için bahis menüsü açılamaz.
040530 0.4 Bahisler mermi bitince kendiliğinden kapanmalı ve bahse girmeden yeterince hızlı bahis oynamayın.
040528 0.3 Pot eklendi.
Martel için küçük hata düzeltmesi.
040518 0.2 Berabere kaldığınızda, bahis parasını geri ödemesi gerekir ... (ne zaman CS btw'de berabere kalırsınız?)
Birkaç burada ve orada düzeltmeler
Botlar daha soğuk bahis yapıyor.
040517 0.1 İlk sürüm
TO DO
=====
- ihtimaline karşı bahis oynamak
- şimdi IMO biraz çirkin menüsünü tekrar
- Bahislerin, ödüllerin, istatistiklerin ayrıntılı çıktısı ..? Tarihe dikkat et, en iyi on ödül kazanma gibi? Hiç ve şu anki harita için ...? (Ve çıktık kim kim öldürdü :-)
- bahis için maksimum süre, 20 saniye gibi, başka bir menü kapanıyor
- Johnny silahını aldı
*/
#include <amxmodx>
#include <amxmisc>
#include <cstrike>
#include <fun>
// ---------- Adjust below settings to your liking ---------------------------------------
//#define DEBUGMODE // Hata ayıklama modunda derlemek için bu yorumu kaldır
//#define IWANTPRIZES // Ödül istemiyorsanız bunu yorumlayın
//#define XTRA_HEALTHBOOST 0 // Ne kadar fazla sağlığa sahip olursan, sağlığa önem verme ödülü vermeli
// 16000 dolardan fazla para kazandığınızda, eklenti otomatik olarak paranın tamamı dolana kadar para için "ödül" alır.
// Bu değerleri değiştirebilirsiniz. Varsayılan olarak ekstra bir ömrü 1000, ekstra sağlık 100 ve zırh 10'dur. Eklenti önce sizi bir çok ekstra yaşam olarak satın almaya çalışır
// olabilir (yani 1000 $ 'dan daha az kalana kadar) ekstra sağlık satın almaya devam eder ve daha sonra ekstra zırh alır. Bununla birlikte, ekstra yaşamın hala en pahalı olduğuna emin olun.
// ve ekstra zırh en ucuz ödülü, ya da başın derde girer.
#define PRIZEPRICE_EXTRALIFE 0
#define PRIZEPRICE_EXTRAHEALTH 0
#define PRIZEPRICE_EXTRAARMOUR 0
#define HUDCHANNEL_T 2 // Hud kanalları. Muhtemelen bunları değiştirmenize gerek yoktur, ancak bazı hud-görüntüleme eklentilerinin müdahale ettiğini fark ederseniz yapabilirsiniz
#define HUDCHANNEL_CT 3 // Her bir oyuncunun ne kadar bahis oynadığını gösteren kırmızı / mavi mesajlar.
#define HUDMESSAGE_HOLDTIME 25.0 // Kırmızı / mavi mesajlar kaç saniye sonra (son bahisten sonra) ekranda kalmalı. Bir kayan nokta (ondalıkla biten) değeri olmalıdır.
// __________________Bot ayarları burada (bunlara dokunmanız gerekmez)__________________
// Bir bot, en düşük toplam HP ve zırhlı kişiye bahis yapan bir "kumarbaz" olabilir, aksi halde "güvenli" oynamaktadır. Kumarbaz olmak için
// her botun belirli (bireysel) değerin altında rastgele bir değer elde etmesi gerekiyor. Bu değer, BOTGAMBLERMIN ve BOTGAMBLERMAX arasında rasgele bir değer seçerek elde edilir.
// Yani, bot kumar değeri 0.3'e kadar çıkabilir ve daha sonra kalan daha zayıf olan oyuncunun botun bahse girmesi olasılığı% 30 olur.
#define BOTGAMBLERMIN 0.1
#define BOTGAMBLERMAX 0.4
// 0.0'dan 1.0'a doğru rastgele bir şamandıra, bir botun ne kadar bahse gireceğine karar verir. Rastgele bir şamandıra en azından bu değeri bitirirse bir ayar kullanılır.
#define RATIO_HIGH 0.9
#define RATIO_MEDIUM 0.6
// Orana bağlı olarak, bu, botun bahis tutarının ne kadarının geçerli parası olduğunu gösterir. MAXBET_LOW en çok botun toplam para toplamının yaklaşık üçte birini koymasına izin verebilir.
#define MAXBET_LOW 0.3 // Yaklaşık üçte biri
#define MAXBET_MEDIUM 0.5 // Yarım para burada maksimum
#define MAXBET_HIGH 1.0 // Bot, tüm parasını burada yattırabilir
// ---------- Yukarıdaki ayarları beğeninize göre ayarlayın. ---------------------------------------
#define MENUBUTTON1 (1<<0)
#define MENUBUTTON2 (1<<1)
#define MENUBUTTON3 (1<<2)
#define MENUBUTTON4 (1<<3)
#define MENUBUTTON5 (1<<4)
#define MENUBUTTON6 (1<<5)
#define MENUBUTTON7 (1<<6)
#define MENUBUTTON8 (1<<7)
#define MENUBUTTON9 (1<<8)
#define MENUBUTTON0 (1<<9)
#define MENUSELECT1 0
#define MENUSELECT2 1
#define MENUSELECT3 2
#define MENUSELECT4 3
#define MENUSELECT5 4
#define MENUSELECT6 5
#define MENUSELECT7 6
#define MENUSELECT8 7
#define MENUSELECT9 8
#define MENUSELECT0 9
#define TEAM_T 1
#define TEAM_CT 2
// Bahisler başlayana kadar 1vs1 durumundan saniyelerle (float olmalı) gelin - 2vs1 olduğunda can veren oyuncu tekrar oynuyorsa bahis iptal edilir.
#define INITBETTINGSTIME 1.0
// Ekstra bir hayat sürerse, bir oyuncu ölünceye kadar saniyeler içinde (float olmalı) olmalıdır. Bu süre zarfında tur sona erdiyse, respawn kapatılacaktır. INITBETTINGSTIME'den daha düşük olmalı.
#define RESPAWNTIME 0.5
#define TASKID_RESPAWN 100 // Sadece bir değer. Değişme
#define TASKID_BETTINGS 200 // Değişme
#define TASKID_BETTIMER 300 // Değişme
#define TASKID_BETTIMERDISPLAY 400 // Değişme
// Hud settings
#define TRED 200
#define TGREEN 0
#define TBLUE 0
#define TX 0.25
#define CTRED 0
#define CTGREEN 0
#define CTBLUE 200
#define CTX 0.75
#define Y 0.35
#define EFFECTS 0
#define FXTIME 6.0
#define FADEINTIME 0.1
#define FADEOUTTIME 0.2
// Global vars below
//new const CT[] = "CT"
//new const T[] = "TERRORIST"
new const OVERRIDEPREVIOUSMENU[] = "lastmanbets_overridemenus"
new const CVAR_DEFAULTBET[] = "lastmanbets_defaultbet"
new const CVAR_BETTIME[] = "lastmanbets_bettime"
new const VAULTKEY_POT[] = "lastmanbets_pot"
new g_names[3][33]
new g_betperson[33]
new g_betamount[33]
new g_t
new g_ct
new bool:g_betting = false
new g_pot = 0
new g_betmenu
new bool:g_round
enum BETSETTING {BET_LOW, BET_MEDIUM, BET_HIGH}
#if defined IWANTPRIZES
new g_extralives[33] = {0, ...}
new g_extrahealth[33] = {0, ...}
new g_extraarmour[33] = {0, ...}
new bool:g_freezenewround[33] = {false, ...} // to prevent from giving prizes several times on newround (could happen ~2 times for some reason)
#endif
// Global vars above
public death_event() {
#if defined IWANTPRIZES
new victim = read_data(2) // victim needed by IWANTPRIZES and DEBUGMODE, else not
//client_print(0, print_chat, "death_event, victim: %d, g_round: %d, g_extralives[victim]: %d", victim, g_round, g_extralives[victim])
if (g_extralives[victim]) {
new team = get_user_team(victim)
if (team == TEAM_T || team == TEAM_CT) {
new idd[1]
idd[0] = victim
set_task(RESPAWNTIME, "respawn", TASKID_RESPAWN + victim, idd, 1)
// Buraya dön. Kurban ölürse ve yeniden doğabilirse, bu bir 1vs1 henüz gerçekleşmediği anlamına gelir. Mağdur, yuvarlak sona ererse tekrar cevap vermeyecektir - ve eğer tur sona ererse, yine de oyuna başlanmamalıdır.
//client_print(0, print_chat, "death_event, end 1")
return PLUGIN_CONTINUE
}
}
#endif // defined IWANTPRIZES
if (!g_round) {
//client_print(0, print_chat, "death_event, end 2")
return PLUGIN_CONTINUE
}
new cts[32], ts[32], ctsnum = 0, tsnum = 0
new const MAXPLAYERS = get_maxplayers()
for (new i = 1; i <= MAXPLAYERS; i++) {
if (!is_user_connected(i) || !is_user_alive(i))
continue
switch (cs_get_user_team(i)) {
case TEAM_T: ts[tsnum++] = i
case TEAM_CT: cts[ctsnum++] = i
default: {
// A user that is not alive but not on T _or_ CT, who is he anyway?? :-)
return PLUGIN_CONTINUE
}
}
if (tsnum > 1 || ctsnum > 1) {
//client_print(0, print_chat, "Deathevent ends in loop, not 1vs1: cts: %d, ts: %d", ctsnum, tsnum)
return PLUGIN_CONTINUE
}
}
// (Bu iki get_player'ın önceki sürümlerinde sorunlar vardı, şimdi yerini oyuncuları elle kod bulmaya bıraktılar.)
//get_players(cts, ctsnum, "ae", CT) // match alive and team
//get_players(ts, tsnum, "ae", T) // match alive and team
if (ctsnum != 1 || tsnum != 1) {
//client_print(0, print_chat, "death_event, end 3, cts: %d, ts: %d", ctsnum, tsnum)
return PLUGIN_CONTINUE
}
get_user_name(ts[0], g_names[TEAM_T], 32)
get_user_name(cts[0], g_names[TEAM_CT], 32)
g_t = ts[0]
g_ct = cts[0]
#if defined DEBUGMODE
new victimdebug = read_data(2) // victim needed by IWANTPRIZES and DEBUGMODE, else not
new victimname[32]
get_user_name(victimdebug, victimname, 31)
log_amx("Betting will maybe start in %f seconds (if %s that just died does not respawn, or the round ends)", INITBETTINGSTIME, victimname)
#endif
set_task(INITBETTINGSTIME, "initbettings", TASKID_BETTINGS)
return PLUGIN_CONTINUE
}
displaybetshud() {
//client_print(0, print_chat, "%s bet $%d on %s.", name, g_betamount[id], g_names[g_betperson[id]])
new const MAXPLAYERS = get_maxplayers()
// First calculate how much each player has been bet on.
new betamounts[2] = {0, 0}, betcount[2] = {0, 0} // t, ct
for (new i = 1; i <= MAXPLAYERS; i++) {
if (!is_user_connected(i) // no one can win money from a player that has disconnected, even though he bet...
|| g_betperson[i] == 0) // this player didn't bet yet
continue
betamounts[g_betperson[i] - 1] += g_betamount[i] // -1 because person will be a team number, either 1 (t) or 2 (ct).
betcount[g_betperson[i] - 1]++
}
const MESSAGESIZE = 511
new tMessage[MESSAGESIZE + 1], ctMessage[MESSAGESIZE + 1]
format(tMessage, MESSAGESIZE, "%s^n$%d from %d bets", g_names[TEAM_T], betamounts[0], betcount[0])
format(ctMessage, MESSAGESIZE, "%s^n$%d from %d bets", g_names[TEAM_CT], betamounts[1], betcount[1])
for (new i = 1; i <= MAXPLAYERS; i++) {
if (!is_user_connected(i) || is_user_bot(i))
continue
// display hud stuff to this person
set_hudmessage(TRED, TGREEN, TBLUE, TX, Y, EFFECTS, FXTIME, HUDMESSAGE_HOLDTIME, FADEINTIME, FADEOUTTIME, HUDCHANNEL_T)
show_hudmessage(i, tMessage)
set_hudmessage(CTRED, CTGREEN, CTBLUE, CTX, Y, EFFECTS, FXTIME, HUDMESSAGE_HOLDTIME, FADEINTIME, FADEOUTTIME, HUDCHANNEL_CT)
show_hudmessage(i, ctMessage)
}
}
#if defined IWANTPRIZES // keeping all prizes-only functions within this big block, don't forget to move fns out of it when they are used by nonprize compiles
public respawn(idd[1]) {
new team = get_user_team(idd[0])
if (team != TEAM_T && team != TEAM_CT)
return
// Call any bets off. If we have a respawner, a 1vs1 situation is impossible.
#if defined DEBUGMODE
new name[32]
get_user_name(idd[0], name, 31)
log_amx("%s %s %s", name, g_round ? "respawns!" : "would've respawned if the round didn't just end... no respawn this time!", task_exists(TASKID_BETTINGS) ? "A betting was about to happen but will called off." : "A betting wasn't about to happen anyway, no action taken.")
#endif
if (task_exists(TASKID_BETTINGS)) // probably not entirely necessary
remove_task(TASKID_BETTINGS) // this should be necessary, though
if (!g_round)
return
g_extralives[idd[0]]--
spawn(idd[0])
new name2[32]
get_user_name(idd[0], name2, 31)
client_print(0, print_chat, "%s respawned, having %d li%s left!", name2, g_extralives[idd[0]], g_extralives[idd[0]] == 1 ? "fe" : "ves")
}
public client_connect(id) {
resetprizes(id)
return PLUGIN_CONTINUE
}
prize(id, moneyover16k) {
new lives = 0, healths = 0, armours = 0, origmoney = moneyover16k
while (moneyover16k >= PRIZEPRICE_EXTRALIFE) {
g_extralives[id]++
moneyover16k -= PRIZEPRICE_EXTRALIFE
lives++
}
while (moneyover16k >= PRIZEPRICE_EXTRAHEALTH) {
g_extrahealth[id]++
moneyover16k -= PRIZEPRICE_EXTRAHEALTH
healths++
}
while (moneyover16k >= PRIZEPRICE_EXTRAARMOUR) {
g_extraarmour[id]++
moneyover16k -= PRIZEPRICE_EXTRAARMOUR
armours++
}
client_print(id, print_chat, "For winning $%d over $16000, you win these prizes: %d Xtra lives, %d health boosts, %d assault suits", origmoney, lives, healths, armours)
}
setprizes(id) {
new bool:extrahealthused = false, bool:extraarmourused = false
// Add extra health
if (g_extrahealth[id] > 0) {
g_extrahealth[id]--
new idd[1]
idd[0] = id
set_task(0.5, "delayedhealthboost", 0, idd, 0)
extrahealthused = true
}
// Add extra armour
new userarmour = get_user_armor(id)
if (g_extraarmour[id] > 0 && userarmour < 0) {
g_extraarmour[id]--
give_item(id, "item_assaultsuit")
extraarmourused = true
}
if (g_extralives[id] + g_extrahealth[id] + g_extraarmour[id] != 0)
client_print(id, print_chat, "Prizes remaining: %d Xtra lives, %d health boosts%s, %d assault suits%s", g_extralives[id], g_extrahealth[id], extrahealthused ? " (1 just used)" : "", g_extraarmour[id], extraarmourused ? " (1 just used)" : "")
}
public delayedhealthboost(idd[1]) {
set_user_health(idd[0], get_user_health(idd[0]) + XTRA_HEALTHBOOST)
}
remove_respawntasks() {
for (new i = 1; i < 33; i++)
remove_task(TASKID_RESPAWN + i)
}
public unsetfreeze(idd[1]) {
g_freezenewround[idd[0]] = false
}
public restartgame_event() {
for (new i = 1; i < 33; i++)
resetprizes(i)
return PLUGIN_CONTINUE
}
resetprizes(id) {
g_extralives[id] = 0
g_extrahealth[id] = 0
g_extraarmour[id] = 0
g_freezenewround[id] = false
}
#if defined DEBUGMODE
public giveprize(id, level, cid) {
if (!cmd_access(id, level, cid, 4)) {
return PLUGIN_HANDLED
}
new giveto, theprize, prizes
new buffer[10]
read_argv(1, buffer, 9)
giveto = str_to_num(buffer)
read_argv(2, buffer, 9)
theprize = str_to_num(buffer)
read_argv(3, buffer, 9)
prizes = str_to_num(buffer)
switch (theprize) {
case 1: {
g_extralives[giveto] += prizes
}
case 2: {
g_extrahealth[giveto] += prizes
}
case 3: {
g_extraarmour[giveto] += prizes
}
default: {
console_print(id, "Only 1-3 works...")
return PLUGIN_HANDLED
}
}
console_print(id, "Gave %d stuff of type %d to %d.", prizes, theprize, giveto)
return PLUGIN_HANDLED
}
public giveprizeall(id, level, cid) {
if (!cmd_access(id, level, cid, 3)) {
return PLUGIN_HANDLED
}
new theprize, prizes
new buffer[10]
read_argv(1, buffer, 9)
theprize = str_to_num(buffer)
read_argv(2, buffer, 9)
prizes = str_to_num(buffer)
new const MAXCLIENTS = get_maxplayers()
for (new i = 1; i <= MAXCLIENTS; i++) {
if (!is_user_connected(i))
continue
switch (theprize) {
case 1: {
g_extralives[i] = prizes
}
case 2: {
g_extrahealth[i] = prizes
}
case 3: {
g_extraarmour[i] = prizes
}
default: {
console_print(id, "Only 1-3 works...")
return PLUGIN_HANDLED
}
}
}
console_print(id, "Set %d stuff of type %d to all.", prizes, theprize)
return PLUGIN_HANDLED
}
#endif // defined DEBUGMODE
#endif // defined IWANTPRIZES
public newround_event(id) {
#if defined IWANTPRIZES
if (g_freezenewround[id])
return PLUGIN_CONTINUE
//log_amx("newround_event called for %d", id)
g_freezenewround[id] = true
new idd[1]
idd[0] = id
set_task(1.0, "unsetfreeze", 0, idd, 1)
setprizes(id)
#endif // defined IWANTPRIZES
if (!g_round)
g_round = true
return PLUGIN_CONTINUE
}
hudtimerstarter() {
new timeend[1]
timeend[0] = get_systime() + get_cvar_num(CVAR_BETTIME)
hudtimerdisplay(timeend)
set_task(1.0, "hudtimerdisplay", TASKID_BETTIMERDISPLAY, timeend, 1, "b")
}
public hudtimerdisplay(timeend[1]) {
new const MAXPLAYERS = get_maxplayers()
new secondsleft = timeend[0] - get_systime()
new msg[64]
if (secondsleft > 0) {
msg = "Bet menu closes in %d seconds"
format(msg, 63, msg, secondsleft)
}
else
msg = "You didn't bet fast enough..."
new usermenu, userkeys, bool:nooneisinmenu = true
for (new i = 1; i <= MAXPLAYERS; i++) {
if (!is_user_connected(i) || is_user_alive(i) || is_user_bot(i))
continue
else
nooneisinmenu = false
get_user_menu(i, usermenu, userkeys) // get user menu
if (usermenu == g_betmenu) {
// Display time left here
client_print(i, print_center, msg)
}
}
// End loops if no one is in menu...
if (nooneisinmenu) {
remove_task(TASKID_BETTIMER)
remove_task(TASKID_BETTIMERDISPLAY)
}
}
public initbettings() {
if (!g_round) { // if round already ended, call bets off
#if defined DEBUGMODE
log_amx("Bahisler başlamak üzereydi, ancak tur bitti, bu sefer hiçbir bahis gerçekleşmeyecek")
#endif
return
}
// Start timer here
set_task(get_cvar_float(CVAR_BETTIME), "closebetmenu", TASKID_BETTIMER)
hudtimerstarter()
new const DEFAULTBET = get_cvar_num(CVAR_DEFAULTBET)
g_betting = true
for (new i = 1; i < 33; i++) // Reset votes
g_betperson[i] = 0
new bool:overridepreviousmenu, bool:bot, currentmenu, CsTeams:team, keys
if (get_cvar_num(OVERRIDEPREVIOUSMENU))
overridepreviousmenu = true
else
overridepreviousmenu = false
new const MAXPLAYERS = get_maxplayers()
#if defined DEBUGMODE
log_amx("Bettings will now start. This server supports %d players.", MAXPLAYERS)
new name[32]
#endif
for (new i = 1; i <= MAXPLAYERS; i++) {
if (!is_user_connected(i) || is_user_alive(i)) { // Online, dead players only
#if defined DEBUGMODE
if (!is_user_connected(i)) {
//log_amx("Player #%d is not connected and will not be able to vote.", i)
}
else {
get_user_name(i, name, 31)
log_amx("Player #%d (%s) is alive and will not be able to vote.", i, name)
}
#endif
continue
}
bot = bool:is_user_bot(i)
if (!bot && !overridepreviousmenu) {
// If already in a menu, don't bother. This isn't that important...
get_user_menu(i, currentmenu, keys) // currentmenu should be 0 when user is in no menu, only then it's ok to show a bet menu :-]
if (currentmenu > 0) {
#if defined DEBUGMODE
get_user_name(i, name, 31)
log_amx("Player #%d (%s) is already in another menu (%d) - your %s cvar is defined to not show bet menu to ppl who already have a menu open. (Bet menu has id %d)", i, name, currentmenu, OVERRIDEPREVIOUSMENU, g_betmenu)
#endif
continue
}
}
// Must be on T or CT team
team = cs_get_user_team(i)
if (team != CS_TEAM_T && team != CS_TEAM_CT) {
#if defined DEBUGMODE
get_user_name(i, name, 31)
log_amx("Player #%d (%s) is not on team 1 (T) or 2 (CT). Actually the player is on team %d and thus can't bet.", i, name, int:team)
#endif
continue
}
// Must have at least DEFAULTBET dollars to participate...
if (cs_get_user_money(i) < DEFAULTBET) {
#if defined DEBUGMODE
get_user_name(i, name, 31)
log_amx("Player #%d (%s) does only have $%d, which is below the $%d needed to be able to vote.", i, name, cs_get_user_money(i), DEFAULTBET)
#endif
client_print(i, print_chat, "You don't have the minimum $%d needed to place a bet.", DEFAULTBET)
continue
}
g_betamount[i] = DEFAULTBET
if (bot) {
// Bots "bet"
//client_print(0, print_chat, "%d should vote and is a bot!", deadplayers[i])
new botid[1]
botid[0] = i
set_task(random_float(1.0, 5.0), "botbet", 0, botid, 1)
#if defined DEBUGMODE
get_user_name(i, name, 31)
log_amx("Player #%d (%s) is a bot and will bet...", i, name)
#endif
}
else {
//client_print(deadplayers[i], print_chat, "starting bet for you")
#if defined DEBUGMODE
get_user_name(i, name, 31)
log_amx("Player #%d (%s) is a normal player and IS shown the bet menu and thus gets the chance to bet this time...", i, name)
#endif
startbet(i)
}
}
displaybetshud()
}
public botbet(botid[1]) {
if (!g_betting || !is_user_connected(botid[0])) // Bot zamanla bağlantısı kesilmiş olabilir ...
return PLUGIN_CONTINUE
// Bot will bet.
// Bot can bet any even $100 value... and should choose the player with most hp+armour, and possibly best frags/deaths ratio, and then it could turn all over to the other guy for
// gambling purpose.
// Gambling ratio could be set somewhere between 0.1 and 0.5...
new const Float:GAMBLER_RATIO = random_float(BOTGAMBLERMIN, BOTGAMBLERMAX)
new bool:gambler = false // this bot is not a gambler... yet
if (random_float(0.0, 1.0) <= GAMBLER_RATIO)
gambler = true // ok, this bot wants to be a gambler :-)
new nongamblerschoice = getnongamblerschoice()
new choice = gambler ? (nongamblerschoice == TEAM_T ? TEAM_CT : TEAM_T) : nongamblerschoice
/*if (gambler) {
if (nongamblerschoice == TEAM_T)
choice = TEAM_CT
else
choice = TEAM_T
}*/
new money = cs_get_user_money(botid[0])
money -= money % 100 // 553 - (553 % 100) would be 553 - (53) would be 500, ie even amount in hundreds...
money = botbetmoney(money)
if (money == 0) // Bot didn't bet this time...
return PLUGIN_CONTINUE
g_betamount[botid[0]] = money
placebet(botid[0], choice)
return PLUGIN_CONTINUE
}
// Decides how much money the will bot bet.
botbetmoney(money) {
// Low (0.0 > 0.6), medium (0.6 > 0.9), high (0.9 > 1.0)
// Low == max 30% of money
// Medium == max 50% of money
// High == max 100% of money
new const Float:RATIO = random_float(0.0, 1.0)
new BETSETTING:betSetting = BET_LOW
if (RATIO >= RATIO_HIGH)
betSetting = BET_HIGH
else if (RATIO >= RATIO_MEDIUM)
betSetting = BET_MEDIUM
new Float:pctOfMoneyToBet
switch (betSetting) {
case BET_LOW: pctOfMoneyToBet = random_float(0.0, MAXBET_LOW) // MAXBET_LOW 0.3
case BET_MEDIUM: pctOfMoneyToBet = random_float(0.0, MAXBET_MEDIUM) // MAXBET_MEDIUM 0.5
//case BET_HIGH: pctOfMoneyToBet = random_float(0.0, MAXBET_HIGH) // MAXBET_HIGH 1.0
default: pctOfMoneyToBet = random_float(0.0, MAXBET_HIGH) // MAXBET_HIGH 1.0
}
money = floatround(money * pctOfMoneyToBet)
money -= money % 100 // to have equal 100s...
return money
}
getnongamblerschoice() {
new choice
new t_hp = get_user_health(g_t), ct_hp = get_user_health(g_ct), t_armour = get_user_armor(g_t), ct_armour = get_user_armor(g_ct)
if (t_hp + t_armour > ct_hp + ct_armour)
choice = TEAM_T
else if (t_hp + t_armour < ct_hp + ct_armour)
choice = TEAM_CT
else // They're equal
choice = random_num(TEAM_T, TEAM_CT)
return choice
}
startbet(id) {
if (!g_betting) {
client_print(id, print_center, "Bahis'i Kacirdiniz !")
return
}
new menuBody[512], flags = MENUBUTTON1|MENUBUTTON2|MENUBUTTON0, money = cs_get_user_money(id)
new t_hp = get_user_health(g_t), ct_hp = get_user_health(g_ct), t_armour = get_user_armor(g_t), ct_armour = get_user_armor(g_ct)
new len = format(menuBody, 511, "It's \y%s\w vs. \y%s\w! Kim kazanacak? Bahisler Gelsin !!^n^n1. %s (HP: %d, Armour: %d)^n2. %s (HP: %d, Armour: %d)^n^nSuan ki Bahis: $\y%d\w^n", g_names[TEAM_T], g_names[TEAM_CT], g_names[TEAM_T], t_hp, t_armour, g_names[TEAM_CT], ct_hp, ct_armour, g_betamount[id])
if (g_pot > 0)
len += format(menuBody[len], 511 - len, "^nCurrent pot is $\y%d\w^n", g_pot)
new const DEFAULTBET = get_cvar_num(CVAR_DEFAULTBET)
// +1x
if (money >= g_betamount[id] + DEFAULTBET) {
flags |= MENUBUTTON3
len += format(menuBody[len], 511 - len, "\w")
}
else
len += format(menuBody[len], 511 - len, "\d")
len += format(menuBody[len], 511 - len, "3. Bahis'i Yukselt $%d^n", DEFAULTBET)
// +10x
if (money >= g_betamount[id] + DEFAULTBET * 10) {
flags |= MENUBUTTON4
len += format(menuBody[len], 511 - len, "\w")
}
else
len += format(menuBody[len], 511 - len, "\d")
len += format(menuBody[len], 511 - len, "4. Bahis'i Yukselt $%d^n", DEFAULTBET * 10)
// -1x
if (g_betamount[id] - DEFAULTBET >= DEFAULTBET) {
flags |= MENUBUTTON5
len += format(menuBody[len], 511 - len, "\w")
}
else
len += format(menuBody[len], 511 - len, "\d")
len += format(menuBody[len], 511 - len, "5. Dusuk Bahis $%d^n", DEFAULTBET)
// -10x
if (g_betamount[id] - DEFAULTBET * 10 >= DEFAULTBET) {
flags |= MENUBUTTON6
len += format(menuBody[len], 511 - len, "\w")
}
else
len += format(menuBody[len], 511 - len, "\d")
len += format(menuBody[len], 511 - len, "6. Dusuk Bahis $%d^n\w", DEFAULTBET * 10)
len += format(menuBody[len], 511 - len, "7. Bahis'e Hepsini Koy!")
flags |= MENUBUTTON7
len += format(menuBody[len], 511 - len, "^n^n0. Bahse Girmek Istemiyorum")
show_menu(id, flags, menuBody)
//client_print(id, print_chat, "Suan Bahis Menu Gosteriliyor !!")
}
public menu_fn(id, key) {
//client_print(id, print_chat, "Bir Menu Seceneginde Bulundunuz: %d", key)
new bool:stayinmenu = true
new const DEFAULTBET = get_cvar_num(CVAR_DEFAULTBET)
switch (key) {
case MENUSELECT1: {
// bet on t
placebet(id, TEAM_T)
stayinmenu = false
}
case MENUSELECT2: {
// bet on ct
placebet(id, TEAM_CT)
stayinmenu = false
}
case MENUSELECT3: {
// raise bet
alterbet(id, DEFAULTBET)
}
case MENUSELECT4: {
// lower bet
alterbet(id, DEFAULTBET * 10)
}
case MENUSELECT5: {
// raise bet
alterbet(id, -DEFAULTBET)
}
case MENUSELECT6: {
// lower bet
alterbet(id, -DEFAULTBET * 10)
}
case MENUSELECT7: {
// bet all
betall(id)
}
case MENUSELECT0: {
// no bet
if (g_betting)
client_print(id, print_chat, "Sure Bakiniz !!Bahis'e Girmeyiniz !!")
stayinmenu = false
}
}
if (stayinmenu)
startbet(id)
return PLUGIN_HANDLED
}
placebet(id, choice) {
if (!is_user_connected(id))
return
if (g_betting) {
g_betperson[id] = choice
altermoney(id, -g_betamount[id])
new name[33]
get_user_name(id, name, 32)
client_print(0, print_chat, "%s bet $%d on %s.", name, g_betamount[id], g_names[g_betperson[id]])
displaybetshud()
}
else
client_print(id, print_center, "Bahis Icin Cok Gec!")
}
alterbet(id, money) {
g_betamount[id] += money
}
betall(id) {
g_betamount[id] = cs_get_user_money(id)
}
altermoney(id, money) { // calc 16000+ bonuses here?
new newmoney = cs_get_user_money(id) + money
#if defined IWANTPRIZES
if (newmoney > 16000)
prize(id, newmoney - 16000)
#endif
cs_set_user_money(id, newmoney, 1)
}
roundendtasks(const TEAM) {
#if defined IWANTPRIZES
remove_respawntasks()
#endif
g_round = false
if (g_betting) {
closebetmenu()
remove_task(TASKID_BETTIMER) // Menüyü kapatacak zamanlayıcıyı durdur ...
remove_task(TASKID_BETTIMERDISPLAY) // Menü kapanıncaya kadar kalan süreyi gösteren zamanlayıcıyı durdurun ...
if (TEAM == TEAM_T || TEAM == TEAM_CT)
calculatebets(TEAM)
else // Yuvarlak berabere bitti ... geri ödeme tüm bahis parası
payback()
}
}
public roundend_t_event() {
roundendtasks(TEAM_T)
}
public roundend_ct_event() {
roundendtasks(TEAM_CT)
}
public roundend_draw_event() {
roundendtasks(0)
}
public closebetmenu() {
new const MAXPLAYERS = get_maxplayers()
new usermenu, userkeys
for (new i = 1; i <= MAXPLAYERS; i++) {
if (!is_user_connected(i) || is_user_alive(i) || is_user_bot(i))
continue
get_user_menu(i, usermenu, userkeys) // get user menu
if (usermenu == g_betmenu) // Hide it here!
client_cmd(i, "slot10") // client_print(players[i], print_chat, "Hey, round's over and you didn't bet yet... close that menu!")
}
}
payback() {
// End betting here
g_betting = false
for (new i = 1; i < 33; i++) {
if (i == g_t || i == g_ct || !is_user_connected(i) || g_betperson[i] == 0) // the remaining players didn't bet, and don't interact with disconnected players, and don't give anything to those who didn't bet
continue
altermoney(i, g_betamount[i])
client_print(i, print_chat, "Round Berabere Bitti Senin Paralarda $%d Gitti.", g_betamount[i])
}
}
calculatebets(result) {
// End betting here
g_betting = false
// Find all who voted for right player, store how much they voted
new totalrightbets = 0, overallbets = 0
for (new i = 1; i < 33; i++) {
if (g_betperson[i] == result)
totalrightbets += g_betamount[i]
if (g_betperson[i] == TEAM_T || g_betperson[i] == TEAM_CT)
overallbets += g_betamount[i]
}
// Did anyone make a bet at all?
if (overallbets == 0) {
client_print(0, print_chat, "Bu Turda Bahis Yapılmadi ...")
return
}
// Print total bets.
client_print(0, print_chat, "Toplam Bahisler: $%d ($%d Kazanan Takim)", overallbets, totalrightbets)
// Now hand out money...
new Float:wonmoney, name[33], Float:highestwonmoney = -1.0, nr_of_highestwinners = 0, highestwinners[32],CsTeams:team
for (new i = 1; i < 33; i++) {
if (i == g_t || i == g_ct || !is_user_connected(i)) // Kalan oyuncular bahis oynamadılar ve bağlantı kesilmiş oyuncularla etkileşime girmiyor ...
continue
team = cs_get_user_team(i)
if (team != CS_TEAM_T && team != CS_TEAM_CT) // Izleyiciler hiçbir şey elde etmiyor
continue
get_user_name(i, name, 32)
if (totalrightbets > 0 && g_betperson[i] == result) { // Just to avoid divison by 0 (which shouldn't happen, but...)
// This player should have money. How much? ((g_betamount[i] / totalrightbets) * overallbets)
wonmoney = (float(g_betamount[i]) / float(totalrightbets)) * float(overallbets)
client_print(i, print_chat, "Bahsi Kazandin !! Bahsinizi Alabilirsiniz !![ $%d ][ $%d ]", g_betamount[i], floatround(wonmoney) - g_betamount[i])
server_print("%s Bahis'i Kazandi. Bahis'ini Aldi Sonuc:[ $%d ]+[ $%d ] Tebrikler ..", name, g_betamount[i], floatround(wonmoney) - g_betamount[i])
altermoney(i, floatround(wonmoney))
if (wonmoney - g_betamount[i] > highestwonmoney) {
nr_of_highestwinners = 0
highestwinners[nr_of_highestwinners++] = i
highestwonmoney = wonmoney - g_betamount[i]
}
else if (wonmoney - g_betamount[i] == highestwonmoney) {
highestwinners[nr_of_highestwinners++] = i
}
}
else if (g_betperson[i] == 0) {
client_print(i, print_chat, "Bu Seferlik Bahis'e Girmedin.")
server_print("%s Bu kez Bahis'e Girmedi...", name)
}
else {
client_print(i, print_chat, "Bahis'i Kaybettiniz !! Miktar: [ $%d ]", g_betamount[i])
server_print("%s Bu $%d Bahis Kaybedildi...", name, g_betamount[i])
}
}
//statsworker(highestwinners, nr_of_highestwinners, highestwonmoney)
if (nr_of_highestwinners == 0) { // Doğru bahse giren var mıydı? Değilse bahis parasını pota getirin.
client_print(0, print_chat, "No one won anything. $%d is added to the pot. Pot value: $%d", overallbets, g_pot += overallbets)
set_vaultpot(g_pot)
return
}
else if (nr_of_highestwinners == 1) { // Winner takes it all.
get_user_name(highestwinners[0], name, 32)
if (g_pot != 0) {
client_print(0, print_chat, "%s won $%d with a $%d bet, thus also winning the pot, $%d!", name, floatround(highestwonmoney), g_betamount[highestwinners[0]], g_pot)
give_pot(nr_of_highestwinners, highestwinners)
}
else {
if (highestwonmoney >= 1.0)
client_print(0, print_chat, "%s won $%d with a $%d bet, however the pot is empty.", name, floatround(highestwonmoney), g_betamount[highestwinners[0]])
}
}
else { // Winners share it all.
new msg[128], len = 0
if (g_pot > 0) {
len += format(msg[len], 127 - len, "Sharing the $%d pot: ", g_pot)
give_pot(nr_of_highestwinners, highestwinners)
}
else
len += format(msg[len], 127 - len, "Best winners: ")
for (new i = 0; i < nr_of_highestwinners; i++) {
get_user_name(highestwinners[i], name, 32)
len += format(msg[len], 127 - len, "%s ", name)
}
}
}
/*
statsworker(highestwinners[32], const NROFHIGHESTWINNERS, Float:highestwonmoney) {
// Build result table of last bet
}
*/
set_vaultpot(value) {
new potstr[16]
num_to_str(value, potstr, 15)
set_vaultdata(VAULTKEY_POT, potstr)
}
give_pot(nr_of_winners, winners[32]) {
new pot = g_pot
g_pot = 0
set_vaultpot(0) // empty pot in vault
if (nr_of_winners == 1) {
altermoney(winners[0], pot)
return
}
if (nr_of_winners == 0) {
log_amx("%s: Error in script - division by zero error in give_pot! nr_of_winners: %d", nr_of_winners)
return
}
new share = pot/nr_of_winners
for (new i = 0; i < nr_of_winners; i++)
altermoney(winners[i], share)
}
/*
public killtest(id, level, cid) {
if (!cmd_access(id, level, cid, 1))
return PLUGIN_HANDLED
new const MAXPLAYERS = get_maxplayers()
new bool:tSkonad = false, bool:ctSkonad = false, team
for (new i = 1; i <= MAXPLAYERS; i++) {
if (!is_user_connected(i) || !is_user_alive(i))
continue
if (tSkonad && ctSkonad) {
user_kill(i, 1)
continue
}
team = cs_get_user_team(i)
if (team == TEAM_T) {
if (tSkonad || i == id)
user_kill(i, 1)
else
tSkonad = true
}
else if (team == TEAM_CT) {
if (ctSkonad || i == id)
user_kill(i, 1)
else
ctSkonad = true
}
else {
// Some odd team... just kill!
user_kill(i, 1)
}
}
return PLUGIN_HANDLED
}
*/
public plugin_init() {
register_plugin(PLUGINNAME, VERSION, AUTHOR)
register_event("DeathMsg", "death_event", "a")
register_event("SendAudio", "roundend_t_event", "a", "2&%!MRAD_terwin")
register_event("SendAudio", "roundend_ct_event", "a", "2&%!MRAD_ctwin")
register_event("SendAudio", "roundend_draw_event", "a", "2&%!MRAD_rounddraw")
register_event("ResetHUD", "newround_event", "b")
#if defined IWANTPRIZES
register_event("TextMsg", "restartgame_event", "a", "2&#Game_C","2&#Game_w")
register_event("TextMsg", "restartgame_event", "a", "2&#Game_will_restart_in")
#if defined DEBUGMODE
register_concmd("0gp", "giveprize", ADMIN_CFG, "<id> <1-3> <#> - give # 1-3 prizes to id")
register_concmd("0gpa", "giveprizeall", ADMIN_CFG, "<1-3> <#> - give # 1-3 prizes to all")
#endif
#endif
//register_clcmd("0killtest", "killtest", ADMIN_CFG, "- kills you and leaves two people alive on each team...")
register_cvar(OVERRIDEPREVIOUSMENU, "1")
register_cvar(CVAR_DEFAULTBET, "100")
register_cvar(CVAR_BETTIME, "20")
g_betmenu = register_menuid("It's")
register_menucmd(g_betmenu, 1023, "menu_fn")
if (vaultdata_exists(VAULTKEY_POT))
g_pot = get_vaultdata(VAULTKEY_POT)
server_print("%s version %s initialized.", PLUGINNAME, VERSION)
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang1045\\ f0\\ fs16 \n\\ par }
*/