How to make a very simple Anti-Spawn Kill -
Lagger321 - 18.05.2013
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!
Re: How to make a very simple Anti-Spawn Kill -
Tanush123 - 19.05.2013
Or you can use a timer that sets player health to 100000 for 5 seconds after they spawn
Re: How to make a very simple Anti-Spawn Kill -
Chasm - 19.05.2013
Agreed. Would be much easier.
Re: How to make a very simple Anti-Spawn Kill -
NL-Sultan - 19.05.2013
Quote:
Originally Posted by Tanush123
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!
Re: How to make a very simple Anti-Spawn Kill -
Genuine - 19.05.2013
Great work.
Re: How to make a very simple Anti-Spawn Kill -
RvGamers - 19.05.2013
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.
Re: How to make a very simple Anti-Spawn Kill -
Lagger321 - 19.05.2013
Quote:
Originally Posted by RvGamers
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!
AW: How to make a very simple Anti-Spawn Kill -
Blackazur - 19.05.2013
Yep, an timer were much better for this, like:
Code:
SetTimerEx("EndAntiSpawnKill", 5000, false, "i", playerid);
Re: How to make a very simple Anti-Spawn Kill -
Revo - 19.05.2013
This will generate ArrayIndexOutOfBounds exceptions; perform a if (killerid != INVALID_PLAYER_ID && IsPlayerConnected(killerid)) before hand.
Re: How to make a very simple Anti-Spawn Kill -
NoahF - 19.05.2013
Thanks for the tutorial.
Re: How to make a very simple Anti-Spawn Kill -
PockerFace - 19.05.2013
Ohh Thanks for this tutorial.
Re: How to make a very simple Anti-Spawn Kill -
RajatPawar - 19.05.2013
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!
Re: How to make a very simple Anti-Spawn Kill -
Beckett - 19.05.2013
Thank you!
Re: How to make a very simple Anti-Spawn Kill -
umarmalik - 19.05.2013
Thank You
Re: How to make a very simple Anti-Spawn Kill -
David (Sabljak) - 19.05.2013
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;
}
Re: How to make a very simple Anti-Spawn Kill -
Snapptime - 21.05.2013
Great work