AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Why isn't this working? (https://forums.alliedmods.net/showthread.php?t=26744)

NewUser 04-08-2006 15:19

Why isn't this working?
 
Code:
public gaben(id) {     if(bool1[id])     {         client_print(id,print_chat, "bool1 error");         return PLUGIN_HANDLED;     }     if(bool2[id])     {         client_print(id,print_chat, "bool2 error");         return PLUGIN_HANDLED;     }         new lawl[256];     new key = (1<<0|1<<1|1<<2|1<<3|1<<4|1<<5|1<<6|1<<9)         format(lawl,sizeof(lawl), "menu name^n");         add(lawl,sizeof(lawl), "^n1. gaben");     add(lawl,sizeof(lawl), "^n2. yams");     add(lawl,sizeof(lawl), "^n3. turtle");     add(lawl,sizeof(lawl), "^n4. squirrel");     add(lawl,sizeof(lawl), "^n5. exit game");     add(lawl,sizeof(lawl), "^n6. sandwich");     add(lawl,sizeof(lawl), "^n^n0. Exit");     show_menu(id,key,lawl);         return PLUGIN_CONTINUE; } public gaben_exec(id, key) {     if(key == 0) func1(id);         else if(key == 1) func2(id);         else if(key == 2) func3(id)         else if(key == 3) func4(id);         else if(key == 4) func5(id);         else if(key == 5) func6(id);         else if(key == 9) return PLUGIN_HANDLED;         return PLUGIN_HANDLED; }

No errors what so ever. Nor any warnings. The menu shows up, nothing functions. Yes, the functions do exist. Also the execute is registered in public plugin init.

Code:
    register_menucmd(register_menuid("menu name:"), 1023, "gaben_exec");

wouter 04-08-2006 15:25

musnt it be like this?
Code:
public gaben_exec(id, key)     {     if(key == 0) {         func1(id);     }         else if(key == 1) {         func2(id);     }         else if(key == 2) {         func3(id)     }         else if(key == 3) {         func4(id);     }         else if(key == 4) {         func5(id);     }         else if(key == 5) {         func6(id);     }         else if(key == 9) {         return PLUGIN_HANDLED;     }         return PLUGIN_HANDLED; }

[ --<-@ ] Black Rose 04-08-2006 15:25

nope
but even better would be
Code:
public gaben_exec(id, key) {     switch ( key ) {         case 0: func1(id);                 case 1: func2(id);                 case 2: func3(id)                 case 3: func4(id);                 case 4: func5(id);                 case 5: func6(id);                 case 9: return PLUGIN_HANDLED;     }     return PLUGIN_HANDLED; }

NewUser 04-08-2006 15:30

Quote:

Originally Posted by [ --<-@
Black Rose]nope
but even better would be
Code:
public gaben_exec(id, key) {     switch ( key ) {         case 0: func1(id);                 case 1: func2(id);                 case 2: func3(id)                 case 3: func4(id);                 case 4: func5(id);                 case 5: func6(id);                 case 9: return PLUGIN_HANDLED;     }     return PLUGIN_HANDLED; }

That's basicly the same thing... Am I not right?

[ --<-@ ] Black Rose 04-08-2006 15:31

faster
but i cant se any errors in your code.

capndurk 04-08-2006 15:31

Code:
register_menucmd(register_menuid("menuid"), key, "gaben_exec");

Code:
show_menu(id, key, menuBody,_, "menuid");

try that

//edit// fixed, specify the menuid to whatever you want

NewUser 04-08-2006 20:28

Quote:

Originally Posted by [ --<-@
Black Rose]faster
but i cant se any errors in your code.

Great. I tried your case #: stuff, all it did was make things worse. I tried it on my other menus that worked before.

-Demonsthenes- 04-08-2006 21:43

Code:
#include <amxmodx> #define Keysmenuname (1<<0)|(1<<1)|(1<<2)|(1<<3)|(1<<4)|(1<<5)|(1<<9) // Keys: 1234560 public plugin_init() {     register_plugin("gaben",".1","amxmodxGabenNoob")     register_menucmd(register_menuid("menuname"), Keysmenuname, "Pressedmenuname")     register_clcmd("gaben","Showmenuname") } public Showmenuname(id) {     new menu_text[255] = "menu name"     format(menu_text,255,"%s^n1. gaben",menu_text)     format(menu_text,255,"%s2. yams^n",menu_text)     format(menu_text,255,"%s3. turtle^n",menu_text)     format(menu_text,255,"%s4. squirrel^n",menu_text)     format(menu_text,255,"%s5. exit game^n",menu_text)     format(menu_text,255,"%s6. sandwhich^n",menu_text)     format(menu_text,255,"%s0. Exit^n",menu_text)     show_menu(id, Keysmenuname, menu_text, -1, "menuname") } public Pressedmenuname(id, key) {     switch (key) {         case 0: func1(id)         case 1: func2(id)           case 2: func3(id)         case 3: func4(id)         case 4: func5(id)         case 5: func6(id)         case 9: return PLUGIN_HANDLED           }     return PLUGIN_HANDLED } public func1(id) {     client_print(id,print_chat,"1") } public func2(id) {     client_print(id,print_chat,"2") } public func3(id) {     client_print(id,print_chat,"3") } public func4(id) {     client_print(id,print_chat,"4") } public func5(id) {     client_print(id,print_chat,"5") } public func6(id) {     client_print(id,print_chat,"6") }


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

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