Keymenu

From EventScripts Community Encyclopedia

Contents

Overview

Syntax: keymenu <command> <parameters>

Note: Command parameters are described inside the < and > characters. Optional parameters are contained within [ and ] characters.

Description

Creates a dynamic AMX-Style menu using a keygroup.


Note: It doesn't expand server variables. Prefix the command with es to expand variables (es keymenu).

Parameters

  • command - tells what to do to your popup
  • parameters - command specific parameters

<userComments></userComments>

Commands

keymenu create <menu name> <return var> <script/block> <keygroup> <menu display> <menu return> Menu Title Text[\nOptional Description Text]

Creates a dynamic menu using a keygroup and additional parameters.
  • <menu name> - The name of your menu.
  • <return var> - When a player makes a selection from your menu, this variable will be set to what their selection was
  • <script/block> - This block will be executed when a player makes a selection from the menu
  • <keygroup> - The keygroup that you use to build the menu with
  • <menu display> - The text that will display as the options in the menu
    • <#key> - Uses the keys from the keygroup as the display
    • <#keyvalue> <key value name> - Uses the key values as the display
  • <menu return> - The value you want to return upon the player's selection from the menu
    • <#key> - Uses the keys from the keygroup to set the return var
    • <#keyvalue> <key value name> - Uses the key values to set the return var
  • Menu Title Text - The title you want to have across the top of your menu. As an optional parameter, you can add "Menu Title Text\nAdditional Text For Next Line Down" (description text)
keymenu delete <menu name>

Deletes a keymenu from memory.
keymenu getpages <var> <menu name>

Retrieves the number of pages there are in the dynamic menu and sets the variable as the number of pages. (In ESv 1.5, an automatic variable check was added to automatically create the variable if it does not exist)
keymenu exists <var> <menu name>

(Added in ES v1.5) Sets the variable to "1" if the keymenu exists, "0" if it does not exist. (an automatic variable check was added to automatically create the variable if it does not exist)
keymenu send <menu name> <userid> [page]

Sends the dynamic menu to the player. If you use the optional page parameter, you can send the menu and have them start on a particular page.
keymenu setvar <menu name> <menu var> <menu value>

(Added in ES v1.5.0.170a) Sets an internal popup variable. This is for advanced scripters only.
keymenu getvar <menu name> <var> <menu var>

(Added in ES v1.5.0.170a) Gets an internal popup variable. This is for advanced scripters only.
keymenu backmenu <menu name> <keymenu/popup>

(Added in ES v1.5.0.170a) Assigns a popup (first checked) or keymenu (second checked) to the 0. Cancel option of the keymenu. This menu will appear if the player hits 0. Cancel.
keymenu getmenuname <var> <popup-name>

(Added in ES v1.5.0.170a) Gets the keymenu-name the popup is assigned to. This is for advanced scripters only.

Examples

This demonstrates a popup test script (save to popupt/es_popupt.txt)

// Scriptname: myscript 
 
event player_say 
{
   if (event_var(text) = showmenu) do
   {
      keymenu exists exists_var mymenu
      if (server_var(exists_var) = 1) then keymenu delete mymenu 
      es_createplayerlist playerlist
      // Creates a menu with player names, and passes the userid when selected 
      keymenu create mymenu myvar myscript/myblock playerlist #keyvalue name #key My PlayerList\nAlways Current When Typed
      es keymenu send mymenu event_var(userid) 
      keymenu getpages myvar mymenu 
      es_tell event_var(userid) Menu has server_var(myvar) pages 
      es_keygroupdelete playerlist
   }
} 
 
block myblock 
{ 
   es_tell server_var(_popup_userid) You chose Userid: server_var(myvar) 
}

Notes

  • Uses popup. See popup documentation for further (more detailed) information
  • Any time the user selects something from the menu, server_var(_popup_userid) can be used to retrieve the userid of the player that selected an option from the menu.
  • Needs corelib to be loaded prior executing es_load keymenu
  • Included in EventScripts v1.3
  • Keymenu does not work in Half-Life 2 Deathmatch or in mods using that game as their base.

See also

blog comments powered by Disqus