Raised This Month: $ Target: $400
 0% 

Zero key doesn't work?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Afrow UK
Junior Member
Join Date: Feb 2007
Old 08-28-2007 , 19:48   Zero key doesn't work?
Reply With Quote #1

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
Afrow UK is offline
purple_pixie
Veteran Member
Join Date: Jun 2007
Location: Winchester, England
Old 08-29-2007 , 04:23   Re: Zero key doesn't work?
Reply With Quote #2

All I can say is try the new menu system ... I never got the hang of "MENU_KEY"s
purple_pixie is offline
Afrow UK
Junior Member
Join Date: Feb 2007
Old 08-29-2007 , 09:52   Re: Zero key doesn't work?
Reply With Quote #3

Hmm but I have heard the new menu system isn't wise for lots of players (i.e. this menu will be sent to up to 12 players at the start of a round). Is this true?

Stu
Afrow UK is offline
Afrow UK
Junior Member
Join Date: Feb 2007
Old 08-29-2007 , 10:19   Re: Zero key doesn't work?
Reply With Quote #4

I just tried MENU_KEY_0 in a small test plugin:
Code:
public message_resethud(id)
{
  show_menu(id, MENU_KEY_0, "Accept?", -1, "blah!")
}

public plugin_init()
{
  register_plugin("test", "0.1", "")
  register_event("ResetHUD", "message_resethud", "be")
  register_menucmd(register_menuid("blah!"), MENU_KEY_0, "player_vote")
}

public player_vote(id, key)
{
  client_print(0, print_chat, "Selection accepted!")
  return PLUGIN_HANDLED
}
0 does not close the menu or make a selection. Only MENU_KEY_1-9 work if I set MENU_KEY1-9 for both register_menuid and show_menu...

Edit: And 0 is bound to slot0.

Stu

Last edited by Afrow UK; 08-29-2007 at 10:30.
Afrow UK is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 16:09.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode