AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Oh noes! i forgot my set_task syntax! (https://forums.alliedmods.net/showthread.php?t=11021)

TotalNoobScripter 03-07-2005 17:27

Oh noes! i forgot my set_task syntax!
 
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.

xeroblood 03-07-2005 18:54

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 }

TotalNoobScripter 03-07-2005 19:35

ahh, so no matter what, you can ultimatley only use 1 paramater args, unless you use an array?

xeroblood 03-07-2005 19:43

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 )

XxAvalanchexX 03-07-2005 22:27

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!"); }

xeroblood 03-08-2005 08:56

Hrmmm.. very weird behavior... i dont recall AMX being like that, or was this an addition to AMXX, do you know?

TotalNoobScripter 03-08-2005 16:47

from what i recall, id as a task paramater has always worked.

PM 03-09-2005 12:38

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 .

xeroblood 03-09-2005 13:34

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...

XxAvalanchexX 03-09-2005 15:17

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.


All times are GMT -4. The time now is 14:15.

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