Hello There, Guest! Login or Register


Anti-Afk / anti spawn kill
#1
I want to suggest anti-afk to prevent death evasion.
Anti Spawn Kill
https://wiki.sa-mp.com/wiki/SetTimerEx
Code:
// The event callback (OnPlayerSpawn) - we will start a timer here
public OnPlayerSpawn(playerid)
{
  // Anti-Spawnkill (5 seconds)

  // Set their health very high so they can't be killed
  SetPlayerHealth(playerid, 999999);

  // Notify them
  SendClientMessage(playerid, -1, "You are protected against spawn-killing for 5 seconds.");

  // Start a 5 second timer to end the anti-spawnkill
  SetTimerEx("EndAntiSpawnKill", 5000, false, "i", playerid);
}

// Forward (make public) the function so the server can 'see' it
forward EndAntiSpawnKill(playerid);

// The timer function - the code to be executed when the timer is called goes here
public EndAntiSpawnKill(playerid)
{
  // 5 seconds has passed, so let's set their health back to 100
  SetPlayerHealth(playerid, 100);

  // Let's notify them also
  SendClientMessage(playerid, -1, "You are no longer protected against spawn-killing.");
  return 1;
}
Reply


Messages In This Thread
Anti-Afk / anti spawn kill - by [PK]Ignatius - 12-05-2016, 12:16 PM
RE: Anti-Afk / anti spawn kill - by Batata45 - 12-05-2016, 05:17 PM
RE: Anti-Afk / anti spawn kill - by Ricky92 - 12-05-2016, 06:39 PM
RE: Anti-Afk / anti spawn kill - by TEF - 12-05-2016, 07:57 PM
RE: Anti-Afk / anti spawn kill - by [PK]Ignatius - 12-06-2016, 10:35 AM
RE: Anti-Afk / anti spawn kill - by Batata45 - 12-06-2016, 08:30 AM
RE: Anti-Afk / anti spawn kill - by Batata45 - 12-06-2016, 05:01 PM
RE: Anti-Afk / anti spawn kill - by [PK]Ignatius - 12-07-2016, 10:06 AM
RE: Anti-Afk / anti spawn kill - by Xanland - 12-07-2016, 11:43 AM
RE: Anti-Afk / anti spawn kill - by Russell - 12-18-2016, 10:56 PM
RE: Anti-Afk / anti spawn kill - by Yassine - 12-19-2016, 11:33 PM