AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   set_task with several (string) parameters? (https://forums.alliedmods.net/showthread.php?t=5720)

[Godmin] Gonzo 09-10-2004 21:56

set_task with several (string) parameters?
 
I know what's wrong, it's my try to get thoose §/§$&%§!" variables into set_task, but how could I make it better?

Code:
public my_slay(id, steamid[35], text[256]) {   new userid = get_user_userid(id)   client_print(id, print_chat, "Rufe slay auf")   if (is_user_alive(userid))   {     client_print(id, print_chat, "SLAY!")     server_print("amx_slay %s", steamid)     server_cmd("amx_slay #%d", userid)   }   else   {     new param[4]     param[0]=id;     format(param[1], 34, "%s", steamid);     format(param[2], 255, "%s", text);     server_print("Dead Client")     set_task(1.0, "my_slay", 4711+id, param)   }   return }

My code instantly crashes when called on a dead client ("else" part)

[Godmin] Gonzo 09-10-2004 22:56

Update: Changed it to the following:

Code:
public my_slay(param[4][256]) {   new id, steamid[35], text[256]   id=str_to_num(param[0])   format(steamid, 34, "%s", param[1])   format(text, 255, "%s", param[2])   new userid = get_user_userid(id)   client_print(id, print_chat, "Rufe slay auf")   if (is_user_alive(id))   {     client_print(id, print_chat, "SLAY!")     server_print("amx_slay %s", steamid)     server_cmd("amx_slay #%d", userid)   }   else   {     new myparam[4][256]     new temp[10]     num_to_str(id, temp, 9)     format(myparam[0], 10, temp)     format(myparam[1], 34, "%s", steamid)     format(myparam[2], 255, "%s", text)     server_print("Dead Client")     set_task(1.0, "my_slay", 4711+id, myparam)   }   return }

Now I get the compile error: muppets-filter.sma(587) : error 048: array dimensions do not match

Line 587 is the set_task line

BAILOPAN 09-11-2004 01:10

You cannot send multiple parameters like this
If you would like to do this I suggest you pass an index into something :)

malex 09-11-2004 01:14

Since that first parameter is a steamid, and will never have a space in it, you could just join the two strings with a space, pass that as a single string, and then use strbreak() to separate it back into two strings. Just a thought.

\malex\


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

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