Raised This Month: $12 Target: $400
 3% 

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


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 12-23-2017 , 14:16   Question: What is a ConVar.FloatValue's expected value?
Reply With Quote #1

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

Last edited by Psyk0tik; 12-24-2017 at 07:03. Reason: Marked as [Solved]
Psyk0tik is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 12-23-2017 , 16:17   Re: Question: What is a ConVar.FloatValue's expected value?
Reply With Quote #2

What do you mean by it doesn't v work
__________________
8guawong is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 12-23-2017 , 17:43   Re: Question: What is a ConVar.FloatValue's expected value?
Reply With Quote #3

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.
__________________
Psyk0tik is offline
WildCard65
Veteran Member
Join Date: Aug 2013
Location: Canada
Old 12-23-2017 , 18:31   Re: Question: What is a ConVar.FloatValue's expected value?
Reply With Quote #4

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.
__________________
WildCard65 is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 12-23-2017 , 21:17   Re: Question: What is a ConVar.FloatValue's expected value?
Reply With Quote #5

What are you doing in the callback?
__________________
8guawong is offline
Powerlord
AlliedModders Donor
Join Date: Jun 2008
Location: Seduce Me!
Old 12-23-2017 , 21:43   Re: Question: What is a ConVar.FloatValue's expected value?
Reply With Quote #6

Quote:
Originally Posted by WildCard65 View Post
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.
__________________
Not currently working on SourceMod plugin development.
Powerlord is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 12-23-2017 , 22:43   Re: Question: What is a ConVar.FloatValue's expected value?
Reply With Quote #7

Quote:
Originally Posted by 8guawong View Post
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).
__________________
Psyk0tik is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 12-23-2017 , 23:04   Re: Question: What is a ConVar.FloatValue's expected value?
Reply With Quote #8

So you are saying
CreateTimer(cvPunishDetectionDelay.FloatValue ,... <- does not work
But
CreateTimer(0.1, aAutoTimer <- works?
__________________

Last edited by 8guawong; 12-23-2017 at 23:04.
8guawong is offline
Psyk0tik
Veteran Member
Join Date: May 2012
Location: Homeless
Old 12-23-2017 , 23:31   Re: Question: What is a ConVar.FloatValue's expected value?
Reply With Quote #9

Quote:
Originally Posted by 8guawong View Post
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.
__________________

Last edited by Psyk0tik; 12-23-2017 at 23:31.
Psyk0tik is offline
8guawong
AlliedModders Donor
Join Date: Dec 2013
Location: BlackMarke7
Old 12-23-2017 , 23:45   Re: Question: What is a ConVar.FloatValue's expected value?
Reply With Quote #10

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
__________________
8guawong is offline
Reply


Thread Tools
Display Modes

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 07:40.


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