Anti-Spawn Kill or Spawn Kill Protection.

Started by Mahmoud Tornado, Jan 26, 2018, 03:45 AM

Previous topic - Next topic

Mahmoud Tornado

Hi friends.
i made Anti-Spawnkill Protection. so i wanna to share it.
class PlayerStats
{
AntiSP = false;
}

function onScriptLoad()
{
Stats <- array( GetMaxPlayers(), null );
}

function onPlayerSpawn( player )
{
SpawnKill( player );
}

function onPlayerJoin( player )
{
Stats[player.ID] = PlayerStats();
}

function onPlayerHealthChange( player, oldhp, newhp )
{
if ( Stats[ player.ID ].AntiSP )
{
player.Health = 100;
}
}

function onPlayerKill( killer, player, reason, bodypart )
{
if ( Stats[ player.ID ].AntiSP )
{
killer.Health = 0;
Message( "[#00de00]Information: [#fbf3f3]" + killer.Name + " Have Been Killed. Reason: Spawn-Kill." );
}
}

function SpawnKill( player )
{
 Stats[ player.ID ].AntiSP = true;
 NewTimer( "SpawnKillFalse", 3000, 1, player.ID );
 MessagePlayer( "[#00de00]Information: [#fbf3f3]Spawn protection enabled.", player );
}

function SpawnKillFalse(p)
{
  local player = FindPlayer(p);
  if (player)
  {
  Stats[ player.ID ].AntiSP = false;
  MessagePlayer( "[#00de00]Information: [#fbf3f3]Spawn protection disabled.", player );
}
}
Enjoy!

D4rkR420R

function SpawnKillFalse will fail if NewTimer( "SpawnKillFalse", 3000, 1, player ) is running & it will automatically crash the server. Use playerID and make a variable that it's asigned to FindPlayer( playerID ) on your SpawnKillFalse function. Overall, the system works properly.

Mahmoud Tornado

Quote from: KuRiMi on Jan 28, 2018, 01:44 AMfunction SpawnKillFalse will fail if NewTimer( "SpawnKillFalse", 3000, 1, player ) is running & it will automatically crash the server. Use playerID and make a variable that it's asigned to FindPlayer( playerID ) on your SpawnKillFalse function. Overall, the system works properly.
Thx. KuRiMi.
Updated.


Mohamed Boubekri

Quote from: KuRiMi on Jan 28, 2018, 01:44 AMfunction SpawnKillFalse will fail if NewTimer( "SpawnKillFalse", 3000, 1, player ) is running & it will automatically crash the server. Use playerID and make a variable that it's asigned to FindPlayer( playerID ) on your SpawnKillFalse function. Overall, the system works properly.
Thanks For That @KuRiMi
Quote from: Mahmoud Tornado on Jan 26, 2018, 03:45 AMHi friends.
i made Anti-Spawnkill Protection. so i wanna to share it.
class PlayerStats
{
AntiSP = false;
}

function onScriptLoad()
{
Stats <- array( GetMaxPlayers(), null );
}

function onPlayerSpawn( player )
{
SpawnKill( player );
}

function onPlayerJoin( player )
{
Stats[player.ID] = PlayerStats();
}

function onPlayerHealthChange( player, oldhp, newhp )
{
if ( Stats[ player.ID ].AntiSP )
{
player.Health = 100;
}
}

function onPlayerKill( killer, player, reason, bodypart )
{
if ( Stats[ player.ID ].AntiSP )
{
killer.Health = 0;
Message( "[#00de00]Information: [#fbf3f3]" + killer.Name + " Have Been Killed. Reason: Spawn-Kill." );
}
}

function SpawnKill( player )
{
 Stats[ player.ID ].AntiSP = true;
 NewTimer( "SpawnKillFalse", 3000, 1, player.ID );
 MessagePlayer( "[#00de00]Information: [#fbf3f3]Spawn protection enabled.", player );
}

function SpawnKillFalse(p)
{
  local player = FindPlayer(p);
  if (player)
  {
  Stats[ player.ID ].AntiSP = false;
  MessagePlayer( "[#00de00]Information: [#fbf3f3]Spawn protection disabled.", player );
}
}
Enjoy!
Good Job ;D
| What now ? | Not yet ! |
Morrocan:- [ 🇲🇦 ].

Mahmoud Tornado

Quote from: Mohamed on Jan 29, 2018, 07:51 PM
Quote from: KuRiMi on Jan 28, 2018, 01:44 AMfunction SpawnKillFalse will fail if NewTimer( "SpawnKillFalse", 3000, 1, player ) is running & it will automatically crash the server. Use playerID and make a variable that it's asigned to FindPlayer( playerID ) on your SpawnKillFalse function. Overall, the system works properly.
Thanks For That @KuRiMi
Quote from: Mahmoud Tornado on Jan 26, 2018, 03:45 AMHi friends.
i made Anti-Spawnkill Protection. so i wanna to share it.
class PlayerStats
{
AntiSP = false;
}

function onScriptLoad()
{
Stats <- array( GetMaxPlayers(), null );
}

function onPlayerSpawn( player )
{
SpawnKill( player );
}

function onPlayerJoin( player )
{
Stats[player.ID] = PlayerStats();
}

function onPlayerHealthChange( player, oldhp, newhp )
{
if ( Stats[ player.ID ].AntiSP )
{
player.Health = 100;
}
}

function onPlayerKill( killer, player, reason, bodypart )
{
if ( Stats[ player.ID ].AntiSP )
{
killer.Health = 0;
Message( "[#00de00]Information: [#fbf3f3]" + killer.Name + " Have Been Killed. Reason: Spawn-Kill." );
}
}

function SpawnKill( player )
{
 Stats[ player.ID ].AntiSP = true;
 NewTimer( "SpawnKillFalse", 3000, 1, player.ID );
 MessagePlayer( "[#00de00]Information: [#fbf3f3]Spawn protection enabled.", player );
}

function SpawnKillFalse(p)
{
  local player = FindPlayer(p);
  if (player)
  {
  Stats[ player.ID ].AntiSP = false;
  MessagePlayer( "[#00de00]Information: [#fbf3f3]Spawn protection disabled.", player );
}
}
Enjoy!
Good Job ;D
Thx. :D