Help | Godmode check is not working properly..
#1

I'm trying to make a godmode check for players and it has some problem.
It should set the player's health to his health minus one and check if the health has changed, but it always sends the message like he's hacking and the player health is 100.0 for example and the edited one is 100.0 as well like it hasn't changed at all. Please help me

pawn Код:
if(strcmp(cmd, "/godmodecheck", true) == 0)
    {
        new Float:PlayerHP[MAX_PLAYERS], Float:EditedHP[MAX_PLAYERS], givenid;
        cmd = strtok(cmdtext, idx);
        if(!strlen(cmd))
        {
            return SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /godmodecheck [playerid]");
        }
        givenid = ReturnUser(cmd);
        if(givenid != INVALID_PLAYER_ID)
        {
            CheckingGod[givenid] = 1;
            new playername[MAX_PLAYER_NAME];
            GetPlayerName(givenid, playername, sizeof(playername));
            GetPlayerHealth(givenid, PlayerHP[givenid]);
            PlayerHealthOld[playerid] = PlayerHP[givenid] - 1.0;
            PlayerHealth[playerid] = PlayerHP[givenid] - 1.0;
            SetPlayerHealth(givenid, PlayerHP[givenid] - 1.0);
            GetPlayerHealth(givenid, EditedHP[givenid]);
            if(PlayerHP[givenid] == EditedHP[givenid])
            {
                format(string, sizeof(string), "{FF0000}AntiCheat: {FFFFFF}%s (ID %d) is using godmode. Player Health: %f - Edited Health: %f", playername, givenid, PlayerHP[givenid], EditedHP[givenid]);
                SendClientMessageToAll(COLOR_WHITE, string);
                PlayerHealthOld[playerid] = PlayerHP[givenid];
                PlayerHealth[playerid] = PlayerHP[givenid];
                SetPlayerHealth(givenid, PlayerHP[givenid]);
                CheckingGod[givenid] = 0;
                return 1;
            }
            if(PlayerHP[givenid] < EditedHP[givenid])
            {
                format(string, sizeof(string), "{FF0000}AntiCheat: {FFFFFF}%s (ID %d) is not using godmode. Player Health: %f - Edited Health: %f", playername, givenid, PlayerHP[givenid], EditedHP[givenid]);
                SendClientMessageToAll(COLOR_WHITE, string);
                PlayerHealthOld[playerid] = PlayerHP[givenid];
                PlayerHealth[playerid] = PlayerHP[givenid];
                SetPlayerHealth(givenid, PlayerHP[givenid]);
                CheckingGod[givenid] = 0;
                return 1;
            }
            if(PlayerHP[givenid] > EditedHP[givenid])
            {
                format(string, sizeof(string), "{FF0000}AntiCheat: {FFFFFF}%s (ID %d) is not using godmode. Player Health: %f - Edited Health: %f", playername, givenid, PlayerHP[givenid], EditedHP[givenid]);
                SendClientMessageToAll(COLOR_WHITE, string);
                PlayerHealthOld[playerid] = PlayerHP[givenid];
                PlayerHealth[playerid] = PlayerHP[givenid];
                SetPlayerHealth(givenid, PlayerHP[givenid]);
                CheckingGod[givenid] = 0;
                return 1;
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "Player is not connected");
            return 1;
        }
        return 1;
    }
Reply
#2

Bump, can anyone help me please? It's urgent..
Reply
#3

Why are you using three different variables for the same purpose? You could just get their health and store it, then decrease it by one, and compare it to the value in the temporary variable. If it is the same, they are using godmode. If not, then give them that amount back and report that they aren't.
Reply
#4

How would it help if it does not change the player's health anyway? I tried it on myself without godmode and it still says I'm using godmode..
Reply
#5

The problem is most likely with your variables. There are three, one of which the value isn't calculated inside the command (despite being called "EditedHP"). Implement the method I stated above, it will probably fix the issue.
Reply
#6

I've changed the command and deleted the PlayerHP variable, and used the PlayerHealth one instead, but still no luck..

pawn Код:
if(strcmp(cmd, "/godmodecheck", true) == 0)
    {
        new Float:EditedHP[MAX_PLAYERS], givenid;
        cmd = strtok(cmdtext, idx);
        if(!strlen(cmd))
        {
            return SendClientMessage(playerid, 0xFFFFFFAA, "USAGE: /godmodecheck [playerid]");
        }
        givenid = ReturnUser(cmd);
        if(givenid != INVALID_PLAYER_ID)
        {
            CheckingGod[givenid] = 1;
            new playername[MAX_PLAYER_NAME];
            GetPlayerName(givenid, playername, sizeof(playername));
            SetPlayerHealth(givenid, PlayerHealth[givenid] - 1.0);
            GetPlayerHealth(givenid, EditedHP[givenid]);
            if(EditedHP[givenid] == PlayerHealth[givenid])
            {
                format(string, sizeof(string), "{FF0000}AntiCheat: {FFFFFF}%s (ID %d) is using godmode. Player Health: %f - Edited Health: %f", playername, givenid, PlayerHealth[givenid], EditedHP[givenid]);
                SendClientMessageToAll(COLOR_WHITE, string);
                SetPlayerHealth(givenid, PlayerHealth[givenid]);
                CheckingGod[givenid] = 0;
                return 1;
            }
            else if(EditedHP[givenid] < PlayerHealth[givenid])
            {
                format(string, sizeof(string), "{FF0000}AntiCheat: {FFFFFF}%s (ID %d) is not using godmode. Player Health: %f - Edited Health: %f", playername, givenid, PlayerHealth[givenid], EditedHP[givenid]);
                SendClientMessageToAll(COLOR_WHITE, string);
                SetPlayerHealth(givenid, PlayerHealth[givenid]);
                CheckingGod[givenid] = 0;
                return 1;
            }
            else if(EditedHP[givenid] > PlayerHealth[givenid])
            {
                format(string, sizeof(string), "{FF0000}AntiCheat: {FFFFFF}%s (ID %d) is not using godmode. Player Health: %f - Edited Health: %f", playername, givenid, PlayerHealth[givenid], EditedHP[givenid]);
                SendClientMessageToAll(COLOR_WHITE, string);
                SetPlayerHealth(givenid, PlayerHealth[givenid]);
                CheckingGod[givenid] = 0;
                return 1;
            }
        }
        else
        {
            SendClientMessage(playerid, COLOR_GREY, "Player is not connected");
            return 1;
        }
        return 1;
    }
Reply
#7

Again, your calls are placed in reversed orders.
pawn Код:
new Float: originalHealth, Float: editedHealth;
GetPlayerHealth(playerid, originalHealth);
SetPlayerHealth(playerid, originalHealth - 1.0);
GetPlayerHealth(playerid, editedHealth);
if(editedHealth >= originalHealth)
{
    // cheating
}
Reply
#8

I've changed to what you gave me, but still the same result.
Reply
#9

Help? I don't get why doesn't it work, it should...
Reply
#10

Please help me
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)