Post by Carbonzxc on Jul 25, 2021 13:12:13 GMT
Hello,
Normally in my plugin players after switch to boss zs_ maps, they should vote for /boss again after each 3 hour. but now that function not works and they can vote for boss every map even we played boss map recently (last map). i need help for t make it work again as expected
Normally in my plugin players after switch to boss zs_ maps, they should vote for /boss again after each 3 hour. but now that function not works and they can vote for boss every map even we played boss map recently (last map). i need help for t make it work again as expected
#include <amxmodx>
#include <PrintChat>
#include <amxmisc>
#include <engine>
#include <hamsandwich>
#include <xs>
#include <cstrike>
#include <fakemeta>
#include <fakemeta_util>
#include <fun>
#define VOTES 12
#define HOURS 3
#define MINUTES 0
#define SECONDS 0
new g_iTime;
new g_iBoss;
new g_iVotes;
new g_iPlayerVote[33];
new g_szMaps[][] =
{
"zs_frozen_boss",
"zs_cronowing_skvd",
"zs_light_zombie_boss"
}
public plugin_init()
{
// register_menucmd(register_menuid("VoteBoss"), MENU_KEY_1 | MENU_KEY_2 | MENU_KEY_3 | MENU_KEY_4 | MENU_KEY_0, "MenuVoteBoss");
register_clcmd("vtboss", "ClCmdVtboss");
register_clcmd("say /boss", "ClCmdVtboss");
register_clcmd("say_team /boss", "ClCmdVtboss");
register_event("HLTV", "EventRoundStart", "a", "1=0", "2=0");
new szTime[12];
if (get_localinfo("vtbss", szTime, charsmax(szTime))) g_iTime = str_to_num(szTime);
if (get_systime() < g_iTime) set_task(float(g_iTime - get_systime()), "TaskCanVote");
else set_task(120.0, "TaskAdv", _, _, _, "b");
register_dictionary("zp_voteboss.txt");
}
public TaskCanVote()
{
PrintChat(0, "%L", LANG_PLAYER, "#VtbossCanVote");
PrintChat(0, "%L", LANG_PLAYER, "#VtbossAdv");
set_task(120.0, "TaskAdv", _, _, _, "b");
}
public TaskAdv()
{
PrintChat(0, "%L", LANG_PLAYER, "#VtbossAdv");
}
public client_disconnected(iEntity)
{
if (g_iPlayerVote[iEntity])
{
g_iVotes--;
g_iPlayerVote[iEntity] = 0;
}
}
public ClCmdVtboss(iEntity)
{
if (g_iPlayerVote[iEntity])
{
PrintChat(iEntity, "%L", iEntity, "#VtbossYouAlready");
return PLUGIN_HANDLED;
}
if (g_iBoss)
{
PrintChat(iEntity, "%L", iEntity, "#VtbossAlready");
return PLUGIN_HANDLED;
}
new iTime = g_iTime - get_systime();
if (iTime > 0)
{
new iMinutes = (iTime / 60) + ((iTime % 60) ? 1 : 0);
new iHours = (iMinutes / 60);
iMinutes %= 60;
if (iHours) PrintChat(iEntity, "%L", iEntity, "#VtbossWaitHours", iHours, iMinutes);
else PrintChat(iEntity, "%L", iEntity, "#VtbossWaitMinutes", iMinutes);
return PLUGIN_HANDLED;
}
g_iPlayerVote[iEntity] = 1;
if (++g_iVotes == VOTES)
{
new szLang[32];
g_iBoss = random_num(0,2);
formatex(szLang, charsmax(szLang), "#VtbossNext%d", g_iBoss+1);
PrintChat(0, "%L", LANG_PLAYER, szLang);
remove_task();
client_printcolor(0, "!g[Commander] !tMap Changing to %s", g_szMaps[g_iBoss])
server_cmd("changelevel %s", g_szMaps[g_iBoss]);
new szTime[12]
num_to_str(get_systime() + HOURS * 3600 + MINUTES * 60 + SECONDS, szTime, charsmax(szTime));
set_localinfo("vtbss", szTime);
//return PLUGIN_HANDLED;
}
new szLang[32];
formatex(szLang, charsmax(szLang), "#VtbossChosen%d", 1);
PrintChat(0, "%L", LANG_PLAYER, szLang, VOTES - g_iVotes);
return PLUGIN_HANDLED;
}
public EventRoundStart()
{
if (g_iBoss)
{
client_printcolor(0, "!g[Commander] !tMap Changing to %s", g_szMaps[g_iBoss])
server_cmd("changelevel %s", g_szMaps[g_iBoss]);
new szTime[12]
num_to_str(get_systime() + HOURS * 3600 + MINUTES * 60 + SECONDS, szTime, charsmax(szTime));
set_localinfo("vtbss", szTime);
}
}
stock client_printcolor(const id,const input[], any:...)
{
new msg[191], players[32], count = 1;
vformat(msg,190,input,3);
replace_all(msg,190,"!g","^4");// green
replace_all(msg,190,"!n","^1");// normal
replace_all(msg,190,"!t","^3");// team
if (id) players[0] = id; else get_players(players,count,"ch");
for (new i=0;i<count;i++)
if (is_user_connected(players[i]))
{
message_begin(MSG_ONE_UNRELIABLE,get_user_msgid("SayText"),_,players[i]);
write_byte(players[i]);
write_string(msg);
message_end();
}
}
/* AMXX-Studio Notes - DO NOT MODIFY BELOW HERE
*{\\ rtf1\\ ansi\\ deff0{\\ fonttbl{\\ f0\\ fnil Tahoma;}}\n\\ viewkind4\\ uc1\\ pard\\ lang2057\\ f0\\ fs16 \n\\ par }
*/