PDA

View Full Version : some code question


lingzhidiyu
10-13-2014, 10:59
//which is better?

(client > 0) or (client != 0)



//And should i add this every function?

if (IsClientInGame(client) && client > 0)

//or return?
if (!IsClientInGame(client))
return;
if (client < 1)
return;
if (client == 0)
return;

Drixevel
10-13-2014, 11:50
if (0 < client <= MaxClients && !IsClientInGame(client))
return;

lingzhidiyu
10-13-2014, 12:03
Thanks,but in second part i meaning this>>which is better?

if (!IsClientInGame(client))
return;

if (IsClientInGame(client))
//do something

LambdaLambda
10-13-2014, 12:23
If you block client's access to further part of your function, you do not have to check the same thing again, and you don't have to use ELSE either. Basing on your example, just check if client is not in game, and if so - call return. Then continue to workin on rest of the code.