Senior Member
|
07-03-2019
, 09:39
Re: Vote menu countdown
|
#3
|
Quote:
Originally Posted by Natsheh
PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#include <amxmisc>
#define PLUGIN "vote round restart"
#define VERSION "1.0"
#define AUTHOR "nobody"
#define TASK_VOTE 3032
new g_iMenu, g_iCountdown, bool:g_bVoted[33];
public plugin_init()
{
register_plugin(PLUGIN, VERSION, AUTHOR)
register_clcmd("say .vote","clcmd_vote");
}
public clcmd_vote(id, level, cid)
{
if(!cmd_access(id, level, cid, 1) || task_exists(TASK_VOTE)) return 1;
vote_menu(id, 10, "0", "0"); return 1;
}
vote_menu(id, countdown, szVoteYesNum[], szVoteNoNum[])
{
static szTitle[96];
if(g_iMenu > 0)
{
menu_destroy(g_iMenu); g_iMenu = 0;
}
else if(id > 0)
{
new szName[32];
get_user_name(id, szName, charsmax(szName));
formatex(szTitle,charsmax(szTitle),"VOTE: Round Restart^nBy: %s",szName);
g_iCountdown = countdown;
set_task(1.0, "RD_FinishVote", TASK_VOTE, _, _, "b");
for(new i; i < sizeof g_bVoted; i++) g_bVoted[i] = false;
}
new iAPlayers[32], pnum;
get_players(iAPlayers, pnum, "ach")
new szBuffer[128]
g_iMenu = menu_create(szTitle,"RD_VoteHandler");
formatex(szBuffer,charsmax(szBuffer),"[%s] YES", szVoteYesNum);
menu_additem(g_iMenu,szBuffer,szVoteYesNum);
formatex(szBuffer,charsmax(szBuffer),"[%s] NO", szVoteNoNum);
menu_additem(g_iMenu,szBuffer,szVoteNoNum);
formatex(szBuffer,charsmax(szBuffer),"^n^n^nVote Time %i", countdown);
menu_addtext(g_iMenu, szBuffer);
menu_setprop(g_iMenu,MPROP_EXIT, MEXIT_NEVER);
menu_setprop(g_iMenu,MPROP_NUMBER_COLOR,"\w");
for( new i;i < pnum; i++ ) {
menu_display(iAPlayers[i],g_iMenu,0);
}
}
public RD_FinishVote(taskid)
{
if(g_iMenu <= 0)
{
remove_task(taskid);
return;
}
new szYesVotes[4], szNoVotes[4];
new paccess, callback;
menu_item_getinfo(g_iMenu, 0, paccess, szYesVotes, 3, "", 0, callback);
menu_item_getinfo(g_iMenu, 1, paccess, szNoVotes, 3, "", 0, callback);
if(g_iCountdown <= 0)
{
show_menu( 0, 0, "^n", 1 );
if(str_to_num(szNoVotes) < str_to_num(szYesVotes))
{
client_print_color(0,print_team_default,"VOTE RESTART ROUND: accepted");
}
else
{
client_print_color(0,print_team_default,"VOTE RESTART ROUND: rejected");
}
menu_destroy(g_iMenu);
g_iMenu = 0;
}
else
{
vote_menu(0, g_iCountdown, szYesVotes, szNoVotes);
g_iCountdown--;
return;
}
remove_task(taskid);
}
public RD_VoteHandler(id,iMenu,iItem)
{
if(iItem == MENU_EXIT)
{
return PLUGIN_HANDLED;
}
if(g_bVoted[id])
{
menu_display(id, iMenu);
return PLUGIN_HANDLED;
}
new szYesVotes[4], szNoVotes[4];
new paccess, callback;
menu_item_getinfo(iMenu, 0, paccess, szYesVotes, 3, "", 0, callback);
menu_item_getinfo(iMenu, 1, paccess, szNoVotes, 3, "", 0, callback);
g_bVoted[id] = true; // NoAccess / player voted
switch(iItem)
{
case 0:
{
num_to_str(++str_to_num(szYesVotes), szYesVotes, charsmax(szYesVotes));
vote_menu(0, g_iCountdown, szYesVotes, szNoVotes);
}
case 1:
{
num_to_str(++str_to_num(szNoVotes), szNoVotes, charsmax(szNoVotes));
vote_menu(0, g_iCountdown, szYesVotes, szNoVotes);
}
}
return PLUGIN_HANDLED;
}
|
well I can not compile it because of these errors
error 022: must be lvalue <non-constant>
line 132: num_to_str(++str_to_num(szYesVotes), szYesVotes, charsmax(szYesVotes));
line 137: num_to_str(++str_to_num(szNoVotes), szNoVotes, charsmax(szNoVotes));
__________________
|
|