16.07.2013, 20:24
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
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;
}