[Include] OnPlayerFakeKill.inc
#1

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);
Hooked callbacks:
pawn Code:
OnPlayerConnect
OnPlayerTakeDamage
OnPlayerDeath
I haven't extensively tested it; I tested it on a localhost server with 2 players so if there are any issues let me know. It is suggested to use the OnPlayerDie callback for the death response, this is only called when the player has legitly died / been legitly killed.

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;
}
Callback explanations:
pawn Code:
OnPlayerDie
- This is simply called when the player is actually killed. This is not called in the event of a fakekill.

pawn Code:
OnPlayerFakeKill(playerid, killerid, reason)
- This is called when a player uses fake kill. The "playerid" is the player faking the kill.

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.
Reply


Messages In This Thread
OnPlayerFakeKill.inc - by Abagail - 22.07.2015, 03:09
Re: OnPlayerFakeKill.inc - by DarkLored - 22.07.2015, 03:14
Re: OnPlayerFakeKill.inc - by SickAttack - 22.07.2015, 03:46
Re: OnPlayerFakeKill.inc - by Abagail - 22.07.2015, 04:25
Re: OnPlayerFakeKill.inc - by Yashas - 22.07.2015, 05:51
Re: OnPlayerFakeKill.inc - by Evocator - 22.07.2015, 07:13
Re: OnPlayerFakeKill.inc - by amirab - 22.07.2015, 10:58
Re: OnPlayerFakeKill.inc - by Tamer - 22.07.2015, 12:58
Re: OnPlayerFakeKill.inc - by Lordzy - 22.07.2015, 13:07
Re: OnPlayerFakeKill.inc - by Abagail - 22.07.2015, 15:16

Forum Jump:


Users browsing this thread: 1 Guest(s)