I have a tiny problem on my menu which is It doesn't show what the player chose
here's the line
PHP Code:
new player[33]
get_user_name(id, player, charsmax(player))
client_print(0, print_chat, "%s chose %s", player, gVotes)
return PLUGIN_HANDLED;
I also tried
PHP Code:
new player[33]
get_user_name(id, player, charsmax(player))
client_print(0, print_chat, "%s chose %s", player, item)
return PLUGIN_HANDLED;
Result : Player chose
Full code :
PHP Code:
/* Plugin generated by AMXX-Studio */
#include <amxmodx>
#define PLUGIN "New Plug-In"
#define VERSION "1.0"
#define AUTHOR "author"
new rounds = 0;
new gVoteMenu;
new gVotes[2];
new gVoting;
public plugin_init() {
register_plugin(PLUGIN, VERSION, AUTHOR)
register_logevent("round_start", 2, "1=Round_Start")
register_clcmd( "amx_ljvote", "StartVote", ADMIN_RCON );
}
public round_start(){
rounds++;
if (rounds == 1) {
set_task(5.0, "StartVote" );
}
}
public StartVote( id )
{
if ( gVoting )
{
client_print( id, print_chat, "There is already a vote going." );
return PLUGIN_HANDLED;
}
gVotes[0] = gVotes[1] = 0;
gVoteMenu = menu_create( "\rLongjump Stats!:", "menu_handler" );
menu_additem( gVoteMenu, "Enable LongJump Stats", "", 0 );
menu_additem( gVoteMenu, "Disable LongJump Stats", "", 0 );
new players[32], pnum, tempid;
get_players( players, pnum );
for ( new i; i < pnum; i++ )
{
tempid = players[i];
menu_display( tempid, gVoteMenu, 0 );
gVoting++;
}
set_task(10.0, "EndVote" );
return PLUGIN_HANDLED;
}
public menu_handler( id, menu, item )
{
if ( item == MENU_EXIT || !gVoting )
{
return PLUGIN_HANDLED;
}
gVotes[ item ]++;
//Here when it sees what the player chose.
new player[33]
get_user_name(id, player, charsmax(player))
client_print(0, print_chat, "%s chose %s", player, gVotes)
return PLUGIN_HANDLED;
}
public EndVote()
{
if ( gVotes[0] > gVotes[1] ){
client_print(0, print_chat, "Enabling lj recieved (%d ) of votes, It's enabled!", gVotes[0] );
console_cmd(0, "lj_enable 1")
}
else if ( gVotes[0] < gVotes[1] ){
client_print(0, print_chat, "Disabling lj recieved (%d ) of votes, It's disabled!", gVotes[1] );
console_cmd(0, "lj_enable 0")
}
else {
client_print(0, print_chat, "The vote tied at (%d) votes each, Vote will start again in 10 seconds", gVotes[0] );
set_task(10.0, "StartVote" );
}
menu_destroy( gVoteMenu );
gVoting = 0;
}