PHP Code:
public plugin_init
{
register_menucmd(register_menuid("VoteMenu"), 1023, "CountVotes")
}
new ga_Choice[3]
new bool:voting = false
public client_putinserver(id)
{
new g_iPlayers[32]
new g_iNum;
get_players(g_iPlayers, g_iNum, "ch");
if(g_iNum >= 4 && !voting)
{
InitVote()
}
}
public InitVote()
{
voting = true
static menuBody[512]
format(menuBody,511,"\rRandom Spawn?^n1. Yes^n2. No");
ga_Choice[1] = 0
ga_Choice[2] = 0
show_menu( 0, (1<<1)|(1<<2), menuBody, 14, "VoteMenu" )
set_task(15.0,"showResult");
}
public CountVotes(key)
{
++ga_Choice[key]
}
public showResult()
{
new TotalVotes = ga_Choice[1] + ga_Choice[2]
new Float:result = (float(ga_Choice[1]) / float(TotalVotes))
if( result >= 5.0)
{
//trun on
}
else
{
//turn off
}
}
__________________