AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Problems with a menu (https://forums.alliedmods.net/showthread.php?t=48209)

dutchmeat 12-07-2006 09:23

Problems with a menu
 
This function works:
Code:
<font size="2"> register_menucmd( register_menuid("Do you want to execute command: ?"), 1023, "Confirm" ) public Askmenu(id){ new szMenuBody[256] new keys format( szMenuBody, 255, "Do you want to execute command: ? ^n1. Yes!^n2 No!^n3. Exit") keys = (1<<0|1<<1|1<<2) show_menu( id, keys, szMenuBody, -1 ) return PLUGIN_HANDLED } public Confirm( id , key ) { switch( key ) { case 0: { client_print(id,print_chat,"Yes") log_amx("YES") } case 1: { client_print(id,print_chat,"No") log_amx("YES") } default: { client_print(id,print_chat,"DEBUG!") } } return PLUGIN_HANDLED } </font>


But this doesn't work (i use this function inside another function),both players are recognised but 'yes' or 'no' does not work, i get the original botmenu (ESF).

Code:
<font size="2"> register_menucmd( register_menuid("Do you want to do things with: ?"), 1023, "Confirm" ) public FusionAskmenu(id,id2){ new szMenuBody[256] new keys new szUserName[32] get_user_name( id2, szUserName, 31 ) format( szMenuBody, 255, "Do you want to do things with: %s? ^n1. Yes!^n2 No!^n3. Exit",szUserName) keys = (1<<0|1<<1|1<<2) show_menu( id, keys, szMenuBody, -1 ) return PLUGIN_HANDLED } public Confirm( id , key ) { switch( key ) { case 0: { client_print(id,print_chat,"Yes") log_amx("YES") } case 1: { client_print(id,print_chat,"No") log_amx("YES") } default: { client_print(id,print_chat,"DEBUG!") } } return PLUGIN_HANDLED } </font>

Does this problem has to do with implenting the name in the 'Ask menu'?
Thanks in advance

VEN 12-07-2006 11:03

Re: Problems with a menu
 
Yes, and please indent next time.

dutchmeat 12-07-2006 11:23

Re: Problems with a menu
 
yes, so how can i fix this? I can't implent a '%s' in registermenu right ?
or can i use:
^"%s^"

VEN 12-07-2006 12:02

Re: Problems with a menu
 
The only way would be register_menuid("Do you want to execute command:")

dutchmeat 12-07-2006 14:50

Re: Problems with a menu
 
So i can't set a variable in a menu command like:

register_menuid("Do you want to execute command: %s",name)

jim_yang 12-08-2006 01:32

Re: Problems with a menu
 
Code:
#include <amxmodx> #include <amxmisc> #define KEY (1<<0)|(1<<1) public plugin_init() {         register_menucmd(register_menuid("Test"), KEY, "key_pressed")         register_clcmd("test","test") } public test(id) {         showmenu(id, 1)         return PLUGIN_HANDLED } public showmenu(id1, id2) {         new name[32], menubody[48]         get_user_name(id2, name, 31)         format(menubody, 47, "Hello %s^n1. Yes^n2. No", name)         show_menu(id1, KEY, menubody, -1, "Test") } public key_pressed(id, key) {         client_print(id, print_chat, "pressed key: %d", key)         return PLUGIN_HANDLED }

VEN 12-08-2006 04:09

Re: Problems with a menu
 
Quote:

So i can't set a variable in a menu command like
You can but it will not take the effect as you expecting. register_menuid doesn't confirm format routines. If your name are constant you can explicitly specify it or format yourself. If it unconstant then you can register the different menuids for every name. In other case just register all that menus by a common phrase as i showed above.

dutchmeat 12-08-2006 04:43

Re: Problems with a menu
 
I wanted my output like this:

"Do you want to do things with: dutchmeat?"
"yes"
"no"

but instead i've used this:

"Do you want to do things with:"
"dutchmeat"
"no"


All times are GMT -4. The time now is 06:54.

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