View Single Post
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 05-25-2017 , 16:46   Re: Using CreateDataTimer
Reply With Quote #28

Quote:
Originally Posted by Halt View Post
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.0Print_Datadata);
    
data.WriteFloat(5.0);
    
data.WriteCell(1);
    
data.WriteString("HELLO WORLD!");

    
CreateDataTimer(2.0Print_Datadata);
    
data.WriteFloat(55.0);
    
data.WriteCell(17);
    
data.WriteString("HELLO XD WORLD!");
    
data.Reset();

    
CreateDataTimer(3.0Print_Datadata);
    
data.WriteFloat(34567.0);
    
data.WriteCell(1678);
    
data.WriteString("ANOTHER RANDOM STRING!");
    
data.Reset();

    
CreateDataTimer(8.0Print_Datadata);
    
data.WriteFloat(678.0);
    
data.WriteCell(65532);
    
data.WriteString("FINALLY!");
    
data.Reset();
}

public 
Action Print_Data(Handle timerHandle data)
{
    
DataPack datapack view_as<DataPack>(data);

    
float fl datapack.ReadFloat();
    
int i datapack.ReadCell();
    
char str[32];
    
data.ReadString(strsizeof(str));

    
PrintToServer("Data: %f %d %s"flistr);

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

Last edited by WildCard65; 05-25-2017 at 16:48.
WildCard65 is offline