[Tutorial] How to make a very simple Anti-Spawn Kill
#1

Okay, so I'm getting bored ATM so, I've decided to make this very simple tutorial about Anti-Spawn Killing.
Basically its only 9 Lines.
Okay, lets get started.

-------------------------------------------------------------------

First :
We need to put it on the OnPlayerDeath callback.
pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
   return 1;
}
Second :
We will use the IsPlayerInRangeOfPoint, but, instead of playerid, we will use Killerid.
Then find the Spawn coordinates of each teams.

pawn Code:
IsPlayerInRangeOfPoint(killerid, Float:size, Float:SpawnX, Float:SpawnY, Float:SpawnZ);
Third :
Then, we will now merge it in the OnPlayerDeath callback.

pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
   if(IsPlayerInRangeOfPoint(killerid, Float:Range, Float:SpawnX, Float:SpawnY, Float:SpawnZ))
   {
    // do whatever punishment you want to do with the Spawn Killer here.
   }
   return 1;
}
Example :
pawn Code:
public OnPlayerDeath(playerid, killerid, reason)
{
   if(IsPlayerInRangeOfPoint(killerid, 20, 1587, -1693, 7)) // It means that if the player is within 20 meter range some around the Garage of LSPD the following will happen :
   {
    SetPlayerHealth(killerid, 0); // my punishment for the Spawn Killer is Death.
    SendClientMessage(killerid, Red, "SERVER : You can't spawn kill!"); // then sends him a message that he can't spawn kill
   }
   return 1;
}
Suggestions of all types are open.
Please help me improve if anything is wrong in the tutorial!
Reply
#2

Or you can use a timer that sets player health to 100000 for 5 seconds after they spawn
Reply
#3

Agreed. Would be much easier.
Reply
#4

Quote:
Originally Posted by Tanush123
View Post
Or you can use a timer that sets player health to 100000 for 5 seconds after they spawn
Indeed, and it will function better as a Anti-Spawn, anyways, nicely done!
Reply
#5

Great work.
Reply
#6

Using a timer would not "function" better than this system. You are comparing apples to oranges. If you actually look at the code, you would see the purpose of this anti-spawn kill system is to protect an AREA, which creates a "safe area" or a "base" for the players in it. If you wanted to simply protect a player when they spawn for a few seconds regardless of where they are, then of course a timer would make sense. Like I said, you're comparing apples to oranges. Two completely different systems.
Reply
#7

Quote:
Originally Posted by RvGamers
View Post
Using a timer would not "function" better than this system. You are comparing apples to oranges. If you actually look at the code, you would see the purpose of this anti-spawn kill system is to protect an AREA, which creates a "safe area" or a "base" for the players in it. If you wanted to simply protect a player when they spawn for a few seconds regardless of where they are, then of course a timer would make sense. Like I said, you're comparing apples to oranges. Two completely different systems.
EXACTLY.
And even then,the player will lose some amount of health,if fired upon!
Reply
#8

Yep, an timer were much better for this, like:

Code:
    SetTimerEx("EndAntiSpawnKill", 5000, false, "i", playerid);
Reply
#9

This will generate ArrayIndexOutOfBounds exceptions; perform a if (killerid != INVALID_PLAYER_ID && IsPlayerConnected(killerid)) before hand.
Reply
#10

Thanks for the tutorial.
Reply
#11

Ohh Thanks for this tutorial.
Reply
#12

I, for one, frankly don't use IsPlayerInRange.. I'd rather create a dynamic sphere using streamer and then check under onPlayerDeath, and do the rest. More precise! Probably, setting a player's health to 100 ON HIS DEATH could cause problem, hence!
Reply
#13

Thank you!
Reply
#14

Thank You
Reply
#15

This is better for anti spawn kill

Code:
public OnPlayerTakeDamage(playerid, issuerid, Float: amount, weaponid)
{
 	if(IsPlayerInRangeOfPoint(issuerid, Float:Range, Float:SpawnX, Float:SpawnY, Float:SpawnZ))
	{
 	SetPlayerHealth(issuerid, 0); // my punishment for the Spawn Killer is Death.
        SendClientMessage(issuerid, -1, "SERVER : You can't spawn kill!"); // then sends him a message that he can't spawn kill
 	}
    return 1;
}
Reply
#16

Great work

Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)