Raised This Month: $ Target: $400
 0% 

Oh noes! i forgot my set_task syntax!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
TotalNoobScripter
Senior Member
Join Date: Aug 2004
Old 03-07-2005 , 17:27   Oh noes! i forgot my set_task syntax!
Reply With Quote #1

How can u make it so a set_task will parse more than 1 paramater?

set_task(3, "omg", id)

Also using id, houw would i make it also send a number to the function?

as in omg(id,amount) where amount is a number?

I dont think set_task(3, "omg", id , 1) would work.
TotalNoobScripter is offline
Send a message via AIM to TotalNoobScripter
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 03-07-2005 , 18:54  
Reply With Quote #2

Code:
public SomeFunction( id ) {     new szArgs[3]     szArgs[0] = id     szArgs[1] = 57362     set_task( 3.0, "omg", 0, szArgs, 2 ) } public omg( szArgs[] ) {     new id = szArgs[0]     new SomeNum = szArgs[1]     //  Do stuff...     return PLUGIN_HANDLED }
xeroblood is offline
Send a message via MSN to xeroblood
TotalNoobScripter
Senior Member
Join Date: Aug 2004
Old 03-07-2005 , 19:35  
Reply With Quote #3

ahh, so no matter what, you can ultimatley only use 1 paramater args, unless you use an array?
TotalNoobScripter is offline
Send a message via AIM to TotalNoobScripter
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 03-07-2005 , 19:43  
Reply With Quote #4

You cant pass any arguments to a function that is called by set_task() unless you pass them in the form of an array... this method allows you to pass as many arguments as you want, just put them in an array..

The 0 in my example of set_task() is the TASK ID, not a passed parameter... it can be used to check if the task exists:

if( task_exists( task_id ) )

or to remove the task before execution:

remove_task( task_id )
xeroblood is offline
Send a message via MSN to xeroblood
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 03-07-2005 , 22:27  
Reply With Quote #5

Yes, you can pass parameters to a function without an array, xeroblood, but only one. It seems to pass the task ID unless you specify an array. Example:

Code:
set_task(3.0,"function",id); public function(id) {    client_print(id,print_chat,"* I know who you are!"); }
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 03-08-2005 , 08:56  
Reply With Quote #6

Hrmmm.. very weird behavior... i dont recall AMX being like that, or was this an addition to AMXX, do you know?
xeroblood is offline
Send a message via MSN to xeroblood
TotalNoobScripter
Senior Member
Join Date: Aug 2004
Old 03-08-2005 , 16:47  
Reply With Quote #7

from what i recall, id as a task paramater has always worked.
TotalNoobScripter is offline
Send a message via AIM to TotalNoobScripter
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 03-09-2005 , 12:38  
Reply With Quote #8

The id is, and has always been (also in AMX), the last parameter passed to the task handler function.

I prefer xs tasks now though ;)
They are only stock functions; wrappers around set_task, and they have the IMO better callfunc-like system. Check xs.inc .
__________________
hello, i am pm
PM is offline
xeroblood
BANNED
Join Date: Mar 2004
Location: Toronto, Canada
Old 03-09-2005 , 13:34  
Reply With Quote #9

Yes, I checked XS out long ago and noticed that it manages tasks alot more efficiently.. you solved the problem of multiple tasks with the same TaskID if I am correct, which is exactly what the method mentioned in this thread will lead to..

If 2 (or more) plugins use this method (of passing a player id as the task id) and then one of the plugins removes the task then it will remove the task for both plugins because they share the same task id, am I correct??

This is solved by both XS or by passing unique task ids and any parameters in an array...

I have always tried to keep unique task ids, and pass any/all parameters in the array form just to prevent conflicts amongst multiple plugins, or has this all been in vain?

I really should check out XS again...
xeroblood is offline
Send a message via MSN to xeroblood
XxAvalanchexX
Veteran Member
Join Date: Oct 2004
Location: abort73.com
Old 03-09-2005 , 15:17  
Reply With Quote #10

remove_task has a parameter as to whether or not to remove tasks of the same ID outside of this plugin. So you can remove tasks from all plugins or only the one you are in. But if you use id as the ID you can't really stop a specific task for the user, as all the tasks for that user have the same ID.
__________________
No longer around. Thanks your support, everyone! As always:
THIS ONES FOR YOU
3000 PTS
XxAvalanchexX is offline
Reply


Thread Tools
Display Modes

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 14:15.


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