17.06.2013, 14:11
Hello, can someone make me a anti fake killing? i dont have an solution for that.
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;
}
//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;
}