22.07.2015, 03:09
(
Last edited by Abagail; 22/07/2015 at 04:26 AM.
)
OnPlayerFakeKill
When I searched the SA-MP forums for an anti fake kill I was horrified to see most scripts checking to see how many times the player died / was killed in x amount of time. This is very bad for many reasons, one being it doesn't even actually say if used fakekill, rapidfire or if they just had a minigun(they also could've simply used the SetPlayerHealth function! This isn't even accounted for at all). So simply this method detects if the killer has given(or if the player has taken) damage from the killing player. If they have taken damage, they have been killed legitly. If they haven't; they are either fake killing or the server is sending the data(you shouldn't call the OnPlayerDeath callback while using this script for that reason).It has two callbacks and hooks three as found below:
Usable Callbacks:
pawn Code:
forward OnPlayerDie(playerid, killerid, reason);
forward OnPlayerFakeKill(playerid, killerid, reason);
pawn Code:
OnPlayerConnect
OnPlayerTakeDamage
OnPlayerDeath
Download: http://pastebin.com/CC7chyn9
Example script:
pawn Code:
#include <a_samp>
#include <fakekill>
public OnPlayerFakeKill(playerid, killerid, reason)
{
SendClientMessage(playerid, 0xFF0000FF, "fuck off faggot");
SetTimerEx("_Ban", 1000, false, "d", playerid);
return 1;
}
forward _Ban(playerid);
public _Ban(playerid)
{
Ban(playerid);
return 1;
}
public OnPlayerDie(playerid, killerid, reason)
{
return 1;
}
pawn Code:
OnPlayerDie
pawn Code:
OnPlayerFakeKill(playerid, killerid, reason)
It should be noted that the OnPlayerDeath callback is as of this version(I will most likely make it not call when the player uses fake kill in future versions) still gets called in the event of a fake kill. You should use OnPlayerDie for your death response, and not OnPlayerDeath.