Quote:
Originally Posted by Halt
But the CreateDataTimer only executes once when I use the command that calls it. I need it to execute 6 times, with 6 DIFFERENT vectors. So what you're telling me is just create 6 timers that all look identical minus the name? Wouldn't that be inefficient?
|
Run this example on your server:
PHP Code:
public void OnPluginStart()
{
DataPack data;
CreateDataTimer(5.0, Print_Data, data);
data.WriteFloat(5.0);
data.WriteCell(1);
data.WriteString("HELLO WORLD!");
CreateDataTimer(2.0, Print_Data, data);
data.WriteFloat(55.0);
data.WriteCell(17);
data.WriteString("HELLO XD WORLD!");
data.Reset();
CreateDataTimer(3.0, Print_Data, data);
data.WriteFloat(34567.0);
data.WriteCell(1678);
data.WriteString("ANOTHER RANDOM STRING!");
data.Reset();
CreateDataTimer(8.0, Print_Data, data);
data.WriteFloat(678.0);
data.WriteCell(65532);
data.WriteString("FINALLY!");
data.Reset();
}
public Action Print_Data(Handle timer, Handle data)
{
DataPack datapack = view_as<DataPack>(data);
float fl = datapack.ReadFloat();
int i = datapack.ReadCell();
char str[32];
data.ReadString(str, sizeof(str));
PrintToServer("Data: %f %d %s", fl, i, str);
return Plugin_Continue;
}
Output:
PHP Code:
// Data: 55.00000 17 HELLO XD WORLD!
// Data: 34567.00000 1678 ANOTHER RANDOM STRING!
// Data: 5.00000 1 HELLO WORLD!
// Data: 678.00000 65532 FINALLY!
__________________