Raised This Month: $32 Target: $400
 8% 

Using CreateDataTimer


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 05-23-2017 , 22:10   Using CreateDataTimer
Reply With Quote #1

When I attempt to compile I get a tag mismatch error at CreateDataTimer, but the arguments match up with the actual timer.

Spoiler
Halt is offline
Squallkins
AlliedModders Donor
Join Date: Mar 2005
Old 05-23-2017 , 22:14   Re: Using CreateDataTimer
Reply With Quote #2

RandomTime needs to be float?
Squallkins is offline
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 05-23-2017 , 22:16   Re: Using CreateDataTimer
Reply With Quote #3

Quote:
Originally Posted by Squallkins View Post
RandomTime needs to be float?
Its an integer no? Hense the int? Holding whole numbers correct?
Halt is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 05-23-2017 , 22:22   Re: Using CreateDataTimer
Reply With Quote #4

something like this
PHP Code:
float RandomTime GetRandomFloat(3.010.0);
float PlayerAimVector[3];
GetAimPos(ClientPlayerAimVector);
Handle datapack;
CreateDataTimer(RandomTimeArtilleryExplosionTimerdatapack);
WritePackFloat(datapackPlayerAimVector[0]);
WritePackFloat(datapackPlayerAimVector[1]);
WritePackFloat(datapackPlayerAimVector[2]);

public 
ArtilleryExplosionTimer(Handle:timerHandle:datapack)
{
        
ResetPack(datapack);
        
float ArtilleryExplosionVector[3];
        
ArtilleryExplosionVector[0] = ReadPackFloat(datapack);
        
ArtilleryExplosionVector[1] = ReadPackFloat(datapack);
        
ArtilleryExplosionVector[2] = ReadPackFloat(datapack);
    
    new 
Explosion CreateEntityByName("tf_generic_bomb");
    
    
DispatchKeyValue(Explosion"origin"ArtilleryExplosionVector);
    
DispatchKeyValue(Explosion"damage""180.0");
    
DispatchKeyValue(Explosion"radius""150.0");
    
DispatchKeyValue(Explosion"health""1");
    
DispatchSpawn(Explosion);
    
AcceptEntityInput(Explosion"explode");


Last edited by 8guawong; 05-23-2017 at 22:24.
8guawong is offline
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 05-23-2017 , 22:26   Re: Using CreateDataTimer
Reply With Quote #5

You have to write to ALL vectors in the float? And why does RandomTime need to be a float if its holding a single whole number?


Edit: The CreateDataTimer is giving me a calling a prototypes mismatch when I compile.

Last edited by Halt; 05-23-2017 at 22:36.
Halt is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 05-23-2017 , 22:36   Re: Using CreateDataTimer
Reply With Quote #6

Quote:
Originally Posted by Halt View Post
You have to write to ALL vectors in the float? And why does RandomTime need to be a float if its holding a single whole number?
Handle CreateTimer(float interval, Timer func, any data, int flags)

CreateDataTimer is a wrapper around CreateTimer to create and pass a datapack handle to timer callback.
__________________
WildCard65 is offline
headline
SourceMod Moderator
Join Date: Mar 2015
Old 05-23-2017 , 23:23   Re: Using CreateDataTimer
Reply With Quote #7

Quote:
Originally Posted by Halt View Post
And why does RandomTime need to be a float if its holding a single whole number?
Because that's the type of the parameter input. You don't get to choose.

If you REALLY wanted a whole number of seconds you can get your random number
PHP Code:
int time GetRandomInt(310
and then when using a timer do

PHP Code:
CreateTimer(float(time), Callback); 
headline is offline
Halt
Senior Member
Join Date: Jan 2015
Location: Black Mesa
Old 05-24-2017 , 01:37   Re: Using CreateDataTimer
Reply With Quote #8

Its still reading back an error "Function prototypes do not match" from this line

Code:
CreateDataTimer(RandomTime, ArtilleryExplosionTimer, datapack);

Here is the timer

Code:
public ArtilleryExplosionTimer(Handle:timer, Handle:datapack)
Halt is offline
xerox8521
Senior Member
Join Date: Sep 2011
Old 05-24-2017 , 03:05   Re: Using CreateDataTimer
Reply With Quote #9

missing Action between public and ArtilleryExplosionTimer

so
public Action ArtilleryExplosionTimer or old syntax public Action:ArtilleryExplosionTimer
xerox8521 is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 05-24-2017 , 07:11   Re: Using CreateDataTimer
Reply With Quote #10

Timer TypeSet
__________________

Last edited by WildCard65; 05-24-2017 at 07:11.
WildCard65 is offline
Reply



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 16:21.


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