AlliedModders

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

atambo 09-03-2005 23:24

menu help
 
1 Attachment(s)
I made a new remove credit menu for credit mod but when I am looking at the "(Cont) Remove Item Menu" and I click on anything it will use the RemoveAIMenu(id, keys) instead of the RemoveTWOAIMenu(id, keys) function...I'm going to attach the plugin below and post the parts that are important I've tried renaming them a few times and everything else is working fine but for some reason it doesn't want to use the RemoveTWOAIMenu(id, keys) with the "(Cont) Remove Item Menu"

Code:
    register_menucmd(register_menuid("Remove Item Menu"), 1023, "RemoveAIMenu")     register_menucmd(register_menuid("(Cont) Remove Item Menu"), 1023, "RemoveTWOAIMenu")

Code:
public RemoveIMenu(id) {     new authid[32]     new playtime = (get_user_time(id) - lastplaytime[id])     lastplaytime[id] = get_user_time(id)     get_user_authid(id,authid,31)     new tmp_vault_time,vault_time[21]     get_vaultdata(authid,vault_time,20)     tmp_vault_time = str_to_num(vault_time)     tmp_vault_time += playtime     connecttime[id] = tmp_vault_time     num_to_str(tmp_vault_time,vault_time,20)     set_vaultdata(authid,vault_time)     new tmp_minutes = floatround(float(connecttime[id]/60),floatround_floor)     new minutes = tmp_minutes % (credittime/60)     new keys     new szMenuBody[512]     new len = format(szMenuBody, 511, "\yRemove Item Menu:^n")     len += format(szMenuBody[len], 511-len, "^n\w1. Battle Aura (Cost: %d Credit)", hpscost)     len += format(szMenuBody[len], 511-len, "^n\w2. First Aid (Cost: %d Credit)", regenerationcost)     len += format(szMenuBody[len], 511-len, "^n\w3. Weapon Training (Cost: %d Credit)", weapontrainingcost)     len += format(szMenuBody[len], 511-len, "^n\w4. Jump Module (Cost: %d Credit)", jumpmodulecost)     len += format(szMenuBody[len], 511-len, "^n\w5. Climbing Gear (Cost: %d Credit)", climbgearcost)     len += format(szMenuBody[len], 511-len, "^n\w6. Promotion (Cost: %d Credit)", promocost)     len += format(szMenuBody[len], 511-len, "^n\w7. Unlimited Ammo (Cost: %d Credit)", unlacost)     len += format(szMenuBody[len], 511-len, "^n\w8. Next Items")     len += format(szMenuBody[len], 511-len, "^n^n\w9.  Back")     len += format(szMenuBody[len], 511-len, "^n\w0.  Cancel")     len += format(szMenuBody[len], 511-len, "^n^nCredits: %i (%i minutes remaining until next credit)",connecttime[id]/credittime,(credittime/60)-minutes)     keys = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<7|1<<8|1<<9)     show_menu(id, keys, szMenuBody, -1)     return PLUGIN_HANDLED } public RemoveAIMenu(id, key) {     switch(key)     {         case 0:         {             if(hpstlr[id] == 0)                 client_print(id, print_chat, "[AMXX] You do not have Battle Aura to remove")             else             {                 creditsspent[id]--                 itemcap[id]--                 hpstlr[id] = 0                 upgraderemoved(id)             }             RemoveIMenu(id)         }         case 1:         {             if(regeneration[id] == 0)                 client_print(id, print_chat, "[AMXX] You do not have First Aid to remove")             else             {                 creditsspent[id]--                 itemcap[id]--                 regeneration[id] = 0                 if(task_exists(FAID_TASK +id))                     remove_task(FAID_TASK + id)                 upgraderemoved(id)             }             RemoveIMenu(id)         }         case 2:         {             if(weapontraining[id] == 0)                 client_print(id, print_chat, "[AMXX] You do not have Weapon Training to remove")             else             {                 creditsspent[id]--                 itemcap[id]--                 weapontraining[id] = 0                 upgraderemoved(id)             }             RemoveIMenu(id)         }         case 3:         {             if(jumpmodule[id] == 0)                 client_print(id, print_chat, "[AMXX] You do not have Jump Module to remove")             else             {                 creditsspent[id]--                 itemcap[id]--                 jumpmodule[id] = 0                 upgraderemoved(id)             }             RemoveIMenu(id)         }         case 4:         {             if(climb[id] == 0)                 client_print(id, print_chat, "[AMXX] You do not have Climbing Gear to remove")             else             {                 creditsspent[id]--                 itemcap[id]--                 climb[id] = 0                 if(task_exists(CLIMB_TASK +id))                     remove_task(CLIMB_TASK + id)                 upgraderemoved(id)             }             RemoveIMenu(id)         }         case 5:         {             if(promotion[id] == 0)                 client_print(id, print_chat, "[AMXX] You do not have Promotion to remove")             else             {                 creditsspent[id]--                 itemcap[id]--                 promotion[id] = 0                 upgraderemoved(id)             }             RemoveIMenu(id)         }         case 6:         {             if(gHasuammo[id] == 0)                 client_print(id, print_chat, "[AMXX] You do not have Unlimited Ammo to remove")             else             {                 creditsspent[id]--                 itemcap[id]--                 gHasuammo[id] = 0                 upgraderemoved(id)             }             RemoveIMenu(id)         }         case 7: RemoveTWOIMenu(id)         case 8: RemoveMenu(id)     }     return PLUGIN_HANDLED } public RemoveTWOIMenu(id) {     new authid[32]     new playtime = (get_user_time(id) - lastplaytime[id])     lastplaytime[id] = get_user_time(id)     get_user_authid(id,authid,31)     new tmp_vault_time,vault_time[21]     get_vaultdata(authid,vault_time,20)     tmp_vault_time = str_to_num(vault_time)     tmp_vault_time += playtime     connecttime[id] = tmp_vault_time     num_to_str(tmp_vault_time,vault_time,20)     set_vaultdata(authid,vault_time)     new tmp_minutes = floatround(float(connecttime[id]/60),floatround_floor)     new minutes = tmp_minutes % (credittime/60)     new keys     new szMenuBody[512]     new len = format(szMenuBody, 511, "\y(Cont) Remove Item Menu:^n")     len += format(szMenuBody[len], 511-len, "^n\w1. E.S.P (Cost: %d Credit)", espcost)     len += format(szMenuBody[len], 511-len, "^n\w2. Laser Pointer (Cost: %d Credit)", lasercost)     len += format(szMenuBody[len], 511-len, "^n\w3. Crowbar (Cost: %d Credit)", crowbarcost)     len += format(szMenuBody[len], 511-len, "^n\w4. Stealth Shoes (Cost: %d Credit)", sshoecost)     len += format(szMenuBody[len], 511-len, "^n^n\w9.  Back")     len += format(szMenuBody[len], 511-len, "^n\w0.  Cancel")     len += format(szMenuBody[len], 511-len, "^n^nCredits: %i (%i minutes remaining until next credit)",connecttime[id]/credittime,(credittime/60)-minutes)     keys = (1<<0|1<<1|1<<2|1<<3|1<<8|1<<9)     show_menu(id, keys, szMenuBody, -1)     return PLUGIN_HANDLED } public RemoveTWOAIMenu(id, key) {     switch(key)     {         case 0:         {             if(esp[id] == 0)                 client_print(id, print_chat, "[AMXX] You do not have ESP to remove")             else             {                 creditsspent[id]--                 itemcap[id]--                 esp[id] = 0                 if(task_exists(ESP_TASK +id))                     remove_task(ESP_TASK + id)                 upgraderemoved(id)             }             RemoveTWOIMenu(id)         }         case 1:         {             if(laser[id] == 0)                 client_print(id, print_chat, "[AMXX] You do not have Laser Pointer to remove")             else             {                 creditsspent[id]--                 itemcap[id]--                 laser[id] = 0                 upgraderemoved(id)             }             RemoveTWOIMenu(id)         }         case 2:         {             if(crowbar[id] == 0)                 client_print(id, print_chat, "[AMXX] You do not have Crowbar to remove")             else             {                 creditsspent[id]--                 itemcap[id]--                 crowbar[id] = 0                 upgraderemoved(id)             }             RemoveTWOIMenu(id)         }         case 3:         {             if(sshoe[id] == 0)                 client_print(id, print_chat, "[AMXX] You do not have Stealth Shoes to remove")             else             {                 creditsspent[id]--                 itemcap[id]--                 sshoe[id] = 0                 set_user_footsteps(id, 0)                 upgraderemoved(id)             }             RemoveTWOIMenu(id)         }         case 8: RemoveIMenu(id)     }     return PLUGIN_HANDLED }

pdoubleopdawg 09-03-2005 23:30

It's more effencient to use the shortcut
register_menu.
http://www.amxmodx.org/funcwiki.php?go=func&id=603

Code:

public RemoveTWOIMenu(id)
You forgot to add keys?

If you did:
Make sure you add it in all of the references to the functions too.

atambo 09-03-2005 23:33

public RemoveTWOIMenu(id)

nah that's not supposed to have keys the public RemoveTWOAIMenu(id, key) is supposed to handle the keys that the public RemoveTWOIMenu(id) supplies it...but for some reason its using the public RemoveAIMenu(id, key) method instead

pdoubleopdawg 09-03-2005 23:34

Oh, there's little difference inbetween the function names, didn't analyse them very well.

atambo 09-03-2005 23:36

how would I go about using the register_menu instead?

pdoubleopdawg 09-03-2005 23:36

Quote:

Originally Posted by atambo
public RemoveTWOIMenu(id)

nah that's not supposed to have keys the public RemoveTWOAIMenu(id, key) is supposed to handle the keys that the public RemoveTWOIMenu(id) supplies it...but for some reason its using the public RemoveAIMenu(id, key) method instead

What do you mean method?
Do you mean it's going to the RemoveAIMenu function?

Same thing

register_menu("Title:",1023,"Function")

atambo 09-03-2005 23:40

ya its displaying the correct menu but when the RemoveTWOIMenu(id) menu passes its keys it passes them to the RemoveAIMenu(id, key) function instead of the RemoveTWOIMenu(id)...and its not registered to do that:

Code:
register_menucmd(register_menuid("Remove Item Menu"), 1023, "RemoveAIMenu")     register_menucmd(register_menuid("(Cont) Remove Item Menu"), 1023, "RemoveTWOAIMenu")

atambo 09-03-2005 23:55

Code:
register_menu("(Cont) Remove Item Menu", 1023, "RemoveTWOAIMenu")

I tried using register_menu instead and its giving me the same problem...anyone have any ideas?

pdoubleopdawg 09-03-2005 23:56

Not really.. Maybe make the names not contain eachother? :? Bad idea..

atambo 09-04-2005 00:11

well I changed the name of the menu to (Cont) Item Menu and now it seems to work...I guess the names were to close to eachother :? oh well thanx for the help!


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

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