AlliedModders

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

sibox 01-02-2011 03:18

Why is this not working
 
Code:
public ReadKey(szLine[]) {     new szBuffer[32];     new b = 0;     if(szBuffer[0] == '/' && szBuffer[1] == '/') { str_to_num(szLine) + 1; }     read_file(g_Buttons, str_to_num(szLine), szBuffer, 31, b) } stock keys_func(i) {     new fsize = file_size(filename, 1)     for(new z = 0; z < fsize;z++)     switch(i) {             case 2:buttons         = "ReadKey(z)"             case 3:buttons        = "ReadKey(z)"             case 4:buttons         = "ReadKey(z)"             case 5:buttons         = "ReadKey(z)"             case 6:buttons         = "ReadKey(z)"             case 7:buttons        = "ReadKey(z)"             case 8:buttons         = "ReadKey(z)"             case 9:buttons         = "ReadKey(z)"             case 10:buttons     = "ReadKey(z)"             case 11:buttons     = "ReadKey(z)"             case 12:buttons     = "ReadKey(z)"             case 13:buttons     = "ReadKey(z)"         }     return buttons }

fysiks 01-02-2011 03:28

Re: Why is this not working
 
What in the world is it supposed to do?

sibox 01-02-2011 03:44

Re: Why is this not working
 
read name of the keys from file but "ReadKey(z)" is not working.. how can i fix it

sibox 01-02-2011 05:53

Re: Why is this not working
 
I think there is problem in cases but i'm not sure thats why i post it here to the pros :p

abdul-rehman 01-02-2011 07:30

Re: Why is this not working
 
Post da whole code, and stop double posting !

ehha 01-02-2011 07:39

Re: Why is this not working
 
That's a string => "ReadKey(z)"
That's a function call with a parameter z => ReadKey(z)
Anyway, doing the same thing in every switch case seems redundant.

sibox 01-02-2011 07:47

Re: Why is this not working
 
Code:
#define KEYS 13 new buttons[32]; new filename[256]; new const command[] = "cheatkey"; new g_Buttons[32]; public plugin_init() {     register_plugin(PLUGIN, VERSION, AUTHOR)     register_clcmd("cheatkey", "warning")     get_configsdir(filename,255)     format(filename,255,"%s/cheatkeys.cfg",filename)     } public ReadKey(szLine[]) {     new szBuffer[32];     new b = 0;     if(szBuffer[0] == '/' && szBuffer[1] == '/') { str_to_num(szLine) + 1; }     read_file(g_Buttons, str_to_num(szLine), szBuffer, 31, b) } stock keys_func(i) {     new fsize = file_size(filename, 1)     new number[32];     for(new z = 0; z < fsize;z++) {         num_to_str(z, number, 31)         switch(i) {                 case 2: ReadKey(number)                 case 3: ReadKey(number)                 case 4: ReadKey(number)                 case 5: ReadKey(number)                 case 6: ReadKey(number)                 case 7: ReadKey(number)                 case 8: ReadKey(number)                 case 9: ReadKey(number)                 case 10: ReadKey(number)                 case 11: ReadKey(number)                 case 12: ReadKey(number)                 case 13: ReadKey(number)             }     }     return buttons } public warning(id) {     for(new i=1;i<=KEYS;i++) {         new name[32]         get_user_name(id,name,31)         client_print(0,print_chat,"%s was forced to quit because he pushed the wrong button! Be careful!",name)         client_print(0, print_chat, "He push: %s", keys_func(i))     } }


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

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