AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Player menu (https://forums.alliedmods.net/showthread.php?t=11452)

Ramirez 03-19-2005 22:17

Player menu
 
Just a quick question on a player menu...
This menu works in game..
But if for example I press 1(wich should select the 1st player in menu)
It does nothing... but if I press 2 it selects number 1.. and if I choose 3 it selects the 4 and so on...

I checked the code tested some things but I couldnt figure it out..
Could anyone check it out for me and tell me what I did wrong? :(

Code:
#include <amxmodx> #include <amxmisc> #define MENU_SIZE    256 #define MENU_PLAYERS 8 new g_iMenuPosition new g_iMenuPlayers[32] public plugin_init() {     register_menucmd( register_menuid("Model changer menu:"), 1023, "MenuAction" )     register_clcmd( "say menu", "ShowMenu", ADMIN_KICK, "- Shows The Player Menu" ) } public ShowMenu( id, lvl, cid ) {     if( cmd_access( id, lvl, cid, 1 ) )         ShowPlayerMenu( id, g_iMenuPosition = 0 )     return PLUGIN_HANDLED } public ShowPlayerMenu( id, pos ) {     if( pos < 0 ) return     new i, j     new szMenuBody[MENU_SIZE]     new iCurrKey = 0     new szUserName[32]     new iStart = pos * MENU_PLAYERS     new iNum     get_players( g_iMenuPlayers, iNum )     if( iStart >= iNum )         iStart = pos = g_iMenuPosition = 0     new iLen = format( szMenuBody, MENU_SIZE-1, "Model changer menu:^n^n", pos+1, (iNum / MENU_PLAYERS + ((iNum % MENU_PLAYERS) ? 1 : 0 )) )     new iEnd = iStart + MENU_PLAYERS     new iKeys = (1<<9|1<<7)     if( iEnd > iNum )         iEnd = iNum     for( i = iStart; i < iEnd; i++ )     {         j = g_iMenuPlayers[i]         get_user_name( j, szUserName, 31 )         if( (get_user_flags(j) & ADMIN_IMMUNITY) || !is_user_alive(j) )         {             iCurrKey++             iLen += format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "%d. %s^n", iCurrKey, szUserName )         }else         {             iKeys |= (1<<iCurrKey++)             iLen += format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "%d. %s^n", iCurrKey, szUserName )         }     }     if( iEnd != iNum )     {         format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n9. More...^n0. %s", pos ? "Back" : "Exit" )         iKeys |= (1<<8)     }     else         format( szMenuBody[iLen], (MENU_SIZE-1-iLen), "^n0. %s", pos ? "Back" : "Exit" )     show_menu( id, iKeys, szMenuBody, -1 )     return } public MenuAction( id, key ) {     switch( key )     {         case 8: ShowPlayerMenu( id, ++g_iMenuPosition ) // More Option         case 9: ShowPlayerMenu( id, --g_iMenuPosition ) // Back Option         // Chose a Player         default:         {             new iPlayerID = g_iMenuPlayers[g_iMenuPosition * MENU_PLAYERS + key]             new szUsername[32]             get_user_name( iPlayerID, szUsername, 31 )             client_print( id, print_chat, "You Picked Player: '%s'!", szUsername )         }     }     return PLUGIN_HANDLED }

XxAvalanchexX 03-19-2005 22:29

Re: Player menu
 
Quote:

Originally Posted by Ramirez
But if for example I press 1(wich should select the 1st player in menu)
It does nothing... but if I press 2 it selects number 1.. and if I choose 3 it selects the 4 and so on...

If they press number 1, the "key" in the function will be 0, if they press 2 it will be 1, if they press 3 it will be 2, so on and so on, if they press 8 it will be 7, if they press 9 it will be 8, and if they press 0 it will be 9.

Ramirez 03-19-2005 22:33

Ok.
But How come the past menus ive done would select the number ive pressed?
Now it choses the previous number o_O
Not sure if you get what im trying to say lol


All times are GMT -4. The time now is 14:10.

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