How to make Anti-Spawn Kill -
JaKe Elite - 05.11.2012
How to make Anti-Spawn Kill
Introduction
I'm bored nothing to do at home right now,
I decide to make a tutorial how to make a Anti-Spawn Kill with Timer.
Let's get started!!
Explain
Ok first off all, Open your script .pwn.
press CTRL+F, type in the field "OnPlayerSpawn"
inside of it, Put
pawn Код:
SetTimerEx("AntiSKEnd", 10000, false, "i", playerid);
SetPlayerHealth(playerid, 999999.0);
SendClientMessage(playerid, -1, "Your spawn protection will expires in 10 seconds!");
- Explanation for SetTimerEx:
Runs a timer, AntiSKEnd is the name of the function to call, 10,000 is the time how many mileseconds the timer will end, 10,000 is 10 seconds, false means the timer will not repeat when it's called, True means it will repeat after the timer is called - True = 1, False = 0, i is Special format indicating the types of values the timer will carry, We use i because it will carry playerid parameters, We could also use d because it works like integer, DON'T EVER USE STRING WHEN IT WILL CARRY A PLAYERID PARAMETERS., playerid is Indefinite number of arguments to pass
List for the format[], we used i in the format[], It is already explained above why we use i.
Код:
Format syntax
Placeholder Meaning
i Stands for an integer parameter.
d Exactly the same as i.
a Passes an array, the next parameter must be an integer ("i") with the array's size. [CURRENTLY UNUSABLE]
s Stands for a string parameter. [CURRENTLY UNUSABLE]
f Stands for a float parameter.
b Stands for a boolean parameter.
- Explanation for SetPlayerHealth
playerid is the player who will spawn, 999999.0 means setting their health 999999.0, Remember, 999999.0 is float not an integer or string.
- Explanation for SendClientMessage
playerid is the player where the message will be sended, -1 is COLOR_WHITE, It's not invalid color, "Your spawn protection will expires in 10 seconds", is the message will be sended to playerid.
So it would look like this
When you add the SetTimerEx
pawn Код:
public OnPlayerSpawn(playerid)
{
SetPlayerHealth(playerid, 999999.0);
SetTimerEx("AntiSKEnd", 10000, false, "i", playerid);
//Your other codes
return 1;
}
Add this somewhere except inside the public callbacks, commands etc...
Explanation is the comment with "//" and "/*"
pawn Код:
forward AntiSKEnd(playerid); //We'll use this to avoid future warnings
public AntiSKEnd(playerid) //When the Timer Ends, This callback is called
{
SetPlayerHealth(playerid, 100.0);
/* - Explanation for SetPlayerHealth
playerid is the target which will set the health, 100.0, set's player health back to normal, 100.0 is float not an integer or string
*/
SendClientMessage(playerid, -1, "Spawn Protection expired!");
/*
- Explanation for SendClientMessage
playerid is the player where the message will be sended, -1 is COLOR_WHITE, It's not invalid color, "Spawn Protection expired!"
*/
return 1; //return 1 to prevent calling the function below the public callback.
}
So it must be look like this in all
pawn Код:
public OnPlayerSpawn(playerid)
{
SetPlayerHealth(playerid, 999999.0);
SetTimerEx("AntiSKEnd", 10000, false, "i", playerid);
//Your other codes
return 1;
}
forward AntiSKEnd(playerid); //We'll use this to avoid future warnings
public AntiSKEnd(playerid) //When the Timer Ends, This callback is called
{
SetPlayerHealth(playerid, 100.0);
/* - Explanation for SetPlayerHealth
playerid is the target which will set the health, 100.0, set's player health back to normal, 100.0 is float not an integer or string
*/
SendClientMessage(playerid, -1, "Spawn Protection expired!");
/*
- Explanation for SendClientMessage
playerid is the player where the message will be sended, -1 is COLOR_WHITE, It's not invalid color, "Spawn Protection expired!"
*/
return 1; //return 1 to prevent calling the function below the public callback.
}
Hope you learn how to create Anti-Spawn Kill, I did all my best to explain it, Also you won't get the warning loose indentation because i properly write it with clean indentation.
Re: How to make Anti-Spawn Kill - Jarnu - 05.11.2012
Nice tutorial kinda good for a newbie to start off with his TDM
Re: How to make Anti-Spawn Kill -
JaKe Elite - 05.11.2012
Thank you.
- Edit: Lol i saw your rep comment, My answer is no.
Re: How to make Anti-Spawn Kill -
RenSoprano - 05.11.2012
Nice very good for newbie players
Re: How to make Anti-Spawn Kill -
JaKe Elite - 06.11.2012
Newbie players?
You mean Newbie Scripters?
Anyway Thanks
Re: How to make Anti-Spawn Kill -
seanny - 06.11.2012
Very nice, well explained!
Re: How to make Anti-Spawn Kill -
bathushan - 06.11.2012
Nice Tut! Keep it up
Re: How to make Anti-Spawn Kill -
JaKe Elite - 07.11.2012
Thanks.
Re: How to make Anti-Spawn Kill -
HeArTBeaT - 10.11.2012
So I open "new.pwn" ?
Re: How to make Anti-Spawn Kill -
Plovix - 10.11.2012
Nice tutorial,it will help a lot to beginners, +rep