View Single Post
friagram
Veteran Member
Join Date: Sep 2012
Location: Silicon Valley
Old 09-02-2013 , 22:05   Re: [ANY] Armor Pack V4
Reply With Quote #65

Quote:
Originally Posted by Chaosxk View Post
Just because i like to make things shorter.

PHP Code:
param2++; 
effect param2;
Action_Effect(client); 
instead of different if else statements in your MenuHandler1.

Also you might need to do some valid client checks to make sure you don't error out with invalid client call stack errors. Here's a stock that i use to check if the client is valid.

PHP Code:
stock bool:IsValidClient(iClientbool:bReplay true) {
    if(
iClient <= || iClient MaxClients)
        return 
false;
    if(!
IsClientInGame(iClient))
        return 
false;
    if(
bReplay && (IsClientSourceTV(iClient) || IsClientReplay(iClient)))
        return 
false;
    return 
true;

So for example in OnTakeDamage, before all your code starts, you would do something like
PHP Code:
if(IsValidClient(client)
{
//blah blah

Same with sm_armor and sm_reset.
Else you might end up with something like:
Client index 0 isinvalid
don't give people bad advice, if a client's entity is hooked by something like ontakedamage a fail stock like isvalidclient will always return true, since their entity will be in game for as long as they are hooked. When they disconnect the hook will be removed.
__________________
Profile - Plugins
Add me on steam if you are seeking sp/map/model commissions.
friagram is offline