View Single Post
101
Member
Join Date: Nov 2023
Old 12-15-2023 , 01:52   Re: Float Cvar Tag mismatch Warning
Reply With Quote #6

That because u have stored a pointer in a float variable , Look at this : register_cvar
u can see at the end of the page that register_cvar doesn't return any float or int value , it returns an <address/pointer> that shouldn't be stored or handled by a float variable .

PHP Code:
new RespawnDelay ;  //this will be a POINTER 
RespawnDelay register_cvar("respawn_delay""1.5");  //our POINTER now is pointing to this cvar 
to get the value of the previous cvar , u can do this :
PHP Code:
get_cvar_float("respawn_delay"); // this will return a float value (and this call is usually used If u know the Cvar Name) 
Or This :
PHP Code:
get_pcvar_float(RespawnDelay); // pcvar means : dereference *(this pointer) , and this will return a float value that the given pointer was pointing at (and this call is usually used if u have stored the cvar in a KNOWN pointer) 

Summary :

- Each Existing CVAR has a value and has a unique pointer .
- Value of Cvar might be (integer , float , or string)
PHP Code:
In your case : the value of ur cvar was Float because u assigned "1.5" which is a float 
- get_cvar means GET the Value .
PHP Code:
//float :
get_cvar_float("respawn_delay");
//int :
get_cvar_num("mp_timeleft");
//string :
new Text[32];
get_cvar_string("hostname"Textcharsmax(Text)); 
- get_pcvar means dereference a Given Pointer to get the value that Pointer was pointing at .
PHP Code:
//float :
get_pcvar_float(RespawnDelay);   // Note That RespawnDelay should be a pointer 
//int :
get_pcvar_num(get_cvar_pointer("sv_maxplayers")); // Twisted way to get the value (dereferencing a given pointer will return the value itself)
//string :
new Text[32];
get_pcvar_string(get_cvar_pointer("hostname"), Textcharsmax(Text)); // Twisted 
-Dereferencing a Pointer should return the Value itself.
-Value of a Value should also return the Value itself .
-Value of a Pointer OR Pointer of a Value will Cuze problems (so try to avoid this) :
PHP Code:
get_pcvar_float("respawn_delay");  // this is Wrong and it means ( dereference this pointer (?!string?!) )
get_cvar_float(RespawnDelay);  // this is also Wrong and it means (get the float value from cvars array that match this string (?!Pointer?!) ) 
I think it wouldn't be a disaster if something like this was found in here : https://www.amxmodx.org

Last edited by 101; 12-16-2023 at 04:19. Reason: update information
101 is offline