AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   get time between Knife slashes (https://forums.alliedmods.net/showthread.php?t=197206)

avril-lavigne 09-30-2012 01:59

get time between Knife slashes
 
Im bad in get_time....or get_gametime


RegisterHam(Ham_Weapon_PrimaryAttack, "weapon_knife", "fw_Knife_PrimaryAttack_Post", 1)

new Float:1slash = get_gametime()
new Float:2slash = get_gametime()


new Float:result = 2slash - 1 slash

not sure. help me to get time between 2 knife attacks

fysiks 09-30-2012 02:05

Re: get time between Knife slashes
 
Use get_systime() at the end of your function and store it in a global variable. At the begining of the function, use get_systime() again and subtract the previous one to get how many seconds it has been since the last time the function has been executed.

avril-lavigne 09-30-2012 15:45

Re: get time between Knife slashes
 
ok finally did it


Sec: 1
Sec: 1
Sec: 0
Sec: 0
Sec: 1
Sec: 0
Sec: 0
Sec: 1

the problem it counts in seconds I need in 0.1 SEC
because time between slashes is almost 1/3 sec

and as u see it returns 0 .... so I cant divide at 0

hleV 09-30-2012 17:47

Re: get time between Knife slashes
 
It's a float so it gives you a 0.000001 precision. How are you printing the values?

jimaway 09-30-2012 18:39

Re: get time between Knife slashes
 
get_systime returns integer not float, use get_gametime the same way if you want float

avril-lavigne 10-01-2012 08:56

Re: get time between Knife slashes
 
Ok I did it. time is 0.71 between each slash thanks

Arkshine 10-01-2012 09:41

Re: get time between Knife slashes
 
If you wanted to know the delay between knife attach, you can just look at the source code : https://github.com/Arkshine/CSSDK/bl.../wpn_knife.cpp and checking m_flNextPrimaryAttack/m_flNextSecondaryAttack . So for slash, 0.35.


All times are GMT -4. The time now is 08:10.

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