07-18-2005 , 14:33 #3 --------------------------------------------------------------------------------
Try this ( command: amx_voterr ):
Code:
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "Vote Restart"
#define VERSION "0.1"
#define AUTHOR "v3x"
#define ACCESS_LEVEL ADMIN_VOTE // Access level required
public plugin_init()
{
register_plugin(PLUGIN,VERSION,AUTHOR)
register_menucmd(register_menuid("\yRestart Round?"),1023,"do_vote")
register_clcmd("amx_voterr","vote_rr",ACCESS_LEVEL,"- Vote for round restart")
}
new g_iVotes[2]
public vote_rr(id,level,cid)
{
if(!cmd_access(id,level,cid,1))
return PLUGIN_HANDLED
new szMenuBody[256]
new keys
new len = format(szMenuBody,255,"\yRestart Round?")
len += format(szMenuBody[len],255-len,"^n^n\w1. \rYes")
len += format(szMenuBody[len],255-len,"^n\w2. \rNo")
keys = (1<<0|1<<1)
show_menu(0,keys,szMenuBody,get_cvar_num("amx_vote_time"),"voting")
set_task(get_cvar_float("amx_vote_time"),"show_results")
return PLUGIN_HANDLED
}
public do_vote(id,key)
{
if(key == 0)
{
g_iVotes[0]++
}
if(key == 1)
{
g_iVotes[1]++
}
if(get_cvar_num("amx_vote_answers"))
{
new szUsername[33]
get_user_name(id,szUsername,32)
client_print(0,3,"%s voted %s",szUsername,(key == 0) ? "for" : "against")
}
return PLUGIN_HANDLED
}
public show_results()
{
client_print(0,print_chat,"Voting results: %i for - %i against",g_iVotes[0],g_iVotes[1])
if(g_iVotes[0] > g_iVotes[1])
{
set_cvar_num("sv_restartround",1)
client_print(0,3,"Voting successful")
}
else if(g_iVotes[0] < g_iVotes[1])
{
client_print(0,3,"Voting failed")
}
g_iVotes[0] = 0
g_iVotes[1] = 0
return PLUGIN_HANDLED
}