Hi,
Quick question, which way is better/faster to get a server command value?
For this example I want to get the mp_maxrounds integer and divide it by 2 so I know when it is half time.
PHP Code:
public OnPluginStart()
{
g_h_max_rounds = FindConVar ("mp_maxrounds");
}
CheckScores() //checked at end of every round
{
if (GetScore() == (GetConVarInt(g_h_max_rounds))/2)// half time
{
// code
}
or
PHP Code:
CheckScores() //checked at end of every round
{
if (GetScore() == (GetConVarInt(FindConVar("mp_maxrounds"))/2)// half time
{
// code
}
Or should I store it and HookConVarChange with it divided by 2?
PHP Code:
new maxrounds = 15;
public OnPluginStart()
{
HookConVarChange(FindConVar("mp_maxrounds"), OnMaxRoundChangeMP);
}
public OnMaxRoundChangeMP(Handle:cvar, const String:oldVal[], const String:newVal[])
{
maxrounds = (GetConVarInt(FindConVar("mp_maxrounds"))/2);
if (g_live)
{
CheckScores();
}
}
CheckScores() //checked at end of every round
{
if (GetScore() == maxrounds)// half time
{
// code
}
Or is it a much of a muchness and the top way just looks cleaner?
Looking to remove a lot of convar's from one of my plugins back to the normal server commands.
__________________