AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   [Menu] Why when I'm pressing 1 plugin gets 0 (https://forums.alliedmods.net/showthread.php?t=63932)

orglee 12-03-2007 16:31

[Menu] Why when I'm pressing 1 plugin gets 0
 
Hello.
Why when I'm pressing 1 while being in the rifle menu plugin gets 0
and 0 is 9 for him. Is this the way it should be or I screwed something up ?
- Im checking key value with this:
Code:
client_print(id, print_chat, "Key = %d, Player = %d", key, id)
My code:
Code:
new menu_rifle_keys = 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 new g_rifle_names[14][] = {     "Clarion", "M4A1",     "Bullpup", "Galil",     "AK47", "Krieg",     "Scout", "AWP",     "Ingram", "Schmidt",     "UMP", "P90",     "MP5", "M249"} new g_rifle_ids[14][] = {     "weapon_famas", "weapon_m4a1",     "weapon_aug", "weapon_galil",     "weapon_ak47", "weapon_sg552",     "weapon_scout", "weapon_awp",     "weapon_mac10", "weapon_tmp",     "weapon_ump45", "weapon_p90",     "weapon_mp5navy", "weapon_m249"} public menuRifleHandler(id, key) {   client_print(id, print_chat, "Key = %d, Player = %d", key, id)     new current_page = riflePageGet(id)   // Next page   if(key == 9)   {     if(current_page < 2)     {       riflePageSet(id, current_page + 1)     }   }   // Back   else if(key == 0)   {     if(current_page > 1)     {       riflePageSet(id, current_page - 1)     }   }   menuRifle(id) } public menuRifle(id) {   new menutext[192]     new current_page = riflePageGet(id)   if(current_page == 1)   {     format(menutext, 191, "\^n\r1. \w%s^n\r2. \w%s^n\r3. \w%s^n\r4. \w%s^n\r5. \w%s^n\r6. \w%s^n\r7. \w%s^n\r9. \wNext",         g_rifle_names[0],         g_rifle_names[1],         g_rifle_names[2],         g_rifle_names[3],         g_rifle_names[4],         g_rifle_names[5],         g_rifle_names[6])   } else {     format(menutext, 191, "\r1. \w%s^n\r2. \w%s^n\r3. \w%s^n\r4. \w%s^n\r5. \w%s^n\r6. \w%s^n\r7. \w%s^n\r0. \wPrevious",         g_rifle_names[7],         g_rifle_names[8],         g_rifle_names[9],         g_rifle_names[10],         g_rifle_names[11],         g_rifle_names[12],         g_rifle_names[13])   }   show_menu(id, menu_rifle_keys, menutext, -1, "Rifle_Menu") }

ConnorMcLeod 12-03-2007 17:14

Re: [Menu] Why when I'm pressing 1 plugin gets 0
 
That's it: 0=slot1, 8 = slot9, 9 = slot10

orglee 12-03-2007 17:30

Re: [Menu] Why when I'm pressing 1 plugin gets 0
 
] bind 9
"9" = "slot9"
] bind 0
"0" = "slot10"
] bind 1
"1" = "slot1"
In other menu I have the same weird thing

ConnorMcLeod 12-03-2007 17:50

Re: [Menu] Why when I'm pressing 1 plugin gets 0
 
You don't get it.
In you function menuRifleHandler, key 0 is slot1, etc.., you just have to deal with it.

M249-M4A1 12-03-2007 17:51

Re: [Menu] Why when I'm pressing 1 plugin gets 0
 
Quote:

Originally Posted by connorr (Post 559590)
You don't get it.
In you function menuRifleHandler, key 0 is slot1, etc..

@orglee, connorr is pointing out that the keys are 1 off from the slot, much like array[0] is the first element, and array[1] refers to the second.


All times are GMT -4. The time now is 11:12.

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