AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   query_client_cvar cant read *.000 value (https://forums.alliedmods.net/showthread.php?t=223480)

avril-lavigne 08-14-2013 05:57

query_client_cvar cant read *.000 value
 
I,m trying to get all players with ( for example ) mp_decals 300.000000
so I did

PHP Code:

query_client_cvar(id"mp_decals""ag")

public 
ag(id, const cvar[], const value[]) {
                        
             new 
iValue str_to_float(value)
             
server_print("user has %.2f",iValue
             if(
iValue == 300.000000 ) {
             
            
// do
                    
             
}
            
    


but server_print debug show me ONLY float value like 300.00 and not 300.000000 , so my condition if ( ivalue == 300.000000) not working

how to get more digits after zero ?

Xellath 08-14-2013 06:59

Re: query_client_cvar cant read *.000 value
 
Code:
new Float:iValue = str_to_float(value)

Also, since you're printing using %.2f you restrict it from printing more than 2 decimals. Use %f. IIRC, str_to_float() is also known to be slightly inaccurate at times. It can sometimes return 0.999~ when the number is in fact 1.0.

ConnorMcLeod 08-14-2013 15:42

Re: query_client_cvar cant read *.000 value
 
Don't convert string, directly check the string.

avril-lavigne 08-14-2013 21:19

Re: query_client_cvar cant read *.000 value
 
ok. works fine with if(equal(value,"300.000000"))

pokemonmaster 08-15-2013 00:28

Re: query_client_cvar cant read *.000 value
 
Isn't mp_decals a server cvar ?

Kia 08-15-2013 04:55

Re: query_client_cvar cant read *.000 value
 
It's a player cvar afaik.


All times are GMT -4. The time now is 15:54.

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