Raised This Month: $ Target: $400
 0% 

set_task with several (string) parameters?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
[Godmin] Gonzo
SourceMod Donor
Join Date: Jul 2004
Location: Godmins World
Old 09-10-2004 , 21:56   set_task with several (string) parameters?
Reply With Quote #1

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 is offline
Send a message via ICQ to [Godmin] Gonzo
[Godmin] Gonzo
SourceMod Donor
Join Date: Jul 2004
Location: Godmins World
Old 09-10-2004 , 22:56  
Reply With Quote #2

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
__________________
[Godmin] Gonzo is offline
Send a message via ICQ to [Godmin] Gonzo
BAILOPAN
Join Date: Jan 2004
Old 09-11-2004 , 01:10  
Reply With Quote #3

You cannot send multiple parameters like this
If you would like to do this I suggest you pass an index into something
__________________
egg
BAILOPAN is offline
malex
Junior Member
Join Date: Aug 2004
Old 09-11-2004 , 01:14  
Reply With Quote #4

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\
malex is offline
Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


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


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