Участник
Пользователь
- Сообщения
- 775
- Реакции
- 293
- Помог
- 11 раз(а)
Так, что ни кто не может помочь?
CRASH: Mon Jul 25 20:52:28 MSK 2022
Start Line: ./hlds_linux -debug -game cstrike -master -noipx -pingboost 3 -bots -hostage-improv -sys_ticrate 1200 -secure +ip 45.136.205.4 +port 27015 +map de_dust2 -maxplayers 24 -bots +rcon_password +sv_password -pidfile hlds.6653.pid
[New LWP 510]
[New LWP 514]
[New LWP 520]
[New LWP 513]
[New LWP 522]
[New LWP 535]
[New LWP 521]
[New LWP 519]
[New LWP 524]
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/x86_64-linux-gnu/libthread_db.so.1".
Core was generated by `./hlds_linux -debug -game cstrike -master -noipx -pingboost 3 -bots -hostage-im'.
Program terminated with signal SIGSEGV, Segmentation fault.
#0 0xf28e01c9 in get_pcvar_string(tagAMX*, int*) () from /home/srv172294/cstrike/addons/amxmodx/dlls/amxmodx_mm_i386.so
[Current thread is 1 (Thread 0xf74c6700 (LWP 510))]
#0 0xf28e01c9 in get_pcvar_string(tagAMX*, int*) () from /home/srv172294/cstrike/addons/amxmodx/dlls/amxmodx_mm_i386.so
#1 0x0a86a0e4 in ?? ()
Backtrace stopped: previous frame inner to this frame (corrupt stack?)
No symbol table info available.
From To Syms Read Shared Object Library
0xf77bda30 0xf77be921 Yes (*) /lib32/libdl.so.2
0xf7730914 0xf7776c78 Yes ./libstdc++.so.6
0xf76996e0 0xf76d0c8b Yes (*) /lib32/libm.so.6
0xf74f4800 0xf7621f1f Yes (*) /lib32/libc.so.6
0xf77cf860 0xf77e8f1d Yes (*) /lib/ld-linux.so.2
0xf74c9e04 0xf74d9490 Yes ./libgcc_s.so.1
0xf6dea1d0 0xf6ed9ee0 Yes (*) /home/srv172294/engine_i486.so
0xf6dae840 0xf6db1dfc Yes (*) /lib32/librt.so.1
0xf6d9c5c0 0xf6da6d74 Yes (*) ./libsteam_api.so
0xf6d818c0 0xf6d8ef11 Yes /lib32/libpthread.so.0
0xf6d57e00 0xf6d73838 Yes (*) /home/srv172294/filesystem_stdio.so
0xf5920200 0xf67b93c4 Yes (*) /home/srv172294/steamclient.so
0xf57bf670 0xf5835020 Yes (*) /home/srv172294/crashhandler.so
0xf2f596a0 0xf2f9bf70 Yes (*) /home/srv172294/./cstrike/addons/metamod/dlls/metamod_i386.so
0xf2cf46a0 0xf2e8bb90 Yes (*) /home/srv172294/cstrike/dlls/cs.so
0xf2ba5d00 0xf2ba6f40 Yes (*) /home/srv172294/cstrike/addons/SafeNameAndChat/SafeNameAndChat.so
0xf2b7d5d0 0xf2b93d20 Yes (*) /home/srv172294/cstrike/addons/reunion/reunion_mm_i386.so
0xf2b5f200 0xf2b72120 Yes (*) /home/srv172294/cstrike/addons/rechecker/rechecker_mm_i386.so
0xf2b37b40 0xf2b410b0 Yes (*) /home/srv172294/cstrike/addons/reauthcheck/reauthcheck_mm_i386.so
0xf2a9e7b0 0xf2b08bc4 Yes (*) /home/srv172294/cstrike/addons/VoiceTranscoder/VoiceTranscoder.so
0xf2a86b90 0xf2a902f0 Yes (*) /home/srv172294/cstrike/addons/resemiclip/resemiclip_mm_i386.so
0xf2a6d980 0xf2a79d30 Yes (*) /home/srv172294/cstrike/addons/resrdetector/resrdetector_mm_i386.so
0xf28969f0 0xf28f9d37 Yes (*) /home/srv172294/cstrike/addons/amxmodx/dlls/amxmodx_mm_i386.so
0xf255d790 0xf25f5fc5 Yes (*) cstrike/addons/amxmodx/modules/mysql_amxx_i386.so
0xf24b2e30 0xf250afb8 Yes (*) cstrike/addons/amxmodx/modules/adminskit_amxx_i386.so
0xf248c130 0xf2492810 Yes (*) cstrike/addons/amxmodx/modules/reaimdetector_amxx_i386.so
0xf247a9c0 0xf2482bb0 Yes (*) cstrike/addons/amxmodx/modules/parachute_amxx_i386.so
0xf23c7340 0xf23da48e Yes (*) /home/srv172294/cstrike/addons/whblocker/whblocker_mm_i386.so
0xf19db3d0 0xf1a0abc4 Yes (*) /home/srv172294/cstrike/addons/hitbox_fix/hitbox_fix_mm_i386.so
0xf18139d0 0xf183fd6c Yes (*) cstrike/addons/amxmodx/modules/fakemeta_amxx_i386.so
0xf178e3b0 0xf17d5da0 Yes (*) cstrike/addons/amxmodx/modules/reapi_amxx_i386.so
0xf16e1260 0xf173cf71 Yes (*) cstrike/addons/amxmodx/modules/sxgeo_amxx_i386.so
0xef1adb60 0xef1f5624 Yes (*) cstrike/addons/amxmodx/modules/hamsandwich_amxx_i386.so
0xef18b9b0 0xef18fa08 Yes (*) cstrike/addons/amxmodx/modules/nvault_amxx_i386.so
0xef012120 0xef018404 Yes (*) cstrike/addons/amxmodx/modules/csx_amxx_i386.so
0xeefef290 0xeeffb80c Yes (*) cstrike/addons/amxmodx/modules/engine_amxx_i386.so
0xeefd0d50 0xeefe0460 Yes (*) cstrike/addons/amxmodx/modules/cstrike_amxx_i386.so
0xeee4da80 0xeee538f0 Yes (*) /lib32/libnss_files.so.2
0xeedeab50 0xeeded7d6 Yes (*) /lib32/libnss_dns.so.2
0xeedd4690 0xeede0b94 Yes (*) /lib32/libresolv.so.2
0xf19a6720 0xf19af1ac Yes (*) cstrike/addons/amxmodx/modules/json_amxx_i386.so
0xef1235d0 0xef16c548 Yes (*) cstrike/addons/amxmodx/modules/regex_amxx_i386.so
(*): Shared library is missing debugging information.
Stack level 0, frame at 0xffc76cf4:
eip = 0xf28e01c9 in get_pcvar_string(tagAMX*, int*); saved eip = 0xa86a0e4
called by frame at 0xa6d91f0
Arglist at 0xffc76cec, args:
Locals at 0xffc76cec, Previous frame's sp is 0xffc76cf4
Saved registers:
ebx at 0xffc76ce8, ebp at 0xffc76cec, esi at 0xffc76ce0, edi at 0xffc76ce4, eip at 0xffc76cf0
End of crash report
----------------------------------------------
#include <amxmodx>
#include <aes_v>
#include <reapi>
#define PLUGIN "SF Bets"
#define VERSION "0.1.6"
#define AUTHOR "serfreeman1337" // maFFyoZZyk Edition
// -- КОНСТАНТЫ -- //
enum _:players_data_struct
{
BET_FOR, // на кого поставил игрок
BET_MONEY, // деньги
BET_EXP, // опыт
BET_BONUS // бонусы
}
enum _:cvars
{
CVAR_MIN_PLAYERS,
CVAR_BET_TIME,
CVAR_BET_AUTOOPEN,
CVAR_BET_MONEY[24],
CVAR_BET_MODE,
Float: CVAR_BET_MULTIPLER,
CVAR_BET_EXP[24],
CVAR_BET_BONUS[24]
}
const taskid_updatemenu = 31337
new const lyl_array[][] = {
{CVAR_BET_MONEY,BET_MONEY},
{CVAR_BET_EXP,BET_EXP},
{CVAR_BET_BONUS,BET_BONUS}
}
#define m_iJoinedState 121
// -- ПЕРЕМЕННЫЕ -- //
new t_id,ct_id // id игроков 1х1
new Float:bet_time // время ставки
new bet_menu
new players_data[MAX_PLAYERS + 1][players_data_struct]
new g_Cvar[cvars]
new HookChain:hook_playerKilled
new menuCB_bet
new g_MinPlayers
public plugin_init()
{
register_plugin(PLUGIN,VERSION,AUTHOR)
// sf plugin tracker
register_cvar("sf_bets", VERSION, FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED)
hook_playerKilled = RegisterHookChain(RG_CBasePlayer_Killed, "CBasePlayer_Killed_Post", true);
RegisterHookChain(RG_RoundEnd, "RoundEnd_Post", .post = true)
RegisterHookChain(RG_CSGameRules_RestartRound, "RoundStart_Post", .post = true);
register_logevent("Bet_CheckMinPlayers",3,"1=joined team")
register_clcmd("say /bet","Bet_ShowMenu",-1,"- open bet menu")
register_dictionary("sf_bets.txt")
register_dictionary("common.txt")
RegisterCvars();
AutoExecConfig(true, "bets", "aes");
}
public plugin_cfg()
{
server_exec()
// --- МЕНЮ --- //
bet_menu = menu_create("Bet Menu","Bet_MenuHandler")
menuCB_bet = menu_makecallback("Bet_MenuCallback")
menu_additem(bet_menu,"Player T","0",.callback = menuCB_bet)
menu_additem(bet_menu,"Player CT","1",.callback = menuCB_bet)
if(g_Cvar[CVAR_BET_MONEY])
menu_additem(bet_menu,"Money","2",.callback = menuCB_bet)
if(g_Cvar[CVAR_BET_EXP])
menu_additem(bet_menu,"Exp","3",.callback = menuCB_bet)
if(g_Cvar[CVAR_BET_BONUS])
menu_additem(bet_menu,"Bonus","4",.callback = menuCB_bet)
}
public OnConfigsExecuted()
{
if(g_Cvar[CVAR_MIN_PLAYERS] == 0)
bind_pcvar_num(get_cvar_pointer("aes_xp_goal_min_players"), g_MinPlayers);
}
public client_disconnected(id)
{
// TODO: придумать что-то
set_task(0.1,"Bet_CheckMinPlayers")
if(players_data[id][BET_FOR])
{
if(players_data[id][BET_EXP])
aes_add_player_exp_f(id,-players_data[id][BET_EXP],true)
if(players_data[id][BET_BONUS])
aes_add_player_bonus_f(id,-players_data[id][BET_BONUS])
}
arrayset(players_data[id],0,players_data_struct)
}
public RoundEnd_Post(WinStatus:status, ScenarioEventEndRound:event, Float:tmDelay)
{
if(t_id && ct_id)
{
if(status == WINSTATUS_CTS) // Победа CT
Bet_End1x1(ct_id)
else // Победа TT
Bet_End1x1(t_id)
}
}
public RoundStart_Post()
{
if(t_id || ct_id)
{
new players[MAX_PLAYERS],pnum
get_players(players,pnum,"ch")
for(new i ; i < pnum ; i++)
arrayset(players_data[players[i]],0,players_data_struct)
t_id = 0
ct_id = 0
bet_time = 0.0
}
}
// Вкл/выкл обнаружения 1x1 по кол-ву игроков в командах
public Bet_CheckMinPlayers()
{
if(g_Cvar[CVAR_MIN_PLAYERS] != 0)
g_MinPlayers = g_Cvar[CVAR_MIN_PLAYERS]
new players[MAX_PLAYERS],pnum
// проверяем кол-во игроков за T
get_players(players,pnum,"e","TERRORIST")
if(pnum < g_MinPlayers)
{
DisableHookChain(hook_playerKilled)
return PLUGIN_CONTINUE
}
// проверяем кол-во игроков за CT
get_players(players,pnum,"e","CT")
if(pnum < g_MinPlayers)
{
DisableHookChain(hook_playerKilled)
return PLUGIN_CONTINUE
}
// вкл все
if(Bet_Check1x1())
Bet_Start()
EnableHookChain(hook_playerKilled)
return PLUGIN_CONTINUE
}
public CBasePlayer_Killed_Post()
if(Bet_Check1x1())
Bet_Start()
// Начало 1х1
public Bet_Start()
{
bet_time = get_gametime() + g_Cvar[CVAR_BET_TIME]
// показываем меню всем
if(g_Cvar[CVAR_BET_AUTOOPEN] == 1)
{
new players[MAX_PLAYERS],pnum
get_players(players,pnum,"ch")
for(new i,player ; i < pnum ; i++)
{
player = players[i]
Bet_ShowMenu(player)
}
}
// таск обновление меню игрокам
if(!task_exists(taskid_updatemenu))
set_task(0.5,"Bet_UpdateMenu",taskid_updatemenu,.flags = "b")
}
// Конец 1x1
public Bet_End1x1(win_practicant)
{
new players[MAX_PLAYERS],pnum
get_players(players,pnum,"ch")
bet_time = 0.0
remove_task(taskid_updatemenu)
Bet_UpdateMenu()
for(new i,player ; i < pnum ; i++)
{
player = players[i]
// игрок не делал ставку
if(!players_data[player][BET_FOR]) continue
// победная ставка
if(players_data[player][BET_FOR] == win_practicant)
{
new win_name[MAX_NAME_LENGTH]
get_user_name(players_data[player][BET_FOR],win_name,charsmax(win_name))
new prize,prize_str[128],prize_len
prize = Bet_GetWinPool(player,BET_MONEY,win_practicant)
// выдаем деньги
if(prize)
{
prize_len += formatex(prize_str[prize_len],charsmax(prize_str) - prize_len,"%L",player,"SF_BET14",prize)
rg_add_account(player, get_member(player, m_iAccount) + prize, AS_ADD, true)
}
// выдаем опыт
prize = Bet_GetWinPool(player,BET_EXP,win_practicant)
if(prize)
{
prize_len += formatex(prize_str[prize_len],charsmax(prize_str) - prize_len,"%s%L",prize_len ? ", " : "",player,"SF_BET15",prize)
aes_add_player_exp_f(player,prize)
}
// выдаем бонусы
prize = Bet_GetWinPool(player,BET_BONUS,win_practicant)
if(prize)
{
prize_len += formatex(prize_str[prize_len],charsmax(prize_str) - prize_len,"%s%L",prize_len ? ", " : "",player,"SF_BET21",prize)
aes_add_player_bonus_f(player,prize)
}
if(!prize_len)
formatex(prize_str,charsmax(prize_str),"%L",player,"SF_BET22")
client_print_color(player,print_team_blue,"%L %L",player,"SF_BET9",player,"SF_BET13",win_name,prize_str)
}
// фейловая ставка
else
{
new lose_name[MAX_NAME_LENGTH]
get_user_name(players_data[player][BET_FOR],lose_name,charsmax(lose_name))
client_print_color(player,print_team_red,"%L %L",player,"SF_BET9",player,"SF_BET12",lose_name)
if(players_data[player][BET_MONEY])
rg_add_account(player, get_member(player, m_iAccount) - players_data[player][BET_MONEY], AS_SET, true)
if(players_data[player][BET_EXP])
aes_add_player_exp_f(player,-players_data[player][BET_EXP],true)
if(players_data[player][BET_BONUS])
aes_add_player_bonus_f(player,-players_data[player][BET_BONUS])
}
arrayset(players_data[player],0,players_data_struct)
}
}
// Функция обновления меню игрокам
public Bet_UpdateMenu()
{
new players[MAX_PLAYERS],pnum
get_players(players,pnum,"ch")
new Float:bet_left = bet_time - get_gametime()
for(new i,player,menu,newmenu,menupage ; i < pnum ; i++)
{
player = players[i]
player_menu_info(player,menu,newmenu,menupage)
// обновляем меню ставок игроку
if(newmenu == bet_menu)
{
// обновляем меню
if(floatround(bet_left) > 0)
{
Bet_MenuFormat(player)
menu_display(player,bet_menu)
}
// закрываем меню по истечению времени
else
{
menu_cancel(player)
show_menu(player,0,"^n")
}
}
}
// сбрасываем такс
if(bet_left <= 0.0)
remove_task(taskid_updatemenu)
}
// Показываем меню ставок
public Bet_ShowMenu(id)
{
// hax
if(id == t_id || id == ct_id)
return PLUGIN_HANDLED
// не показываем меню игрокам в спектаторах
if(!(CS_TEAM_T <= get_member(id, m_iTeam) <= CS_TEAM_CT) || get_member(id, m_iJoiningState))
return PLUGIN_HANDLED
// меню можно вызвать только 1x1
if(!t_id || !ct_id)
{
client_print_color(id,print_team_red,"%L %L",id,"SF_BET9",id,"SF_BET10")
return PLUGIN_CONTINUE
}
if(players_data[id][BET_FOR])
{
client_print_color(id,print_team_red,"%L %L",id,"SF_BET9",id,"SF_BET18")
return PLUGIN_CONTINUE
}
// меню можно вызвать только живым
if(is_user_alive(id))
{
client_print_color(id,print_team_red,"%L %L",id,"SF_BET9",id,"SF_BET11")
return PLUGIN_CONTINUE
}
new Float:bet_left = bet_time - get_gametime()
if(bet_left <= 0.0)
{
client_print_color(id,print_team_red,"%L %L",id,"SF_BET9",id,"SF_BET17")
return PLUGIN_CONTINUE
}
Bet_MenuFormat(id)
menu_display(id,bet_menu)
return PLUGIN_CONTINUE
}
// Обработка действий в меню
public Bet_MenuHandler(id,menu,r_item)
{
if(r_item == MENU_EXIT)
return PLUGIN_HANDLED
new ri[2],di[2]
menu_item_getinfo(menu,r_item,di[0],ri,charsmax(ri),di,charsmax(di),di[0])
new item = str_to_num(ri)
switch(item)
{
// делаем ставки
case 0,1:
{
// ставим деньги
if(players_data[id][BET_MONEY])
{
new user_money = get_member(id, m_iAccount)
// игроку не хватает денег
if(user_money < players_data[id][BET_MONEY])
{
Bet_MenuFormat(id)
menu_display(id,menu)
return PLUGIN_HANDLED
}
}
new Float: fExp = aes_get_player_exp(id);
new iBonuses = aes_get_player_bonus(id);
// ставим опыт
if(players_data[id][BET_EXP])
{
if(fExp < players_data[id][BET_EXP])
{
Bet_MenuFormat(id)
menu_display(id,menu)
return PLUGIN_HANDLED
}
}
if(players_data[id][BET_BONUS])
{
if(iBonuses < players_data[id][BET_BONUS])
{
Bet_MenuFormat(id)
menu_display(id,menu)
return PLUGIN_HANDLED
}
}
// запоминаем на кого поставили
players_data[id][BET_FOR] = item == 0 ? t_id : ct_id
if(!players_data[id][BET_FOR])
return PLUGIN_HANDLED
// сообщение в чат
new plr_name[MAX_NAME_LENGTH],bet_name[MAX_NAME_LENGTH]
get_user_name(id,plr_name,charsmax(plr_name))
get_user_name(players_data[id][BET_FOR],bet_name,charsmax(bet_name))
// сообщение всем мертвым игрокам
new players[MAX_PLAYERS],pnum
get_players(players,pnum,"bch")
for(new i,player ; i < pnum ; i++)
{
player = players[i]
if(player == id)
client_print_color(player,print_team_default,"%L %L",player,"SF_BET9",player,"SF_BET27",bet_name,Bet_Menu_Chat(id))
else
client_print_color(player,(get_member(player, m_iTeam) == CS_TEAM_CT ? print_team_blue : print_team_red), "%L %L",player,"SF_BET9",player,"SF_BET28",plr_name,bet_name,Bet_Menu_Chat(id))
}
}
// переключатели стаовк
case 2,3,4,5:
{
new cp = lyl_array[item - 2][0]
new sp = lyl_array[item - 2][1]
new bet_str[128],bet_val[10],bool:set
get_pcvar_string(g_Cvar[cp],bet_str,charsmax(bet_str))
while(argbreak(bet_str,bet_val,charsmax(bet_val),bet_str,charsmax(bet_str)) != -1)
{
if(!bet_val[0]) break
bet_val[0] = str_to_num(bet_val)
// переключаем на большее значение
if(bet_val[0] > players_data[id][sp])
{
set = true
players_data[id][sp] = bet_val[0]
break
}
}
// сбрасываем переключатель
if(bet_val[0] <= players_data[id][sp] && !set) players_data[id][sp] = 0
switch(item)
{
case 2: if(get_member(id, m_iAccount) < players_data[id][sp]) players_data[id][sp] = 0
case 3,4:
{
new Float: fExp = aes_get_player_exp(id);
new iBonuses = aes_get_player_bonus(id);
if((item == 3 && fExp < players_data[id][sp]) || (item == 4 && iBonuses < players_data[id][sp]))
players_data[id][sp] = 0
}
}
Bet_MenuFormat(id)
menu_display(id,menu)
}
}
return PLUGIN_HANDLED
}
// Настраиваем отображение меню
public Bet_MenuFormat(id)
{
new fmt[512],len
// --- ЗАГОЛОВОК --- //
len += formatex(fmt[len],charsmax(fmt) - len,"%L^n%L^n%L",id,"SF_BET1",id,"SF_BET2",bet_time - get_gametime(),id,"SF_BET3",Bet_Menu_GetBetString(id))
menu_setprop(bet_menu,MPROP_TITLE,fmt)
// --- ВЫХОД --- //
formatex(fmt,charsmax(fmt),"%L",id,"EXIT")
menu_setprop(bet_menu,MPROP_EXITNAME,fmt)
}
// Настраиваем кнопки в меню
public Bet_MenuCallback(id, menu, r_item)
{
new fmt[256],len
new ri[2],di[2]
menu_item_getinfo(menu,r_item,di[0],ri,charsmax(ri),di,charsmax(di),di[0])
new item = str_to_num(ri)
if(item == 0) Bet_MenuFormat(id)
switch(item)
{
// ставки на T или CT
case 0,1:
{
new ct_name[MAX_NAME_LENGTH],bet_id = (item == 0 ? t_id : ct_id)
new rt = ITEM_DISABLED
get_user_name(bet_id,ct_name,charsmax(ct_name))
len = formatex(fmt[len],charsmax(fmt) - len,"%L",id,"SF_BET6",ct_name,item == 0 ? "T" : "CT")
if(players_data[id][BET_MONEY]) rt = ITEM_ENABLED
new prize = Bet_GetWinPool(id,BET_MONEY,bet_id)
new prize_str[128],prize_len
if(prize) prize_len += formatex(prize_str[prize_len],charsmax(prize_str) - prize_len,"%L",id,"SF_BET5",prize)
prize = Bet_GetWinPool(id,BET_EXP,bet_id)
if(prize) prize_len += formatex(prize_str[prize_len],charsmax(prize_str) - prize_len,"%s%L",prize_len ? ", " : "",id,"SF_BET4",prize)
prize = Bet_GetWinPool(id,BET_BONUS,bet_id)
if(prize) prize_len += formatex(prize_str[prize_len],charsmax(prize_str) - prize_len,"%s%L",prize_len ? ", " : "",id,"SF_BET20",prize)
if(players_data[id][BET_EXP] || players_data[id][BET_EXP]) rt = ITEM_ENABLED
if(prize_str[0]) len += formatex(fmt[len],charsmax(fmt) - len," %L",id,"SF_BET16",prize_str)
if(item == 1) len += formatex(fmt[len],charsmax(fmt) - len,"^n")
menu_item_setname(menu,r_item,fmt)
return rt
}
// переключатели
case 2,3,4,5:
{
new cp = lyl_array[item - 2][0]
new sp = lyl_array[item - 2][1]
switch(item)
{
case 2: len = formatex(fmt[len],charsmax(fmt) - len,"%L",id,"SF_BET7")
case 3: len = formatex(fmt[len],charsmax(fmt) - len,"%L",id,"SF_BET8")
case 4: len = formatex(fmt[len],charsmax(fmt) - len,"%L",id,"SF_BET19")
}
new bet_str[128],bet_val[10]
get_pcvar_string(g_Cvar[cp],bet_str,charsmax(bet_str))
if(!bet_str[0])
{
menu_item_setname(bet_menu,r_item,fmt)
return ITEM_DISABLED
}
while(argbreak(bet_str,bet_val,charsmax(bet_val),bet_str,charsmax(bet_str)) != -1)
{
if(!bet_val[0]) break
bet_val[0] = str_to_num(bet_val)
if(bet_val[0] != players_data[id][sp]) len += formatex(fmt[len],charsmax(fmt) - len," \d[%d]",bet_val[0])
else len += formatex(fmt[len],charsmax(fmt) - len," \r[\y%d\r]",bet_val[0])
}
menu_item_setname(bet_menu,r_item,fmt)
}
}
return ITEM_ENABLED
}
// лул
Bet_Menu_GetBetString(id)
{
new fmt[512],len
if(players_data[id][BET_MONEY]) len += formatex(fmt[len],charsmax(fmt) - len,"%L",id,"SF_BET5",players_data[id][BET_MONEY])
if(players_data[id][BET_EXP]) len += formatex(fmt[len],charsmax(fmt) - len,"%s%L",fmt[0] ? ", " : "",id,"SF_BET4",players_data[id][BET_EXP])
if(players_data[id][BET_BONUS]) len += formatex(fmt[len],charsmax(fmt) - len,"%s%L",fmt[0] ? ", " : "",id,"SF_BET20",players_data[id][BET_BONUS])
if(!fmt[0]) copy(fmt,charsmax(fmt),"\d-\w")
return fmt
}
// чат оповещалка
Bet_Menu_Chat(id)
{
new fmt[512],len
if(players_data[id][BET_MONEY]) len += formatex(fmt[len],charsmax(fmt) - len,"%L",id,"SF_BET14",players_data[id][BET_MONEY])
if(players_data[id][BET_EXP]) len += formatex(fmt[len],charsmax(fmt) - len,"%s%L",fmt[0] ? ", " : "",id,"SF_BET15",players_data[id][BET_EXP])
if(players_data[id][BET_BONUS]) len += formatex(fmt[len],charsmax(fmt) - len,"%s%L",fmt[0] ? ", " : "",id,"SF_BET21",players_data[id][BET_BONUS])
if(!fmt[0]) copy(fmt,charsmax(fmt),"Ничего")
return fmt
}
// Узнаем выигрыш ставки
Bet_GetWinPool(id,pool,practicant)
{
new win_bet
switch(g_Cvar[CVAR_BET_MODE])
{
case 0:
{
new players[MAX_PLAYERS],pnum
get_players(players,pnum,"ch")
new bet_pool
new win_pool
for(new i,player ; i <pnum ; i++)
{
player = players[i]
if(players_data[player][BET_FOR] == 0 && player != id) continue
if(players_data[player][BET_FOR] == practicant || !players_data[player][BET_FOR]) bet_pool += players_data[player][pool]
else win_pool += players_data[player][pool]
}
if(!bet_pool) return 0
// процент ставки игрока от общей суммы
new Float:bet_perc = float(players_data[id][pool]) * 100.0 / float(bet_pool)
win_bet = (win_pool * floatround(bet_perc) / 100)
}
case 1: win_bet = (players_data[id][pool])
}
win_bet = floatround(win_bet * g_Cvar[CVAR_BET_MULTIPLER])
return win_bet
}
// Функция проверки 1x1
Bet_Check1x1()
{
if(t_id && ct_id)
return false
new players[MAX_PLAYERS],tnum,ctnum
get_players(players,tnum,"aeh","TERRORIST") // живые игрока из T
if(tnum == 1) t_id = players[0] // запоминаем ID посл. живого T
else
{
t_id = 0
return false
}
get_players(players,ctnum,"aeh","CT") // живые игроки за CT
if(ctnum == 1) ct_id = players[0] // запоминаем ID посл. живого CT
else
{
ct_id = 0
return false
}
return true // это 1x1
}
RegisterCvars()
{
bind_pcvar_num(
create_cvar(
.name = "sf_bet_min_players",
.string = "2",
.flags = FCVAR_SERVER,
.description = fmt("%l", "SF_CVAR_MIN_PLAYERS"),
.has_min = true,
.min_val = 0.0
), g_Cvar[CVAR_MIN_PLAYERS]
);
bind_pcvar_num(
create_cvar(
.name = "sf_bet_time",
.string = "15",
.flags = FCVAR_SERVER,
.description = fmt("%l", "SF_CVAR_BET_TIME"),
.has_min = true,
.min_val = 0.0
), g_Cvar[CVAR_BET_TIME]
);
bind_pcvar_string(
create_cvar(
.name = "sf_bet_money",
.string = "100 1000 3000",
.flags = FCVAR_SERVER,
.description = fmt("%l", "SF_CVAR_BET_MONEY")
), g_Cvar[CVAR_BET_MONEY], charsmax(g_Cvar[CVAR_BET_MONEY])
);
bind_pcvar_num(
create_cvar(
.name = "sf_bet_mode",
.string = "1",
.flags = FCVAR_SERVER,
.description = fmt("%l", "SF_CVAR_BET_MODE"),
.has_min = true,
.min_val = 0.0
), g_Cvar[CVAR_BET_MODE]
);
bind_pcvar_float(
create_cvar(
.name = "sf_bet_multipler",
.string = "2.0",
.flags = FCVAR_SERVER,
.description = fmt("%l", "SF_CVAR_BET_MULTIPLER"),
.has_min = true,
.min_val = 0.0
), g_Cvar[CVAR_BET_MULTIPLER]
);
bind_pcvar_string(
create_cvar(
.name = "sf_bet_exp",
.string = "100 200 300",
.flags = FCVAR_SERVER,
.description = fmt("%l", "SF_CVAR_BET_EXP")
), g_Cvar[CVAR_BET_EXP], charsmax(g_Cvar[CVAR_BET_EXP])
);
bind_pcvar_string(
create_cvar(
.name = "sf_bet_bonus",
.string = "5 10 15",
.flags = FCVAR_SERVER,
.description = fmt("%l", "SF_CVAR_BET_BONUS")
), g_Cvar[CVAR_BET_BONUS], charsmax(g_Cvar[CVAR_BET_BONUS])
);
bind_pcvar_num(
create_cvar(
.name = "sf_bet_auto",
.string = "1",
.flags = FCVAR_SERVER,
.description = fmt("%l", "SF_CVAR_BET_AUTOOPEN"),
.has_min = true,
.min_val = 0.0
), g_Cvar[CVAR_BET_AUTOOPEN]
);
}
get_pcvar_string
, ты делаешь new cp = lyl_array[item - 2][0]
, потом делаешь get_pcvar_string(g_Cvar[cp],
. А с какой целью-то? get_pcvar_* требует указатель квара (cvar pointer) первым аргументом, а ты пытаешься туда подставить строку, так как у тебя в этот массив биндятся значения кваров:bind_pcvar_string(
create_cvar(
.name = "sf_bet_money",
.string = "100 1000 3000",
.flags = FCVAR_SERVER,
.description = fmt("%l", "SF_CVAR_BET_MONEY")
), g_Cvar[CVAR_BET_MONEY], charsmax(g_Cvar[CVAR_BET_MONEY])
);
lyl_array[item - 2][0]
, [0] - ты подставляешь первый символ строки, если я правильно разобрался во всех этих дебрях. get_cvar_string(g_Cvar[cp],bet_str,charsmax(bet_str))
copy(bet_str,charsmax(bet_str),g_Cvar[cp])
#include <amxmodx>
#include <aes_v>
#include <reapi>
#define PLUGIN "SF Bets"
#define VERSION "0.1.6"
#define AUTHOR "serfreeman1337" // maFFyoZZyk Edition
// -- КОНСТАНТЫ -- //
enum _:players_data_struct
{
BET_FOR, // на кого поставил игрок
BET_MONEY, // деньги
BET_EXP, // опыт
BET_BONUS // бонусы
};
enum _:cvars
{
CVAR_MIN_PLAYERS,
CVAR_BET_TIME,
CVAR_BET_AUTOOPEN,
CVAR_BET_MONEY[24],
CVAR_BET_MODE,
Float: CVAR_BET_MULTIPLER,
CVAR_BET_EXP[24],
CVAR_BET_BONUS[24]
};
const taskid_updatemenu = 31337;
new const lyl_array[][] = {
{CVAR_BET_MONEY,BET_MONEY},
{CVAR_BET_EXP,BET_EXP},
{CVAR_BET_BONUS,BET_BONUS}
};
#define m_iJoinedState 121
// -- ПЕРЕМЕННЫЕ -- //
new t_id,ct_id; // id игроков 1х1
new Float:bet_time; // время ставки
new bet_menu;
new players_data[MAX_PLAYERS + 1][players_data_struct];
new g_Cvar[cvars];
new HookChain:hook_playerKilled;
new menuCB_bet;
new g_MinPlayers;
public plugin_init()
{
register_plugin(PLUGIN,VERSION,AUTHOR);
// sf plugin tracker
register_cvar("sf_bets", VERSION, FCVAR_SERVER | FCVAR_SPONLY | FCVAR_UNLOGGED);
hook_playerKilled = RegisterHookChain(RG_CBasePlayer_Killed, "CBasePlayer_Killed_Post", true);
RegisterHookChain(RG_RoundEnd, "RoundEnd_Post", .post = true);
RegisterHookChain(RG_CSGameRules_RestartRound, "RoundStart_Post", .post = true);
register_logevent("Bet_CheckMinPlayers",3,"1=joined team");
register_clcmd("say /bet","Bet_ShowMenu",-1,"- open bet menu");
register_dictionary("sf_bets.txt");
register_dictionary("common.txt");
RegisterCvars();
AutoExecConfig(true, "bets", "aes");
}
public plugin_cfg()
{
// server_exec();
// --- МЕНЮ --- //
bet_menu = menu_create("Bet Menu","Bet_MenuHandler");
menuCB_bet = menu_makecallback("Bet_MenuCallback");
menu_additem(bet_menu,"Player T","0",.callback = menuCB_bet);
menu_additem(bet_menu,"Player CT","1",.callback = menuCB_bet);
if(g_Cvar[CVAR_BET_MONEY])
menu_additem(bet_menu,"Money","2",.callback = menuCB_bet);
if(g_Cvar[CVAR_BET_EXP])
menu_additem(bet_menu,"Exp","3",.callback = menuCB_bet);
if(g_Cvar[CVAR_BET_BONUS])
menu_additem(bet_menu,"Bonus","4",.callback = menuCB_bet);
}
public OnConfigsExecuted()
{
if(g_Cvar[CVAR_MIN_PLAYERS] == 0)
bind_pcvar_num(get_cvar_pointer("aes_xp_goal_min_players"), g_MinPlayers);
}
public client_disconnected(id)
{
// TODO: придумать что-то
set_task(0.1,"Bet_CheckMinPlayers");
if(players_data[id][BET_FOR])
{
if(players_data[id][BET_EXP])
aes_add_player_exp_f(id,-players_data[id][BET_EXP],true);
if(players_data[id][BET_BONUS])
aes_add_player_bonus_f(id,-players_data[id][BET_BONUS]);
}
arrayset(players_data[id],0,players_data_struct);
}
public RoundEnd_Post(WinStatus:status, ScenarioEventEndRound:event, Float:tmDelay)
{
if(t_id && ct_id)
{
if(status == WINSTATUS_CTS) // Победа CT
Bet_End1x1(ct_id);
else // Победа TT
Bet_End1x1(t_id);
}
}
public RoundStart_Post()
{
if(t_id || ct_id)
{
new players[MAX_PLAYERS],pnum;
get_players(players,pnum,"ch");
for(new i ; i < pnum ; i++)
arrayset(players_data[players[i]],0,players_data_struct);
t_id = 0;
ct_id = 0;
bet_time = 0.0;
}
}
// Вкл/выкл обнаружения 1x1 по кол-ву игроков в командах
public Bet_CheckMinPlayers()
{
if(g_Cvar[CVAR_MIN_PLAYERS] != 0)
g_MinPlayers = g_Cvar[CVAR_MIN_PLAYERS];
if(get_member_game(m_iNumTerrorist) < g_MinPlayers || get_member_game(m_iNumCT) < g_MinPlayers)
{
DisableHookChain(hook_playerKilled);
return PLUGIN_CONTINUE;
}
// вкл все
if(Bet_Check1x1())
Bet_Start();
EnableHookChain(hook_playerKilled);
return PLUGIN_CONTINUE;
}
public CBasePlayer_Killed_Post()
if(Bet_Check1x1())
Bet_Start();
// Начало 1х1
public Bet_Start()
{
bet_time = get_gametime() + g_Cvar[CVAR_BET_TIME];
// показываем меню всем
if(g_Cvar[CVAR_BET_AUTOOPEN] == 1)
{
new players[MAX_PLAYERS],pnum;
get_players(players,pnum,"ch");
for(new i,player ; i < pnum ; i++)
{
player = players[i];
Bet_ShowMenu(player);
}
}
// таск обновление меню игрокам
if(!task_exists(taskid_updatemenu))
set_task(0.5,"Bet_UpdateMenu",taskid_updatemenu,.flags = "b");
}
// Конец 1x1
public Bet_End1x1(win_practicant)
{
new players[MAX_PLAYERS],pnum;
get_players(players,pnum,"ch");
bet_time = 0.0;
remove_task(taskid_updatemenu);
Bet_UpdateMenu();
for(new i,player ; i < pnum ; i++)
{
player = players[i];
// игрок не делал ставку
if(!players_data[player][BET_FOR])
continue;
// победная ставка
if(players_data[player][BET_FOR] == win_practicant)
{
new win_name[MAX_NAME_LENGTH];
get_user_name(players_data[player][BET_FOR],win_name,charsmax(win_name));
new prize,prize_str[128],prize_len;
prize = Bet_GetWinPool(player,BET_MONEY,win_practicant);
// выдаем деньги
if(prize)
{
prize_len += formatex(prize_str[prize_len],charsmax(prize_str) - prize_len,"%L",player,"SF_BET14",prize);
rg_add_account(player, get_member(player, m_iAccount) + prize, AS_ADD, true);
}
// выдаем опыт
prize = Bet_GetWinPool(player,BET_EXP,win_practicant);
if(prize)
{
prize_len += formatex(prize_str[prize_len],charsmax(prize_str) - prize_len,"%s%L",prize_len ? ", " : "",player,"SF_BET15",prize);
aes_add_player_exp_f(player,prize);
}
// выдаем бонусы
prize = Bet_GetWinPool(player,BET_BONUS,win_practicant);
if(prize)
{
prize_len += formatex(prize_str[prize_len],charsmax(prize_str) - prize_len,"%s%L",prize_len ? ", " : "",player,"SF_BET21",prize);
aes_add_player_bonus_f(player,prize);
}
if(!prize_len)
formatex(prize_str,charsmax(prize_str),"%L",player,"SF_BET22");
client_print_color(player,print_team_blue,"%L %L",player,"SF_BET9",player,"SF_BET13",win_name,prize_str);
}
// фейловая ставка
else
{
new lose_name[MAX_NAME_LENGTH];
get_user_name(players_data[player][BET_FOR],lose_name,charsmax(lose_name));
client_print_color(player,print_team_red,"%L %L",player,"SF_BET9",player,"SF_BET12",lose_name);
if(players_data[player][BET_MONEY])
rg_add_account(player, get_member(player, m_iAccount) - players_data[player][BET_MONEY], AS_SET, true);
if(players_data[player][BET_EXP])
aes_add_player_exp_f(player,-players_data[player][BET_EXP],true);
if(players_data[player][BET_BONUS])
aes_add_player_bonus_f(player,-players_data[player][BET_BONUS]);
}
arrayset(players_data[player],0,players_data_struct);
}
}
// Функция обновления меню игрокам
public Bet_UpdateMenu()
{
new players[MAX_PLAYERS],pnum;
get_players(players,pnum,"ch");
new Float:bet_left = bet_time - get_gametime();
for(new i,player,menu,newmenu,menupage ; i < pnum ; i++)
{
player = players[i];
player_menu_info(player,menu,newmenu,menupage);
// обновляем меню ставок игроку
if(newmenu == bet_menu)
{
// обновляем меню
if(floatround(bet_left) > 0)
{
Bet_MenuFormat(player);
menu_display(player,bet_menu);
}
// закрываем меню по истечению времени
else
{
menu_cancel(player);
show_menu(player,0,"^n");
}
}
}
// сбрасываем такс
if(bet_left <= 0.0)
remove_task(taskid_updatemenu);
}
// Показываем меню ставок
public Bet_ShowMenu(id)
{
// hax
if(id == t_id || id == ct_id)
return PLUGIN_HANDLED;
// не показываем меню игрокам в спектаторах
if(!(CS_TEAM_T <= get_member(id, m_iTeam) <= CS_TEAM_CT) || get_member(id, m_iJoiningState))
return PLUGIN_HANDLED;
// меню можно вызвать только 1x1
if(!t_id || !ct_id)
{
client_print_color(id,print_team_red,"%L %L",id,"SF_BET9",id,"SF_BET10");
return PLUGIN_CONTINUE;
}
if(players_data[id][BET_FOR])
{
client_print_color(id,print_team_red,"%L %L",id,"SF_BET9",id,"SF_BET18");
return PLUGIN_CONTINUE;
}
// меню можно вызвать только живым
if(is_user_alive(id))
{
client_print_color(id,print_team_red,"%L %L",id,"SF_BET9",id,"SF_BET11");
return PLUGIN_CONTINUE;
}
new Float:bet_left = bet_time - get_gametime();
if(bet_left <= 0.0)
{
client_print_color(id,print_team_red,"%L %L",id,"SF_BET9",id,"SF_BET17");
return PLUGIN_CONTINUE;
}
Bet_MenuFormat(id);
menu_display(id,bet_menu);
return PLUGIN_CONTINUE;
}
// Обработка действий в меню
public Bet_MenuHandler(id,menu,r_item)
{
if(r_item == MENU_EXIT)
return PLUGIN_HANDLED;
new ri[2],di[2];
menu_item_getinfo(menu,r_item,di[0],ri,charsmax(ri),di,charsmax(di),di[0]);
new item = str_to_num(ri);
switch(item)
{
// делаем ставки
case 0,1:
{
// ставим деньги
if(players_data[id][BET_MONEY])
{
new user_money = get_member(id, m_iAccount);
// игроку не хватает денег
if(user_money < players_data[id][BET_MONEY])
{
Bet_MenuFormat(id);
menu_display(id,menu);
return PLUGIN_HANDLED;
}
}
new Float: fExp = aes_get_player_exp(id);
new iBonuses = aes_get_player_bonus(id);
// ставим опыт
if(players_data[id][BET_EXP])
{
if(fExp < players_data[id][BET_EXP])
{
Bet_MenuFormat(id);
menu_display(id,menu);
return PLUGIN_HANDLED;
}
}
if(players_data[id][BET_BONUS])
{
if(iBonuses < players_data[id][BET_BONUS])
{
Bet_MenuFormat(id);
menu_display(id,menu);
return PLUGIN_HANDLED;
}
}
// запоминаем на кого поставили
players_data[id][BET_FOR] = item == 0 ? t_id : ct_id;
if(!players_data[id][BET_FOR])
return PLUGIN_HANDLED;
// сообщение в чат
new plr_name[MAX_NAME_LENGTH],bet_name[MAX_NAME_LENGTH];
get_user_name(id,plr_name,charsmax(plr_name));
get_user_name(players_data[id][BET_FOR],bet_name,charsmax(bet_name));
// сообщение всем мертвым игрокам
new players[MAX_PLAYERS],pnum;
get_players(players,pnum,"bch");
for(new i,player ; i < pnum ; i++)
{
player = players[i];
if(player == id)
client_print_color(player,print_team_default,
"%L %L",player,"SF_BET9",player,"SF_BET27",bet_name,Bet_Menu_Chat(id)
);
else
client_print_color(player,(get_member(player, m_iTeam) == CS_TEAM_CT ? print_team_blue : print_team_red),
"%L %L",player,"SF_BET9",player,"SF_BET28",plr_name,bet_name,Bet_Menu_Chat(id)
);
}
}
// переключатели стаовк
case 2,3,4:
{
new cp = lyl_array[item - 2][0];
new sp = lyl_array[item - 2][1];
new bet_str[128],bet_val[10],bool:set;
copy(bet_str,charsmax(bet_str),g_Cvar[cp]);
while(argbreak(bet_str,bet_val,charsmax(bet_val),bet_str,charsmax(bet_str)) != -1)
{
if(!bet_val[0])
break;
bet_val[0] = str_to_num(bet_val);
// переключаем на большее значение
if(bet_val[0] > players_data[id][sp])
{
set = true;
players_data[id][sp] = bet_val[0];
break;
}
}
// сбрасываем переключатель
if(bet_val[0] <= players_data[id][sp] && !set)
players_data[id][sp] = 0;
switch(item)
{
case 2:
{
if(get_member(id, m_iAccount) < players_data[id][sp])
players_data[id][sp] = 0;
}
case 3,4:
{
new Float: fExp = aes_get_player_exp(id);
new iBonuses = aes_get_player_bonus(id);
if((item == 3 && fExp < players_data[id][sp]) || (item == 4 && iBonuses < players_data[id][sp]))
players_data[id][sp] = 0;
}
}
Bet_MenuFormat(id);
menu_display(id,menu);
}
}
return PLUGIN_HANDLED;
}
// Настраиваем отображение меню
public Bet_MenuFormat(id)
{
new fmt[512],len;
// --- ЗАГОЛОВОК --- //
len += formatex(fmt[len],charsmax(fmt) - len,"%L^n%L^n%L",id,"SF_BET1",id,"SF_BET2",bet_time - get_gametime(),id,"SF_BET3",Bet_Menu_GetBetString(id));
menu_setprop(bet_menu,MPROP_TITLE,fmt);
// --- ВЫХОД --- //
formatex(fmt,charsmax(fmt),"%L",id,"EXIT");
menu_setprop(bet_menu,MPROP_EXITNAME,fmt);
}
// Настраиваем кнопки в меню
public Bet_MenuCallback(id, menu, r_item)
{
new fmt[256],len;
new ri[2],di[2];
menu_item_getinfo(menu,r_item,di[0],ri,charsmax(ri),di,charsmax(di),di[0]);
new item = str_to_num(ri);
if(item == 0)
Bet_MenuFormat(id);
switch(item)
{
// ставки на T или CT
case 0,1:
{
new ct_name[MAX_NAME_LENGTH],bet_id = (item == 0 ? t_id : ct_id);
new rt = ITEM_DISABLED;
get_user_name(bet_id,ct_name,charsmax(ct_name));
len = formatex(fmt[len],charsmax(fmt) - len,"%L",id,"SF_BET6",ct_name,item == 0 ? "T" : "CT");
if(players_data[id][BET_MONEY])
rt = ITEM_ENABLED;
new prize = Bet_GetWinPool(id,BET_MONEY,bet_id);
new prize_str[128],prize_len;
if(prize)
prize_len += formatex(prize_str[prize_len],charsmax(prize_str) - prize_len,"%L",id,"SF_BET5",prize);
prize = Bet_GetWinPool(id,BET_EXP,bet_id)
if(prize)
prize_len += formatex(prize_str[prize_len],charsmax(prize_str) - prize_len,"%s%L",prize_len ? ", " : "",id,"SF_BET4",prize);
prize = Bet_GetWinPool(id,BET_BONUS,bet_id);
if(prize)
prize_len += formatex(prize_str[prize_len],charsmax(prize_str) - prize_len,"%s%L",prize_len ? ", " : "",id,"SF_BET20",prize);
if(players_data[id][BET_EXP] || players_data[id][BET_EXP])
rt = ITEM_ENABLED;
if(prize_str[0])
len += formatex(fmt[len],charsmax(fmt) - len," %L",id,"SF_BET16",prize_str);
if(item == 1)
len += formatex(fmt[len],charsmax(fmt) - len,"^n");
menu_item_setname(menu,r_item,fmt);
return rt;
}
// переключатели
case 2,3,4:
{
new cp = lyl_array[item - 2][0];
new sp = lyl_array[item - 2][1];
switch(item)
{
case 2: len = formatex(fmt[len],charsmax(fmt) - len,"%L",id,"SF_BET7");
case 3: len = formatex(fmt[len],charsmax(fmt) - len,"%L",id,"SF_BET8");
case 4: len = formatex(fmt[len],charsmax(fmt) - len,"%L",id,"SF_BET19");
}
new bet_str[128],bet_val[10];
copy(bet_str, charsmax(bet_str), g_Cvar[cp]);
if(!bet_str[0])
{
menu_item_setname(bet_menu,r_item,fmt);
return ITEM_DISABLED;
}
while(argbreak(bet_str,bet_val,charsmax(bet_val),bet_str,charsmax(bet_str)) != -1)
{
if(!bet_val[0])
break;
bet_val[0] = str_to_num(bet_val);
if(bet_val[0] != players_data[id][sp])
len += formatex(fmt[len],charsmax(fmt) - len," \d[%d]",bet_val[0]);
else
len += formatex(fmt[len],charsmax(fmt) - len," \r[\y%d\r]",bet_val[0]);
}
menu_item_setname(bet_menu,r_item,fmt);
}
}
return ITEM_ENABLED;
}
// лул
Bet_Menu_GetBetString(id)
{
new fmt[512],len;
if(players_data[id][BET_MONEY])
len += formatex(fmt[len],charsmax(fmt) - len,"%L",id,"SF_BET5",players_data[id][BET_MONEY]);
if(players_data[id][BET_EXP])
len += formatex(fmt[len],charsmax(fmt) - len,"%s%L",fmt[0] ? ", " : "",id,"SF_BET4",players_data[id][BET_EXP]);
if(players_data[id][BET_BONUS])
len += formatex(fmt[len],charsmax(fmt) - len,"%s%L",fmt[0] ? ", " : "",id,"SF_BET20",players_data[id][BET_BONUS]);
if(!fmt[0])
copy(fmt,charsmax(fmt),"\d-\w");
return fmt;
}
// чат оповещалка
Bet_Menu_Chat(id)
{
new fmt[512],len;
if(players_data[id][BET_MONEY])
len += formatex(fmt[len],charsmax(fmt) - len,"%L",id,"SF_BET14",players_data[id][BET_MONEY]);
if(players_data[id][BET_EXP])
len += formatex(fmt[len],charsmax(fmt) - len,"%s%L",fmt[0] ? ", " : "",id,"SF_BET15",players_data[id][BET_EXP]);
if(players_data[id][BET_BONUS])
len += formatex(fmt[len],charsmax(fmt) - len,"%s%L",fmt[0] ? ", " : "",id,"SF_BET21",players_data[id][BET_BONUS]);
if(!fmt[0])
copy(fmt,charsmax(fmt),"Ничего");
return fmt;
}
// Узнаем выигрыш ставки
Bet_GetWinPool(id,pool,practicant)
{
new win_bet;
switch(g_Cvar[CVAR_BET_MODE])
{
case 0:
{
new players[MAX_PLAYERS],pnum;
get_players(players,pnum,"ch");
new bet_pool,win_pool;
for(new i,player ; i <pnum ; i++)
{
player = players[i]
if(players_data[player][BET_FOR] == 0 && player != id)
continue;
if(players_data[player][BET_FOR] == practicant || !players_data[player][BET_FOR])
bet_pool += players_data[player][pool];
else
win_pool += players_data[player][pool];
}
if(!bet_pool)
return 0;
// процент ставки игрока от общей суммы
new Float:bet_perc = float(players_data[id][pool]) * 100.0 / float(bet_pool);
win_bet = (win_pool * floatround(bet_perc) / 100);
}
case 1: win_bet = (players_data[id][pool]);
}
win_bet = floatround(win_bet * g_Cvar[CVAR_BET_MULTIPLER]);
return win_bet;
}
// Функция проверки 1x1
Bet_Check1x1()
{
if(t_id && ct_id)
return false;
new players[MAX_PLAYERS],tnum,ctnum;
get_players(players,tnum,"aeh","TERRORIST"); // живые игрока из T
if(tnum == 1)
t_id = players[0]; // запоминаем ID посл. живого T
else
{
t_id = 0;
return false;
}
get_players(players,ctnum,"aeh","CT"); // живые игроки за CT
if(ctnum == 1)
ct_id = players[0]; // запоминаем ID посл. живого CT
else
{
ct_id = 0;
return false;
}
return true; // это 1x1
}
RegisterCvars()
{
bind_pcvar_num(
create_cvar(
.name = "sf_bet_min_players",
.string = "2",
.flags = FCVAR_SERVER,
.description = fmt("%l", "SF_CVAR_MIN_PLAYERS"),
.has_min = true,
.min_val = 0.0
), g_Cvar[CVAR_MIN_PLAYERS]
);
bind_pcvar_num(
create_cvar(
.name = "sf_bet_time",
.string = "15",
.flags = FCVAR_SERVER,
.description = fmt("%l", "SF_CVAR_BET_TIME"),
.has_min = true,
.min_val = 0.0
), g_Cvar[CVAR_BET_TIME]
);
bind_pcvar_string(
create_cvar(
.name = "sf_bet_money",
.string = "100 1000 3000",
.flags = FCVAR_SERVER,
.description = fmt("%l", "SF_CVAR_BET_MONEY")
), g_Cvar[CVAR_BET_MONEY], charsmax(g_Cvar[CVAR_BET_MONEY])
);
bind_pcvar_num(
create_cvar(
.name = "sf_bet_mode",
.string = "1",
.flags = FCVAR_SERVER,
.description = fmt("%l", "SF_CVAR_BET_MODE"),
.has_min = true,
.min_val = 0.0
), g_Cvar[CVAR_BET_MODE]
);
bind_pcvar_float(
create_cvar(
.name = "sf_bet_multipler",
.string = "2.0",
.flags = FCVAR_SERVER,
.description = fmt("%l", "SF_CVAR_BET_MULTIPLER"),
.has_min = true,
.min_val = 0.0
), g_Cvar[CVAR_BET_MULTIPLER]
);
bind_pcvar_string(
create_cvar(
.name = "sf_bet_exp",
.string = "100 200 300",
.flags = FCVAR_SERVER,
.description = fmt("%l", "SF_CVAR_BET_EXP")
), g_Cvar[CVAR_BET_EXP], charsmax(g_Cvar[CVAR_BET_EXP])
);
bind_pcvar_string(
create_cvar(
.name = "sf_bet_bonus",
.string = "5 10 15",
.flags = FCVAR_SERVER,
.description = fmt("%l", "SF_CVAR_BET_BONUS")
), g_Cvar[CVAR_BET_BONUS], charsmax(g_Cvar[CVAR_BET_BONUS])
);
bind_pcvar_num(
create_cvar(
.name = "sf_bet_auto",
.string = "1",
.flags = FCVAR_SERVER,
.description = fmt("%l", "SF_CVAR_BET_AUTOOPEN"),
.has_min = true,
.min_val = 0.0
), g_Cvar[CVAR_BET_AUTOOPEN]
);
}