[Tutorial] Spawn Kill
#1

I don't care if anybody has this tutorial, but this tutorial is for newbies/lazies on having a hard time finding spawnkill.
This is my first tutorial, so don't flame me.

Anti-Spawn Kill
What is anti-spawn kill for?
• You will not have baserapers on your server.
• Spawnkillers have no match at all.

Let's get started.

Open pawno.exe and create a new scheme.
• Open pawno.exe >> CTRL + N

Find OnPlayerSpawn.
• CTRL + F >> Then type OnPlayerSpawn.

You will see this:
pawn Код:
public OnPlayerSpawn(playerid)
{
return 1;
}
Why on OnPlayerSpawn?
• This is a callback; which means when you spawn, the codes below will activate.
• Look at other callbacks and try to learn them.

Add this before return 1;
pawn Код:
SetPlayerHealth(playerid,99999);
SetTimer("spawnkill",10000,false);
What is SetPlayerHealth and SetTimer for?

SetPlayerHealth(playerid,99999);
• This will set the player health.

SetPlayerHealth(playerid,99999);
• This is to send the 'playerhealth' to the player(the player who had the SetPlayerHealth activated.)

SetPlayerHealth(playerid,99999);
• This is how much you will set the 'playerid's' health.
____________________________________
SetTimer("spawnkill",10000,false);
• This will start the timer.

SetTimer("spawnkill",10000,false);
• This is what you will call to your timer/this will be activated when the timer stops.(we will first use 'spawnkill')

SetTimer("spawnkill",10000,false);
• This sets how much time you will activate(spawnkilling time) the timer.(Note: It's m/s format, 1 sec = 1000 m/s)

SetTimer("spawnkill",10000,false);
• This mean if this timer will loop. 'true' if yes, 'false' if not.

Now we're going to define the 'spawnkill' that we've used earlier.
Place this outside of any callbacks; because we will create a new callback.

A callback is something with 'public'. Examples:
pawn Код:
public OnPlayerRequestClass(playerid, classid)
public OnPlayerConnect(playerid)
public OnPlayerDisconnect(playerid, reason)
Place this forward anywhere on your script.(Best place to input the forward: under <a_samp>)
pawn Код:
forward spawnkill(playerid);
NOTE: You need a semi-colon at the end.

If you don't add that 'forward', this will show on your Pawn Compiler.
Код:
warning 235: public function lacks forward declaration (symbol "spawnkill")
Did you notice that other callbacks doesn't need forward? Examples of callbacks that doesn't need forward:
pawn Код:
public OnPlayerText(playerid, classid)
public OnPlayerCommandText(playerid)
public OnPlayerStateChange(playerid, reason)
It's all because of #include <a_samp>. Try creating a new scheme, and remove that include. After removing, compile it. You will recieve these errors:
Код:
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(25) : error 017: undefined symbol "print"
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(26) : error 017: undefined symbol "print"
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(27) : error 017: undefined symbol "print"
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(32) : warning 235: public function lacks forward declaration (symbol "OnGameModeInit")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(35) : error 017: undefined symbol "SetGameModeText"
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(36) : error 017: undefined symbol "AddPlayerClass"
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(40) : warning 235: public function lacks forward declaration (symbol "OnGameModeExit")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(45) : warning 235: public function lacks forward declaration (symbol "OnPlayerRequestClass")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(47) : error 017: undefined symbol "SetPlayerPos"
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(48) : error 017: undefined symbol "SetPlayerCameraPos"
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(49) : error 017: undefined symbol "SetPlayerCameraLookAt"
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(53) : warning 235: public function lacks forward declaration (symbol "OnPlayerConnect")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(58) : warning 235: public function lacks forward declaration (symbol "OnPlayerDisconnect")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(63) : warning 235: public function lacks forward declaration (symbol "OnPlayerSpawn")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(68) : warning 235: public function lacks forward declaration (symbol "OnPlayerDeath")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(73) : warning 235: public function lacks forward declaration (symbol "OnVehicleSpawn")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(78) : warning 235: public function lacks forward declaration (symbol "OnVehicleDeath")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(83) : warning 235: public function lacks forward declaration (symbol "OnPlayerText")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(88) : warning 235: public function lacks forward declaration (symbol "OnPlayerCommandText")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(90) : error 017: undefined symbol "strcmp"
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(98) : warning 235: public function lacks forward declaration (symbol "OnPlayerEnterVehicle")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(103) : warning 235: public function lacks forward declaration (symbol "OnPlayerExitVehicle")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(108) : warning 235: public function lacks forward declaration (symbol "OnPlayerStateChange")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(113) : warning 235: public function lacks forward declaration (symbol "OnPlayerEnterCheckpoint")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(118) : warning 235: public function lacks forward declaration (symbol "OnPlayerLeaveCheckpoint")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(123) : warning 235: public function lacks forward declaration (symbol "OnPlayerEnterRaceCheckpoint")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(128) : warning 235: public function lacks forward declaration (symbol "OnPlayerLeaveRaceCheckpoint")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(133) : warning 235: public function lacks forward declaration (symbol "OnRconCommand")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(138) : warning 235: public function lacks forward declaration (symbol "OnPlayerRequestSpawn")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(143) : warning 235: public function lacks forward declaration (symbol "OnObjectMoved")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(148) : warning 235: public function lacks forward declaration (symbol "OnPlayerObjectMoved")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(153) : warning 235: public function lacks forward declaration (symbol "OnPlayerPickUpPickup")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(158) : warning 235: public function lacks forward declaration (symbol "OnVehicleMod")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(163) : warning 235: public function lacks forward declaration (symbol "OnVehiclePaintjob")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(168) : warning 235: public function lacks forward declaration (symbol "OnVehicleRespray")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(173) : warning 235: public function lacks forward declaration (symbol "OnPlayerSelectedMenuRow")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(178) : warning 235: public function lacks forward declaration (symbol "OnPlayerExitedMenu")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(183) : warning 235: public function lacks forward declaration (symbol "OnPlayerInteriorChange")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(188) : warning 235: public function lacks forward declaration (symbol "OnPlayerKeyStateChange")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(193) : warning 235: public function lacks forward declaration (symbol "OnRconLoginAttempt")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(198) : warning 235: public function lacks forward declaration (symbol "OnPlayerUpdate")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(203) : warning 235: public function lacks forward declaration (symbol "OnPlayerStreamIn")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(208) : warning 235: public function lacks forward declaration (symbol "OnPlayerStreamOut")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(213) : warning 235: public function lacks forward declaration (symbol "OnVehicleStreamIn")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(218) : warning 235: public function lacks forward declaration (symbol "OnVehicleStreamOut")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(223) : warning 235: public function lacks forward declaration (symbol "OnDialogResponse")
C:\Documents and Settings\eros\Desktop\SAMP Server\gamemodes\1.pwn(228) : warning 235: public function lacks forward declaration (symbol "OnPlayerClickPlayer")
Now it needs a forward, because inside <a_samp> has the forwards for these callbacks.

Let's go back to our topic. After putting the forward for the name 'spawnkill', we will put our new callback.
pawn Код:
public spawnkill(playerid)
NOTE: You do not need any semi-colon at the end, because callbacks doesn't need them.

Open brackets.
pawn Код:
public spawnkill(playerid)
{
We will now set the player's health back to its normal.
pawn Код:
SetPlayerHealth(playerid,100.0);
We will send the player for the spawn-kill is over.
pawn Код:
SendClientMessage(playerid,-1,"Anti-Spawn Kill is now over.");
NOTE: Color -1 is color white.

Close brackets. No need for return 1;
pawn Код:
}
You have finished your own Anti-Spawn kill script! But what to do next?

You may wish to design your own Anti-Spawn Kill.
Example 1:
pawn Код:
#define COLOR 0xFFFFFFFF //0xFFFFFFFF is color white. You could set your own color here.
forward spawnkill(playerid);
public spawnkill(playerid)
{
    SetPlayerHealth(playerid,100.0);
    SendClientMessage(playerid, COLOR, "_________________________________");
    SendClientMessage(playerid, COLOR, "");
    SendClientMessage(playerid, COLOR, "Spawn-kill protection is now over.");
    SendClientMessage(playerid, COLOR, "_________________________________");
}

public OnPlayerSpawn(playerid)
{
    SendClientMessage(playerid, COLOR, "_________________________________");
    SendClientMessage(playerid, COLOR, "");
    SendClientMessage(playerid, COLOR, "You are now spawn-kill protected.");
    SendClientMessage(playerid, COLOR, "_________________________________");
    SetPlayerHealth(playerid,99999);
    SetTimer("spawnkill",10000,false);
    return 1;
}
Have fun, and happy scripting!
NOTE: You are free to rep me or not if I helped you. Any bugs/questions asked, ask it now!
Reply


Messages In This Thread
Spawn Kill - by Extraordinariness - 08.03.2014, 12:13
Re: Spawn Kill - by Joeyer5 - 19.03.2014, 10:39
Re: Spawn Kill - by Vince - 19.03.2014, 11:24
Re: Spawn Kill - by zT KiNgKoNg - 19.03.2014, 15:14
Re: Spawn Kill - by GWMPT - 19.03.2014, 16:36
Re: Spawn Kill - by SickAttack - 04.04.2014, 07:00

Forum Jump:


Users browsing this thread: 1 Guest(s)