View Single Post
101
Member
Join Date: Nov 2023
Old 12-18-2023 , 14:39   Re: Float Cvar Tag mismatch Warning
Reply With Quote #14

Quote:
Originally Posted by HamletEagle View Post
guarding against the input when getting the cvar value is the alternative.
I got it . thx a lot , So according to this topic we have to say that :

if u create a cvar and u wouldn't/couldn't set a limit (min,max) by using this function : create_cvar

Then u can use this alternative clamp floatclamp function to protect the Extracted value for any exsisting cvar . Examples :

PHP Code:
new Float:valueget_pcvar_float(RespawnDelay); // Extract the float value that RespawnDelay was pointing at (FASTER)
new Float:clampedValue floatclamp(value5.030.0);
set_task(clampedValue"ReviveIt" Victim); 
Or
PHP Code:
new Float:valueget_cvar_float("respawn_delay");  // Extract the float value that Match This String (SLOWER) 
set_taskfloatclamp(value 5.0 30.0) ,   "ReviveIt" ,   Victim); 
The value is guaranteed to be either 5, 30, or something in between . Even if RespawnDelay pointer was pointing to -1.0 .

For Advanced usage , u can create a custum function Safe_Float like this :
PHP Code:
Round_Start()
{
    
set_taskSafe_Floatget_cvar_pointer("mp_buytime") , 1.0 300.0) ,  "Hint_Buy_Time_Expired" ,  101);
}

Death_Event(Victim)
{
    
set_taskSafe_Float(RespawnDelay 3.0 5.0) ,  "ReviveIt" ,  Victim);
}

stock FloatSafe_Float(CVAR_Pointer , const FloatMin , const FloatMax )
{
    
// This function Does Both : Change The Actual Cvar Value , then return it Within The desired Range  
    
new Float:floatclampget_pcvar_float(CVAR_Pointer) , Min Max );
    
set_pcvar_floatCVAR_Pointer X);
    return 
;

Is This right Mr Eagle ?
-I hope it wasn't an overstatement -
101 is offline