You do not pass parameters correctly.
To pass only one parameter you can use task ID. I.e. your function will receive task ID as first parameter:
Код:
new task_ID = 123;
set_task(time, "function", task_ID);
public function(task_ID)
{
// task_ID == 123
Task ID is unique inside a plugin, so if you call set_task with the same task ID, that scheduled task will be replaced (with new function, parameters, whatever). So you need to specify different task ID. The easiest way to do that is to use some constant value and add the single parameter value to it:
Код:
const MY_TASK_BASE = 1000;
for (new id = 1; id < 33; id++)
set_task(time, "function", MY_TASK_BASE + id);
public function(task_ID)
{
// task_ID will be from 1001 to 1032
new id = task_ID - MY_TASK_BASE;
In that code function will be called 32 times with different task_ID ranging from 1001 up to 1032, so single parameter (id) can be calculated from it by subtracting task ID base constant.
To pass more than 1 parameter you will have to use parameter array:
Код:
native set_task(Float:time,const function[],id = 0,const parameter[]="",len = 0,const flags[]="", repeat = 0);
Код:
new data[2];
data[0] = id;
data[1] = ent;
set_task(1.0, "function", task_ID, data, sizeof(data));
public function(task_ID, data, dataSize)
{
new id = data[0];
new ent = data[1];