[Tutorial] Easiest Way To Create Capture Zones
#1

I was seeing around whole SA-MP many people have questions how to create Capture Zone so today i am showing

a tutorial by which you can create 1 capture zone in your script


So before you script you need to know two things that is first of all you need to know how to create gang zones if

you don't know see my gang zone tutorial here

http://forum.sa-mp.com/showthread.ph...Easiest+Create


Now after you know how to create gang zone secondly you have to know how to create teams if you don't know see

my this tutorial http://forum.sa-mp.com/showthread.ph...Easiest+Create

now if you know how to script gang zone and teams now you want to know how to create capture zones right

now here we start


INCLUDES NEEDED FOR SCRIPTING

#include <a_samp>
#include <zcmd>
#include <Dudb>
#pragma unused ret_memcpy

First of all i am starting with the defines first make this color and gang zone defines in your script


HTML Code:
//Max Allowed Zones
#define MAX_GANGZONES   15

//Colors
#define COLOR_USA 0x0000FF96
#define COLOR_RUSSIA 0xFF000096
#define COLOR_UK 0x00808096
#define COLOR_CHINA 0x80800096
we are here defining the
HTML Code:
#define MAX_GANGZONES 15
You guys saw that right i put this define

to create the maximum amount of zone for capture some-one can create


you guys also saw i gave teh COLOR_USA etc this is because those are my team colors so it will be easy for me to

track the colors so i gave it there next part of our tutorial is you need to know how to make a Checkpoint if you

don't know see how to create here

http://forum.sa-mp.com/showthread.ph...ple+Checkpoint

then after you know how to create a checkpoint come to know now for example i choose my 4 teams USA,RUSSIA,

UK and China so we have teams and everything set up checkpoint now only thing is we need to know how to make

the capture system so to make it first go to your script line

Code:
public OnPlayerEnterCheckpoint(playerid)
so after you went to this line you need something more to make something in this line those things are


Code:
new Checkpoint[MAX_PLAYERS];
new timer;
top of
Code:
public OnGameModeInit()
so when you put them there these are used because to set

timer and max checkpoints the new timer; is to set the timer for zone to 30,40 secs whatever you like and the

new Checkpoint[MAX_PLAYERS]; is for the maximum amount of checkpoint we are using for our script


so then again come to public OnPlayerEnterCheckpoint (playerid)

then after you go there just script the following lines



Code:
 SendClientMessage(playerid, 0x00FF007A, "Wait 30 Seconds - To Caputre this Zone."); // Telling the player to        wait 30 seconds.
    GangZoneFlashForAll(China,  0xFF80FF76); // Makes the turf Flash Pink ( telling everyone its being taken over )
    SendClientMessageToAll(0xFF80FFFF, "The gangzone is being taken over"); // Sending Message to all players.
    timer = SetTimerEx("SetZone", 30000, false, "i", playerid); // Setting the Timer... ( 30 seconds )
    Checkpoint[playerid] = 1; // Telling the variable that the player is in the checkpoint.
SendClientMessage thing is to send the message to player that he has to wait for 30 seconds to capture the zone

gangzoneflashforall China is to flash the zone when some-one enters the checkpoint SendClientMessageToAll

that symbol is used for sending the message to all that the zone is being taken over by some-one and

timer = SetTimerEx("SetZone",30000,false,"i",playerid); remember we have the new timer; this new timer is used

here as timer = SetTimerEx to set the zone timer to 30 seconds for players to capture it to thats why we are

using that new timer; thing in our gm or else it would be of no use but this timer thing is very important thing in

the capture things and we are using the Checkpoint[playerid] = 1; to check if the player is in the checkpoint and

is in.

so when we complete the OnPlayerEnterCheckpoint it will be something like this


Code:
public OnPlayerEnterCheckpoint(playerid) // If the player enters a particluar checkpoint
{
    SendClientMessage(playerid, 0x00FF007A, "Wait 30 Seconds - To Caputre this Zone."); // Telling the player to wait 30 seconds.
    GangZoneFlashForAll(USA,  0xFF80FF76); // Makes the turf Flash Pink ( telling everyone its being taken over )
    GangZoneFlashForAll(China,  0xFF80FF76); // Makes the turf Flash Pink ( telling everyone its being taken over )
    SendClientMessageToAll(0xFF80FFFF, "The gangzone is being taken over"); // Sending Message to all players.
    timer = SetTimerEx("SetZone", 30000, false, "i", playerid); // Setting the Timer... ( 30 seconds )
    Checkpoint[playerid] = 1; // Telling the variable that the player is in the checkpoint.
    return 1;
}
so the next part of the tutorial is we have to know how to make a GangZoneStopFlashForAll when player leaves

checkpoint and show messages for it we need to script like this

Code:
if(Checkpoint[playerid] == 1)
    {
        SendClientMessage(playerid, 0x00FF007A, " You have left the checkpoint , You have failed to capture");
        GangZoneStopFlashForAll(USA);
        GangZoneStopFlashForAll(China);
        SendClientMessageToAll(0x00FF007A, "Zone was not taken over");
        KillTimer(timer);
        Checkpoint[playerid] = 0;
    }
we are giving the if checkpoint thing to check if the player is in checkpoint so to know when the player will leave.

SendClientMessage we are using this thing again to say player that he has left the checkpoint.

GangZoneStopFlashForAll(China); this line is used so when the player is leaving the checkpoint it will stop flash

or the whole server will be a bug. SendClientMessageToAll is used again to say everyone that the zone was not

taken over or what message you like to give. KillTimer(timer); is to stop a dangerous bug which i faced first to not

give bonus to who did not capture the zone as much as i know it is this, Checkpoint[playerid] = 0; then we will use

it to say that player is no more in checkpoint which means now the player is not in and its 0.

So when we complete our OnPlayerLeaveCheckpoint(playerid) thing then the code should be something like this



Code:
public OnPlayerLeaveCheckpoint(playerid)
{
    if(Checkpoint[playerid] == 1)
    {
        SendClientMessage(playerid, 0x00FF007A, " You have left the checkpoint , You have failed to capture");
        GangZoneStopFlashForAll(USA);
        GangZoneStopFlashForAll(China);
        SendClientMessageToAll(0x00FF007A, "Zone was not taken over");
        KillTimer(timer);
        Checkpoint[playerid] = 0;
    }
    return 1;
}
Now We Come To The Last Step Of Our Capture Zone To Set The Zone To Which Team Captures It.


Code:
forward SetZone(playerid);
public SetZone(playerid)
{
SetPlayerScore(playerid,GetPlayerScore(playerid)+5 );
GivePlayerMoney(playerid,6000);
SendClientMessage(playerid, COLOR_BLUE,"You've capture the zone and receive 6000 $ and 5 score");
we are using the forward to forward our public setzone so when we forwarded it so when the zone is captured it will

give the player bonus and other money things SetPlayerScore(playerid,GetPlayerScore(playerid)+5 ); so we are

using this thing to give the player 5 score bonus GivePlayerMoney(playerid,6000); we are using this one to give

player money of about 6000. and again we are using the sendclientmessage to say player that he has got this

amount of things as gift.

Code:
if(gTeam[playerid] == TEAM_USA)
{
	GangZoneShowForAll(USA,COLOR_USA);
}
if(gTeam[playerid] == TEAM_UK)
{
	GangZoneShowForAll(USA,COLOR_UK);
}
if(gTeam[playerid] == TEAM_RUSSIA)
{
	GangZoneShowForAll(USA,COLOR_RUSSIA);
}
if(gTeam[playerid] == TEAM_CHINA)
{
	GangZoneShowForAll(USA,COLOR_CHINA);
}
if(gTeam[playerid] == TEAM_USA)
{
	GangZoneShowForAll(China,COLOR_USA);
}
if(gTeam[playerid] == TEAM_UK)
{
	GangZoneShowForAll(China,COLOR_UK);
}
if(gTeam[playerid] == TEAM_RUSSIA)
{
	GangZoneShowForAll(China,COLOR_RUSSIA);
}
if(gTeam[playerid] == TEAM_CHINA)
{
	GangZoneShowForAll(China,COLOR_CHINA);
}
so as the zone is captured we need to know which team captured to for it we gave to show the gangzone color

TEAM_RUSSIA then RUSSIA color as in the define i already said easy to find our color if we define in team name

so when zone captured we are giving the color of the team.

so when scripting of setzone is finished it will look something like this

Code:
forward SetZone(playerid);
public SetZone(playerid)
{
SetPlayerScore(playerid,GetPlayerScore(playerid)+5 );
GivePlayerMoney(playerid,6000);
SendClientMessage(playerid, COLOR_BLUE,"You've capture the zone and receive 500 $ and 5 score");
if(gTeam[playerid] == TEAM_USA)
{
	GangZoneShowForAll(USA,COLOR_USA);
}
if(gTeam[playerid] == TEAM_UK)
{
	GangZoneShowForAll(USA,COLOR_UK);
}
if(gTeam[playerid] == TEAM_RUSSIA)
{
	GangZoneShowForAll(USA,COLOR_RUSSIA);
}
if(gTeam[playerid] == TEAM_CHINA)
{
	GangZoneShowForAll(USA,COLOR_CHINA);
}
if(gTeam[playerid] == TEAM_USA)
{
	GangZoneShowForAll(China,COLOR_USA);
}
if(gTeam[playerid] == TEAM_UK)
{
	GangZoneShowForAll(China,COLOR_UK);
}
if(gTeam[playerid] == TEAM_RUSSIA)
{
	GangZoneShowForAll(China,COLOR_RUSSIA);
}
if(gTeam[playerid] == TEAM_CHINA)
{
	GangZoneShowForAll(China,COLOR_CHINA);
}
return 1;
}
I KNOW THERE IS ONE BUG WHICH I CAN'T FIX THAT IS PLAYER OF ONE TEAM CAN CAPTURE IT THOUSAND TIMES.

and in this tutorial i have used this 4 teams as example and i created a zone name China for this tutorial and

i used OnPlayerSpawn under it SetPlayerCheckpoint(playerid,cords) to make my checkpoint and capture zone

this is a easy way to create capture zone as i know SO THANK YOU! For Watching my tutorial

If I Helped You Please +REP
Reply


Messages In This Thread
Easiest Way To Create Capture Zones - by Nirzor - 22.06.2012, 17:59
Re: Easiest Way To Create Capture Zones - by [GF]Logic - 22.06.2012, 21:41
Re: Easiest Way To Create Capture Zones - by cJMaster_ - 22.06.2012, 21:45
Re: Easiest Way To Create Capture Zones - by Nirzor - 23.06.2012, 05:30
Re: Easiest Way To Create Capture Zones - by Littlehelper - 23.06.2012, 07:25
Re: Easiest Way To Create Capture Zones - by Nirzor - 23.06.2012, 07:41
Re: Easiest Way To Create Capture Zones - by Jarnu - 26.06.2012, 08:42
Re: Easiest Way To Create Capture Zones - by Nirzor - 26.06.2012, 08:44
Re: Easiest Way To Create Capture Zones - by JimmyCh - 25.06.2013, 18:56
Re: Easiest Way To Create Capture Zones - by K3 - 28.06.2013, 07:08

Forum Jump:


Users browsing this thread: 1 Guest(s)