Need help with this Health Hack command please.
#4

Quote:
Originally Posted by Babul
View Post
the "else if" statements are th reason. firsly, you allow 1 state only, either if the player IS armor hacking, if not (else) hes health hacking etc. it all depends on the fail of the prior check.
never make a check depend on another one, unless its the sam variable - you want to check for both health AND armor cheaters? try this, i only took out one "else", and rearranged the order:
pawn Code:
CMD:hh(playerid, params[])
{
    new iTarget;
    if(sscanf(params, "u", iTarget)) return SendClientMessage(playerid, COLOR_WHITE, "USAGE: /explode [PlayerID] (Spectate before exploding.)");
    {
        if(iTarget == INVALID_PLAYER_ID) return SendClientMessage(playerid, COLOR_BRIGHTRED, "ERROR: That Player is not connected.");
        {
            if(PlayerInfo[playerid][pAdmin] >=3)
            {
                new TStr[256];
                new pStr[256];
                new pname[MAX_PLAYER_NAME];
                GetPlayerName(playerid,pname,sizeof(pname));
                new tname[MAX_PLAYER_NAME];
                GetPlayerName(iTarget, tname,sizeof(tname));
                format(pStr,sizeof(pStr), "You have checked %s for health hacks.",tname);
                format(TStr,sizeof(TStr), "You've been checked for health hacks by Administrator %s.",pname);
                SendClientMessage(iTarget, COLOR_TAN, TStr);
                SendClientMessage(playerid, COLOR_GREEN, pStr);
                new Float:health;
                new Float:armour;
                GetPlayerHealth(iTarget, health);
                GetPlayerArmour(iTarget, armour);
                if (armour > 105)//first, check if its an armor cheater. if so, warn admin...
                {
                    SendClientMessage(playerid, COLOR_TAN, "Player is possibly hacking.");
                }
                else if(armour < 100.0)//..if not, hes ok. the next check will start regardless this one:
                {
                    SendClientMessage(playerid, COLOR_TAN, "Player is NOT hacking.");
                }
                if (health > 105)//now do the check from above for health aswell...
                {
                    SendClientMessage(playerid, COLOR_TAN, "Player is possibly hacking.");
                }
                else if(health < 100.0)
                {
                    SendClientMessage(playerid, COLOR_TAN, "Player is NOT hacking.");
                }
            }
            else SendClientMessage(playerid, COLOR_BRIGHTRED, "You're not authorized to use this command.");
        }
    }
    return 1;
}
Thank you, completely understandable. I really do appreciate it.
Reply


Messages In This Thread
Need help with this Health Hack command please. - by rangerxxll - 08.03.2012, 23:00
Re: Need help with this Health Hack command please. - by Shabi RoxX - 08.03.2012, 23:06
Re: Need help with this Health Hack command please. - by Babul - 08.03.2012, 23:07
Re: Need help with this Health Hack command please. - by rangerxxll - 08.03.2012, 23:32

Forum Jump:


Users browsing this thread: 3 Guest(s)