For register_menucmd I have keys MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|M ENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|ME NU_KEY_9|MENU_KEY_0
For show_menu I have keys=MENU_KEY_0 followed by some keys|=(1<<j) where j is a counter from 0 to x players.
For some reason the zero (0) key doesn't do anything! Somebody said it did work, but I haven't seen this!
Some of the code:
Code:
#define KEYS_PLAYERVOTE MENU_KEY_1|MENU_KEY_2|MENU_KEY_3|MENU_KEY_4|MENU_KEY_5|MENU_KEY_6|MENU_KEY_7|MENU_KEY_8|MENU_KEY_9|MENU_KEY_0
register_menucmd(register_menuid("Team Player Vote results: "), KEYS_PLAYERVOTE, "player_vote")
...
// ---------------------------------------------------------------------------------
// Display the team player vote options.
// ---------------------------------------------------------------------------------
show_player_vote(id)
{
new player_count = get_playersnum()
new player_timeshow = get_pcvar_num(g_cvar_pv_timeshow)
// Prepare a list of player names for the vote:
// If you've been playing for more than X minutes.
// If there are more than X players on each team.
if ((floatround(float(get_user_time(id, true)) / 60, floatround_floor) >= player_timeshow) && player_vote_enoughplayers(player_count))
{
new vote_text[LEN_MENUTEXT]
new player_timelist = get_pcvar_num(g_cvar_pv_timelist)
formatex(vote_text, LEN_MENUTEXT - 1, "Please vote for your favourite^nteam player from the last %d rounds:^n", get_pcvar_num(g_cvar_pv_rounds))
// Set to true if one player has been added.
new bool:menu_show = false
// Sets the keys for the menu.
new keys = MENU_KEY_0
// Get the team of the player that is voting.
new player_team[LEN_NAME]
get_user_team(id, player_team, LEN_NAME - 1)
for (new i=1, j=0; i<=player_count; i++)
{
if (is_user_connected(i)/* && !is_user_bot(i)*/)
{
// Check that this player to be added isn't you,
// that they are on the same team as you and
// that that player has been playing for more than X minutes.
new player_team_vote[LEN_NAME]
get_user_team(i, player_team_vote, LEN_NAME - 1)
if ((i != id) && equal(player_team, player_team_vote) && (floatround(float(get_user_time(i, true)) / 60, floatround_floor) >= player_timelist))
{
// Add a menu key.
keys |= (1<<j) // 0 = #1 key, 1 = #2 key, 2 = #3 key etc.
// Add the player to our player ids array.
g_players[id][playervote_ids][j] = i
// Next player to vote for.
j++
// #9 key is cancel.
if (j == 9) break
// Add the player to the vote text.
format(vote_text, LEN_MENUTEXT - 1, "%s^n%d: %s", vote_text, j, g_players[i][player_name])
// Show the menu now that at least one player is on the list.
menu_show = true
}
}
}
// Show the menu if there are any players on it.
if (menu_show)
{
// Add cancel item.
format(vote_text, LEN_MENUTEXT - 1, "%s^n^n0: None", vote_text)
// Display menu to player.
show_menu(id, keys, vote_text, -1, "Team Player Vote results: ")
}
}
return PLUGIN_CONTINUE
}
// ---------------------------------------------------------------------------------
// Called when a vote is sent (keys 0-9).
// key=value: 0=1, 1=2... 9=0.
// ---------------------------------------------------------------------------------
public player_vote(id, key)
{
if (key != 9)
{
new player_team[LEN_NAME]
get_user_team(id, player_team, LEN_NAME - 1)
g_players[g_players[id][playervote_ids][key]][player_score]++
client_print(0, print_chat, "* %s (%s) voted for %s as his favoured team player!", g_players[id][player_name], player_team, g_players[g_players[id][playervote_ids][key]][player_name])
}
return PLUGIN_HANDLED
}
Any ideas why?
Stu