Invalid convar handle after converting to newdecls

W

Wliu

Guest
#1
Old code:
Code:

if(GetConVarBool(FindConVar("tf2items_rnd_enabled")))
{

Randomizer_CheckAmmo(client, wepEntity);
}

New code:
Code:

if(FindConVar("tf2items_rnd_enabled").BoolValue)
{

Randomizer_CheckAmmo(client, wepEntity);
}

Randomizer is not guaranteed to be installed on the server. The old code worked just fine (returning false if the cvar didn't exist), but after converting to newdecls, it's giving me "Native "ConVar.BoolValue.get" reported: Invalid convar handle 0 (error 4)" errors.

I did a cursory look through the code and it's apparently supposed to error in the old syntax too - not sure why it didn't, possibly a bug? It would be really nice for BoolValue to just return false (or null) if the cvar doesn't exist instead of throwing.
 
   
   
   
Top