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