Vice City: Multiplayer

Server Development => Scripting and Server Management => Snippet Showroom => Topic started by: Mahmoud Tornado on Jan 26, 2018, 03:45 AM

Title: Anti-Spawn Kill or Spawn Kill Protection.
Post by: Mahmoud Tornado on Jan 26, 2018, 03:45 AM
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!
Title: Re: Anti-Spawn Kill or Spawn Kill Protection.
Post by: D4rkR420R on Jan 28, 2018, 01:44 AM
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.
Title: Re: Anti-Spawn Kill or Spawn Kill Protection.
Post by: Mahmoud Tornado on Jan 28, 2018, 01:51 AM
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.
Title: Re: Anti-Spawn Kill or Spawn Kill Protection.
Post by: =RK=MarineForce on Jan 28, 2018, 03:03 PM
nice

Title: Re: Anti-Spawn Kill or Spawn Kill Protection.
Post by: Mohamed Boubekri 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
Title: Re: Anti-Spawn Kill or Spawn Kill Protection.
Post by: Mahmoud Tornado on Jan 30, 2018, 06:07 PM
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