Anti Fake Killing - Printable Version
+- SA-MP Forums Archive (
https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (
https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (
https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Anti Fake Killing (
/showthread.php?tid=444603)
Anti Fake Killing -
Blackazur - 17.06.2013
Hello, can someone make me a anti fake killing? i dont have an solution for that.
Re: Anti Fake Killing -
Jaxson - 17.06.2013
Try with checking the weapon of the killerid (GetPlayerWeapon I think) under OnPlayerDeath callback.
Re: Anti Fake Killing -
dannyk0ed - 17.06.2013
The only way i fixed this was using FuckCleo. But we can't release the source of the coding so, find another way OnPlayerDeath.
Re: Anti Fake Killing -
Pottus - 17.06.2013
Best way to do this is don't use OnPlayerDeath(), OnPlayerStateChange() and OnPlayerTakeDamage() can be used to detect when a player is killed then call your own death function - OnPlayerDeathEx().
This is definitely the way to go, you can still use OnPlayerDeath() to detect for fake kills but it wouldn't have any effect on the system anymore.
Here is what I have in my OnPlayerStateChange()
I won't paste the rest of the system, basically all you need to do is make your own OnPlayerTakeDamage() system to keep track of the players health and initiate the death callback.
pawn Code:
public OnPlayerStateChange(playerid, newstate, oldstate)
{
if(IsPlayerNPC(playerid)) { return 1; } // Player Is NPC Do Nothing
if(newstate == PLAYER_STATE_WASTED && !PlayerIsDead[playerid])
{
// Player was inside a vehicle when they died
if (oldstate == PLAYER_STATE_DRIVER || oldstate == PLAYER_STATE_PASSENGER)
{
OnPlayerDeathExtended(playerid, MAX_PLAYERS + 12, 51);
print("1:OnPlayerDeathExtended called OnPlayerStateChange");
}
// Player died in some other way
else
{
printf("2:OnPlayerDeathExtended called OnPlayerStateChange newstate: %i oldstate: %i", newstate, oldstate);
// This if statement prevents a possible bug from false calls.
if(oldstate != PLAYER_STATE_SPAWNED) OnPlayerDeathExtended(playerid, MAX_PLAYERS + 11, 47);
}
}
return 1;
}
Notice the calls to OnPlayerDeathExtended()?
The nice thing about it is it you can kill the player anywhere in the script now and form your own death callback parameters.
Re: Anti Fake Killing -
AldoT - 17.06.2013
pawn Code:
//anti fake kill
new antifakekill[MAX_PLAYERS];
public OnPlayerDeath(playerid, killerid, reason)
{
antifakekill[playerid] ++;
SetTimerEx("antifakekill2", 1000,false,"i",playerid);
return 1;
}
forward antifakekill2(playerid);
public antifakekill2(playerid)
{
antifakekill[playerid] --;
if(antifakekill[playerid] > 3)
{
new string[64], pName[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName,MAX_PLAYER_NAME);
format(string,sizeof string,"* %s was banned reason (Fake kill)",pName);
SendClientMessageToAll(0xFF0000FF,string);
BanEx(playerid, "Fake kill");
}
return 1;
}