Raised This Month: $ Target: $400
 0% 

Set_task with params?


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Arion
Senior Member
Join Date: Mar 2007
Old 10-02-2007 , 20:05   Set_task with params?
Reply With Quote #1

First of all, I found many threads about the same question, but no one satisfied me entirely..

I only want to change this function to a task

sendMessage (totalPlayers, cont, color, teamName, player)


Something like this:

set_task (0.1, "sendMessage", id, "totalPlayers, cont, color, teamName, player")


This way it compiles with no errors, but doesn't work either..
__________________
Arion is offline
Send a message via MSN to Arion
M249-M4A1
I <3 Mac
Join Date: May 2005
Location: Not interested
Old 10-02-2007 , 20:37   Re: Set_task with params?
Reply With Quote #2

You can only pass one parameter
__________________
M249-M4A1 is offline
Drak
Veteran Member
Join Date: Jul 2005
Old 10-02-2007 , 21:28   Re: Set_task with params?
Reply With Quote #3

You can do stuff like this:
Code:
public task_function() {     new args[2]     args[0] = 100     args[1] = 200     set_task(1.0,"function",0,args,2); } public function(value[]) {     server_print("Value: %d Value2: %d",value[0],value[1]); }
__________________
Oh yeah
Drak is offline
Send a message via MSN to Drak
Arion
Senior Member
Join Date: Mar 2007
Old 10-02-2007 , 22:05   Re: Set_task with params?
Reply With Quote #4

Thanks M249-M4A1, I knew I could pass only one parameter. But how can I pass all of them?


Drak, I tried this too... but how do I do if values are strings?

args[0] = teamName
copy (args[0], teamName)
?
__________________
Arion is offline
Send a message via MSN to Arion
Hawk552
AMX Mod X Moderator
Join Date: Aug 2005
Old 10-02-2007 , 22:09   Re: Set_task with params?
Reply With Quote #5

It really depends on what each variable is. Are they arrays?

Please specify.
__________________
Hawk552 is offline
Send a message via AIM to Hawk552
Arion
Senior Member
Join Date: Mar 2007
Old 10-02-2007 , 22:17   Re: Set_task with params?
Reply With Quote #6

totalPlayers : int
cont: int
color: array (string?)
teamName: array
player: int

__________________
Arion is offline
Send a message via MSN to Arion
kp_uparrow
Penalized Member
Join Date: Jun 2006
Location: 192.168.0.1
Old 10-02-2007 , 22:48   Re: Set_task with params?
Reply With Quote #7

nope, limitation of the set task, but you can format it into one string and break it down after its called
__________________
I USED A SECOND ACCOUNT TO DO MORE KARMA UPS AND DOWNS UNTIL GREENTRYST CAUGHT ME
kp_uparrow is offline
Arion
Senior Member
Join Date: Mar 2007
Old 10-02-2007 , 22:50   Re: Set_task with params?
Reply With Quote #8

And... How do I do that?
__________________
Arion is offline
Send a message via MSN to Arion
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 10-02-2007 , 23:17   Re: Set_task with params?
Reply With Quote #9

Hum try this. I don't know your color format so I've assumed something like "255255255".

Code:
my_function( id ) {       // color = "255255255"     // team = "TERRORIST" or "CT" or "UNASSIGNED", or "SPECTATOR"         static         param[23], // 9 (color) + 10 (team) + 3 (totalplayers/cont/player) + 1           len;         param[0]  = totalPlayers;     param[1]  = cont;     param[2]  = player;         len = formatex( param[3], sizeof param - 1, "%s-%s", color, teamName );         set_task ( 0.1, "sendMessage", id, param, len + 4 ); } public sendMessage( param[] ) {     static         sColor[10],         sTeam[10];             strtok( param[3], sColor, sizeof sColor - 1, sTeam, sizeof sTeam - 1, '-' );         log_amx( "totalPlayers: %d | cont: %d | player: %d | color: %s | team: %s", param[0], param[1], param[2], sColor, sTeam ); }
__________________

Last edited by Arkshine; 10-02-2007 at 23:26.
Arkshine is offline
Old 10-02-2007, 23:18
M249-M4A1
This message has been deleted by M249-M4A1. Reason: arkshine beat me to it
Arion
Senior Member
Join Date: Mar 2007
Old 10-02-2007 , 23:26   Re: Set_task with params?
Reply With Quote #10

I'll try that... Thanks!
__________________
Arion is offline
Send a message via MSN to Arion
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 16:11.


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