Quote:
Originally Posted by eXemplar
If you have a few instances of where you check for the same stuff you could try something along the lines of,
Code:
bool:IsValidClient(client)
{
return IsClientInGame(client) && !IsFakeClient(client) && !IsClientObserver(client);
}
|
Ooh, I'll definitely use that. I'm surprised I didn't think of that o_o
I've got like 20 different iterations of IsValidClient saved in a text file. Here's a good example that checks for things like if a player is coaching, or if they are the Replay thing, or if they are a Source TV client.
PHP Code:
stock bool:IsValidClient(i, bool:replay = true)
{
if (i <= 0 || i > MaxClients || !IsClientInGame(i) || GetEntProp(i, Prop_Send, "m_bIsCoaching"))
{
return false;
}
if (replay && (IsClientSourceTV(i) || IsClientReplay(i)))
{
return false;
}
return true;
}