Raised This Month: $51 Target: $400
 12% 

[REQ/IDEA] set_task redesign?


  
 
 
Thread Tools Display Modes
Author Message
Zenith77
Veteran Member
Join Date: Aug 2005
Old 10-11-2006 , 21:52   [REQ/IDEA] set_task redesign?
#1

Well, the current implementation of set_task only allows for cells to be passed as parameters, which can create problems. What if you manually add paramters to the set task, basically like a list or something.

For example:
Code:
set_task(/*bla bla bla*/); set_task_addparam_cell(someVarINeedToPass, anotherOne, gaben); set_task_addparam_string("Hello world", "what");

As you can see, multiple params of different data types would add greater power to tasks. Also the natives set_task_addparam_* accept more than one argument so they don't have to repeat the native 15 million times. I didn't think to hard about this, just an idea that popped into my head. Let me know if I need to explain it more ^^.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
BAILOPAN
Join Date: Jan 2004
Old 10-11-2006 , 22:34   Re: [REQ/IDEA] set_task redesign?
#2

This isn't any different than what's currently there really. You just have to work harder to pack the data in.
__________________
egg
BAILOPAN is offline
Xanimos
Veteran Member
Join Date: Apr 2005
Location: Florida
Old 10-12-2006 , 00:04   Re: [REQ/IDEA] set_task redesign?
#3

Quote:
Originally Posted by BAILOPAN View Post
This isn't any different than what's currently there really. You just have to work harder to pack the data in.
On that note,...in a few plugins I've packed about 5 variables, some ints some strings into one param array.
Xanimos is offline
Send a message via AIM to Xanimos Send a message via MSN to Xanimos
PM
hello, i am pm
Join Date: Jan 2004
Location: Canalization
Old 10-12-2006 , 08:41   Re: [REQ/IDEA] set_task redesign?
#4

You could try out the XS library's task wrappers - which do basically what you proposed.
Code:
#include <xs> // in some function: // xs_task_begin; the parameters are the same as in set_task. // If you set id to -1, the function automatically finds an unused id. xs_task_begin(interval, "func", taskid, flags, repeat); xs_task_pushint(100); // Add an int parameter xs_task_pushstr("hello"); // Add a string parameter xs_task_pushfl(5.67); // Add a float parameter xs_task_end(); // Don't forget to call this. It also returns the task id // which can be useful if you let XS automatically choose the id // Then on the topmost level (not in any function) XS_MAKE_TASKFUNC(func) {   // In functions defined using XS_MAKE_TASKFUNC, you can use   // these functions:   new id = xs_task_readid();   new paramscnt = xs_task_paramcount();   for (new i = 0; i < paramscnt; ++i)   {     new type = xs_task_paramtype(i);     if (type == xs_int)     {        new intparam = xs_task_paramint(i);        log_amxx("Param #%d: Integer; value=%d", i, intparam);     }     else if (type ==xs_float)     {       new Float:flparam = xs_task_paramfl(i);       log_amxx("Param #%d: Float; value=%f", i, flparam);     }     else if (type == xs_string)     {       new str[256];       xs_task_paramstr(i, str, 255);       log_amxx("Param #%d: String; value=%s", i, str);     }   } }
Note that it worked a long time ago, changes in the compiler could have broken it (I hope they didn't though).
Also note that these are only wrappers aroung set_task - if you are interested in the implementation and its performance implications, look into xs.inc.
Also, the number of task arguments is limited to 8 defaultly. You can change this by defining XS_TASK_MAXPARAMS to another number before including xs.inc. Same goes for XS_TASK_MAXPARAMSIZE, which specifies the maximal size of a string parameter (default: 512).
Also note that strings are stored in packed state so you cannot pass normal cell arrays where an element is not within the range of 0 <= x <= 255 . However, adding this functionality should not be too hard.
__________________
hello, i am pm
PM is offline
Zenith77
Veteran Member
Join Date: Aug 2005
Old 10-12-2006 , 09:37   Re: [REQ/IDEA] set_task redesign?
#5

Ok, like a said just an idea.
__________________
Quote:
Originally Posted by phorelyph View Post
your retatred
Zenith77 is offline
 



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 05:32.


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