AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting (https://forums.alliedmods.net/forumdisplay.php?f=107)
-   -   Solved Question: What is a ConVar.FloatValue's expected value? (https://forums.alliedmods.net/showthread.php?t=303838)

Psyk0tik 12-23-2017 14:16

Question: What is a ConVar.FloatValue's expected value?
 
I'm using this in my code:

PHP Code:

hPunishTimer CreateTimer(cvPunishDetectionDelay.FloatValueaAutoTimerUpdatePlayer_TIMER_REPEAT); 

I noticed that something wasn't working and tracked it down to the cvPunishDetectionDelay.FloatValue. Currently, my cfg file has that value set to 0.1, however, when I set it to something like 1.0 or 5.5, the timer works.

So why is it that 0.1 doesn't work but 1.0/5.5 does? Is it because 0.1 is basically close to 0 or something else?

8guawong 12-23-2017 16:17

Re: Question: What is a ConVar.FloatValue's expected value?
 
What do you mean by it doesn't v work

Psyk0tik 12-23-2017 17:43

Re: Question: What is a ConVar.FloatValue's expected value?
 
What I mean is that, when I set the convar cvPunishDetectionDelay to 0.1, it doesn't seem to be accepted, thus rendering the timer useless. When I set it to 1.0 or anything higher than 1, that's when the timer seems to work. My main question is just asking what exactly is the .FloatValue's expected value. I read a post by asherkin that a .BoolValue works as follows: 0.9 ~= 0 = false and 1.1 ~= 1 = true, but I don't know if that also applies to .FloatValues.

WildCard65 12-23-2017 18:31

Re: Question: What is a ConVar.FloatValue's expected value?
 
SM Timers are checked if they should run EVERY gameframe, how the check is done is comparing the current game time (as dictated by "GetGameTime() (or GetEngineTime())") with the time Timer was created (and last executed for repeating Timers) plus the timer delay.

8guawong 12-23-2017 21:17

Re: Question: What is a ConVar.FloatValue's expected value?
 
What are you doing in the callback?

Powerlord 12-23-2017 21:43

Re: Question: What is a ConVar.FloatValue's expected value?
 
Quote:

Originally Posted by WildCard65 (Post 2567850)
SM Timers are checked if they should run EVERY gameframe, how the check is done is comparing the current game time (as dictated by "GetGameTime() (or GetEngineTime())") with the time Timer was created (and last executed for repeating Timers) plus the timer delay.

SourceMod doesn't run timers every gameframe. It makes sure 0.1 seconds have passed since the last time it ran them. Hence why the minimum timer accuracy is documented as being 0.1 seconds.

Psyk0tik 12-23-2017 22:43

Re: Question: What is a ConVar.FloatValue's expected value?
 
Quote:

Originally Posted by 8guawong (Post 2567860)
What are you doing in the callback?

Basically I'm just checking for how long and how far a player has been separated from their teammates. Once the player reaches the distance limit that is set by a cvar, a special infected is spawned behind them to "punish" them.

Spoiler


Though, the callback isn't the problem. I'm just wondering why setting the cvar value to 0.1 and using ConVar.FloatValue to retrieve it returns 0. I thought it'd be the same as manually setting the timer to 0.1.

I suppose when doing ConVar.BoolValue it works as follows: 0.9 (any number with 0 as the whole number rounds off to 0) ~= 0 = false, 1.1 (anything with 1 as the whole number rounds off to 1) ~= 1 = true (if true, that value will be used as the bool value).

And for ConVar.FloatValue, it seems to work as follows: 0.9 (any number with 0 as the whole number rounds off to 0) ~= 0 = false, 5.5 (1 or any value greater than 1) ~= 1 = true (if true, that value will be used as the float value).

8guawong 12-23-2017 23:04

Re: Question: What is a ConVar.FloatValue's expected value?
 
So you are saying
CreateTimer(cvPunishDetectionDelay.FloatValue ,... <- does not work
But
CreateTimer(0.1, aAutoTimer <- works?

Psyk0tik 12-23-2017 23:31

Re: Question: What is a ConVar.FloatValue's expected value?
 
Quote:

Originally Posted by 8guawong (Post 2567866)
So you are saying
CreateTimer(cvPunishDetectionDelay.FloatValue ,... <- does not work
But
CreateTimer(0.1, aAutoTimer <- works?

Exactly.

When I set cvPunishDetectionDelay.FloatValue to 1 or higher though, it works.

8guawong 12-23-2017 23:45

Re: Question: What is a ConVar.FloatValue's expected value?
 
how are you telling if the timer is working or not?
what happen if you add
public Action tAutoTimerUpdatePlayer(Handle timer, any data)
{
PrintToChatAll("timer is working");

do you get spammed?
if you do get spammed then i think maybe somewhere in your callback is wrong


All times are GMT -4. The time now is 23:45.

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