01.11.2013, 13:59
Your code didn't work.
But, I, finally made it work.
Now i'm having another issue.
Now it works fine (When in god mode). I set the god mode in 160.0 (Since getplayerhealth always return this value when reached the health target).
The god mode works fine and always return this
But here what happens when there is no god mode. (100.0)
See that? It works perfectly. But the AntiCheat detects it wrongly.
Yes in the first two value it displays the correct value. But after the decimal it displays this.
Not the current player health, this:
I've put debug in the function and it returns equal. But when there is no god mode, It always return unequal (The decimal numbers are displayed wrongly and the anticheat is called when the health and the var achealth is unequal)
But, I, finally made it work.
Now i'm having another issue.
Now it works fine (When in god mode). I set the god mode in 160.0 (Since getplayerhealth always return this value when reached the health target).
The god mode works fine and always return this
Код:
160.000000 | 160.000000 //Setting the health 155.050003 | 155.050003 //Damaged (OnPlayerTakeDamage is called)
Код:
100.000000 | 100.000000 (Jake_Hero turn off his /god) 95.050003 | 95.050003 (Jake_Hero is damaged, OnPlayerTakeDamage is called) AC: 95.000000 | 95.050003 (Jake_Hero is banned)
Yes in the first two value it displays the correct value. But after the decimal it displays this.
Код:
.000000
Код:
.050003
pawn Код:
forward SetPlayerHealthEx(playerid, Float:health);
public SetPlayerHealthEx(playerid, Float:health)
{
ACHealth[playerid] = health;
printf("%f | %f", ACHealth[playerid], health);
return SetPlayerHealth(playerid, health);
}
forward SetPlayerArmourEx(playerid, Float:armour);
public SetPlayerArmourEx(playerid, Float:armour)
{
ACArmour[playerid] = armour;
printf("%f | %f", ACArmour[playerid], armour);
return SetPlayerArmour(playerid, armour);
}
public AntiCheat()
{
new Query[900],
ip[24]
;
new string[250];
foreach(new i : Player)
{
if(GetPlayerState(i) == PLAYER_STATE_NONE || GetPlayerState(i) == PLAYER_STATE_WASTED || GetPlayerState(i) == PLAYER_STATE_SPECTATING) return 1;
if(GetPlayerWeaponState(i) == WEAPONSTATE_NO_BULLETS)
{
for(new x=0;x<47;x++) Weapon[i][x] = false;
}
new weap = GetPlayerWeapon(i),
Float:health,
Float:armour
;
GetPlayerHealth(i, health);
GetPlayerArmour(i, armour);
if(health != ACHealth[i])
{
printf("AC: %f | %f", health, ACHealth[i]);
ClearChatBox(i, 100);
GetPlayerIp(i, ip, 24);
format(string, sizeof string, "» %s(%d) has been banned by AntiCheat | Reason: Health Hack", GetName(i), i);
SendClientMessageToAllEx(COLOR_RED, string);
SendClientMessageEx(i, COLOR_YELLOW, "AntiCheat: "white"[30] Wassup with your heal, Hahaha i caught you!");
SendClientMessageEx(i, COLOR_RED, "You've been banned from the server, Reason: Health Hacks!");
SendClientMessageEx(i, COLOR_GREEN, "If you think this is mistake create a ban appeal on the forum!");
format(Query, sizeof(Query), "UPDATE `bans` SET `Temporary` = 0, `IP` = '%s', `Month` = 1, `Days` = 1, `Years` = 1970, `NAME` = '%s', `REASON` = 'Health Hacks', `BannedBy` = 'AC' WHERE `NAME` = '%s'", ip, DB_Escape(GetName(i)), DB_Escape(GetName(i)));
db_query(Database, Query);
db_free_result(db_query(Database, Query));
KickDelay(i);
format(string, sizeof string, "%s has been banned by Anitcheat, Reason: Health Hack", GetName(i));
SaveLogs("aclog", string);
return 1;
}
if(armour != ACArmour[i])
{
ClearChatBox(i, 100);
GetPlayerIp(i, ip, 24);
format(string, sizeof string, "» %s(%d) has been banned by AntiCheat | Reason: Armour Hack", GetName(i), i);
SendClientMessageToAllEx(COLOR_RED, string);
SendClientMessageEx(i, COLOR_YELLOW, "AntiCheat: "white"[30] Wassup with your armour shield, Hahaha i caught you!");
SendClientMessageEx(i, COLOR_RED, "You've been banned from the server, Reason: Armour Hacks!");
SendClientMessageEx(i, COLOR_GREEN, "If you think this is mistake create a ban appeal on the forum!");
format(Query, sizeof(Query), "UPDATE `bans` SET `Temporary` = 0, `IP` = '%s', `Month` = 1, `Days` = 1, `Years` = 1970, `NAME` = '%s', `REASON` = 'Armour Hacks', `BannedBy` = 'AC' WHERE `NAME` = '%s'", ip, DB_Escape(GetName(i)), DB_Escape(GetName(i)));
db_query(Database, Query);
db_free_result(db_query(Database, Query));
KickDelay(i);
format(string, sizeof string, "%s has been banned by Anitcheat, Reason: Armour Hack", GetName(i));
SaveLogs("aclog", string);
return 1;
}
}
return 1;
}
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
if(issuerid == INVALID_PLAYER_ID)
{
if(ACArmour[playerid])
{
ACArmour[playerid] -= amount;
SetPlayerArmourEx(playerid, ACArmour[playerid]);
}
else
{
if(ACArmour[playerid] - amount >= 0)
{
ACArmour[playerid] -= amount;
SetPlayerArmourEx(playerid, ACArmour[playerid]);
}
else
{
ACHealth[playerid] -= (amount - ACArmour[playerid]);
ACArmour[playerid] = 0;
SetPlayerHealthEx(playerid, ACHealth[playerid]);
}
}
}
return 1;
}
public OnPlayerGiveDamage(playerid, damagedid, Float: amount, weaponid)
{
if(ACArmour[damagedid])
{
ACArmour[damagedid] -= amount;
SetPlayerArmourEx(damagedid, ACArmour[damagedid]);
}
else
{
if(ACArmour[damagedid] - amount >= 0)
{
ACArmour[damagedid] -= amount;
SetPlayerArmourEx(damagedid, ACArmour[damagedid]);
}
else
{
ACHealth[damagedid] -= (amount - ACArmour[damagedid]);
ACArmour[damagedid] = 0;
SetPlayerHealthEx(damagedid, ACHealth[damagedid]);
}
}
return 1;
}