Creating captureable GangZones. [Best for TDM] - Jarnu - 20.08.2012
Introduction
Hello guys, today i am going to show you how to make captureable Gang zones. Mainly for the TDM server's its very good feature. So, why wasting time.. lets start.
STEP BY STEP | PROPER EXPLANATION | WORKS.
__________________________________
1. Defining variables.
__________________________________
First we need to define some important variables we will use in creating the capture zones.
-Checkpoints:
Extra Info: [30] means you can define 30 Capture zones with only one variable.. example: CP[Zone1]; You can increase it or decrease it as per your Zone numbers.
-Gang Zones
Extra Info: same as above
-Main variables use to define the Gang zone for particular team
pawn Код:
new tCheck[30];
new zDefine[MAX_PLAYERS];
new UnderAttack[30];
Extra Info (tCheck) : It will be used to check that the zone is captured by particular team.
Extra Info (zDefine) : will be used to define the zone and the color of GangZone.
Extra Info (UnderAttack) : will be used to check that if the zone is already being taken over and to stop other player to capture it while its already being captured.
-Timer
pawn Код:
new timer[MAX_PLAYERS][30];
Extra Info: self understandable.
TIP: We will use streamer for multiple checkpoints.
_______________________________________
2. Creating Gang Zone and Checkpoints
_______________________________________
As we have defined our variables.. we can now create the Checkpoints and GangZones.
-Checkpoints
First we need to define the name of checkpoint.
Extra Info: We will use the above define for the GangZone too
Now creating the checkpoint for this we will use CreateDynamicCP
Under OnGameModeInit we will put the following code
pawn Код:
CP[Zone] = CreateDynamicCP(.....);
Same for GangZone
pawn Код:
Zone[Zone] = GangZoneCreate(......);
End: We are now done with our Checkpoint and GangZone too.. lets make it captureable!
___________________________________________
3. Making the Zone Captureable
___________________________________________
Extra: As we have used the Streamer checkpoint, so we will use OnPlayerEnterDynamicCP callback for the Checkpoint.
Under OnPlayerEnterDynamicCP
pawn Код:
if(checkpointid == CP[Zone]) {
First: Checking if the zone is already capture by the player's team
pawn Код:
if(tCheck[Zone] == gTeam[playerid]) return SendClientMessage(playerid, 0xFF0000FF,"ERROR: This zone is already captured by your team");
Second: Checking if the zone is already being taken over
pawn Код:
if(UnderAttack == 1) return SendClientMessage(playerid, 0xFF0000FF,"ERROR: This zone is already being taken over!");
Third: Checking if the player who is trying to enter zone is in vehicle
pawn Код:
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFF0000FF,"ERROR: You cannot capture while in vehicle!");
If the above situations are not there.. then setting it UnderAttack.
Setting up the timer to capture the zone.
pawn Код:
timer[playerid][Zone] = SetTimerEx("SetZone",25000,false,"i", playerid);
Flashing the zone when player enter Checkpoint.
pawn Код:
GangZoneFlashForAll(Zone[Zone],COLOR_RED);
Sending message to all the this zone is being taken over.
pawn Код:
SendClientMessageToAll(0x00FF00FF,"*Zone is being taken over!");
defining the zone for next setting up for player's team
pawn Код:
zDefine[playerid] = Zone;
Proper code for above situation
pawn Код:
if(checkpointid == CP[Zone])
{
if(tCheck[Zone] == gTeam[playerid]) return SendClientMessage(playerid, COLOR_RED,"This zone is already captured by your team");
if(UnderAttack[Zone] == 1) return SendClientMessage(playerid, COLOR_RED,"This zone is already being taken over!");
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, RED,"ERROR: You cannot capture while in vehicle!");
UnderAttack[Zone] = 1;
timer[playerid][Zone] = SetTimerEx("SetZone",25000,false,"i", playerid);
GangZoneFlashForAll(Zone[Zone],COLOR_RED);
SendClientMessageToAll(GREEN, "Zone is being taken over");
zDefine[playerid] = Zone;
}
Now OnPlayerLeaveDynamicCP
pawn Код:
if(checkpointid == CP[Zone]) {
First doing UnderAttack = 0;
Stopping the zone's flash
pawn Код:
GangZoneStopFlashForAll(Zone[Zone]);
Killing the timer
pawn Код:
KillTimer(timer[playerid][Zone]);
_________________________
Reaching towards final steps.
_________________________
Following codes are self understandable.
pawn Код:
forward SetZone(playerid);
public SetZone(playerid)
{
SetPlayerScore(playerid, GetPlayerScore(playerid) + 3); //Giving score and money
GivePlayerMoney(playerid, 3000);
SendClientMessage(playerid,GREEN,"Congratulation! You have Gained 3 Scores & 3000$ Money ");
UnderAttack[Zone] = 0; //Stopping the UnderAttack
KillTimer(timer[playerid][Zone]); //Killing the timer
SetGangZone(playerid); //We will define it..
return 1;
}
SetGangZone is also self Understandable
pawn Код:
forward SetGangZone(playerid);
public SetGangZone(playerid)
{
if(zDefine[playerid] == Zone)
{
GangZoneShowForAll(Zone[Zone],GetPlayerColor(playerid));
/*Following code looks a bit big but its very simple.. its just send msg. */
new string[126], pName5[MAX_PLAYER_NAME];
GetPlayerName(playerid,pName5,sizeof(pName5));
format(string,sizeof string,"*%s has captured Zone",pName5);
GangZoneStopFlashForAll(Zone[Zone]);
SendClientMessageToAll(GREEN, string);
tCheck[Zone] = gTeam[playerid];
}
return 1;
}
TIP: You need to kill the timer in various situations like OnPlayerDeath...
Thank you for reading the tutorial.. it might helped you a bit ..
+REP me if you liked it please.. ^-^
Re: Creating captureable GangZones. [Best for TDM] - Jarnu - 28.08.2012
Comment guys.. anyway.. UPDATED. and fixed a missing brace
Re: Creating captureable GangZones. [Best for TDM] -
Jeth - 28.08.2012
Nice Job Jarnu!
it's good dude
Re: Creating captureable GangZones. [Best for TDM] -
Inverse9 - 28.08.2012
jarnu
i can't understand
i can't added capture zone please help me and tell me with easily
Re: Creating captureable GangZones. [Best for TDM] -
DeadLy™ - 28.08.2012
Jarnu, Nice [Tutorial]
Good Job.
Re: Creating captureable GangZones. [Best for TDM] -
Lordzy - 28.08.2012
In my opinion it would be more better if you explain more.
Explain each lines..so that it'll look more better than current.
Re: Creating captureable GangZones. [Best for TDM] -
Nirzor - 28.08.2012
Jarnu a mistake you did not add the OnPlayerLeaveDynamicCP(playerid, checkpointid) lol! add it!
and Nice Tutorial jarnu
great job from my great buddy! and you should explain the CreateDynamicCP more cause
in its last there is after float
,y,z there is CP size and other things which newbies don't understand if they don't
know that they can't make the CP give the last codes for CP or it will be total mess! i can also make capture zones
now!
but i don't cheat your tutorial! :P
Re: Creating captureable GangZones. [Best for TDM] - Jarnu - 29.08.2012
Quote:
Now OnPlayerLeaveDynamicCP
|
Quote:
Jarnu a mistake you did not add the OnPlayerLeaveDynamicCP(playerid, checkpointid) lol! add it!
|
Go and read the tutorial properly..
@all thanks ^_^
Re: Creating captureable GangZones. [Best for TDM] - Jarnu - 04.09.2012
Updated! ..Comment guys
Re: Creating captureable GangZones. [Best for TDM] -
Devilxz97 - 04.09.2012
Explain each lines would be better.
btw Awesome Tutorial it will help a new scripter to script a capturezone minigames or TDM gm
Re: Creating captureable GangZones. [Best for TDM] -
Cassy_ - 04.09.2012
Quote:
Originally Posted by talkro
Jarnu, Nice [Tutorial]
Good Job.
|
Regards, Cassy_
( [COD5]Cassy or call me [SWAT]Matrix[DELTA] )
Re: Creating captureable GangZones. [Best for TDM] - Jarnu - 04.09.2012
@Devil..
i will in my next tut.. ^^ and thanks
Thank You all
Re: Creating captureable GangZones. [Best for TDM] -
JustinAn - 05.09.2012
Well explained dude!
Re: Creating captureable GangZones. [Best for TDM] -
davve95 - 05.09.2012
Thanks! Gonna use this later
.
Re: Creating captureable GangZones. [Best for TDM] - Jarnu - 05.09.2012
Thank you davve and Justin ^^
Re: Creating captureable GangZones. [Best for TDM] - Jarnu - 16.09.2012
Fixed a small mistake.. thanks newbienoob
Re: Creating captureable GangZones. [Best for TDM] -
DaRk_RaiN - 15.11.2012
I love it, its understandable and simple
Re: Creating captureable GangZones. [Best for TDM] -
Coder_ - 20.11.2012
That is understandable thanks soo much ^^
We need tutorials Like this one
Re: Creating captureable GangZones. [Best for TDM] -
Joshman543 - 20.11.2012
Quote:
Originally Posted by Coder_
That is understandable thanks soo much ^^
We need tutorials Like this one
|
agreed
Re: Creating captureable GangZones. [Best for TDM] -
ikkentim - 21.11.2012
it wont work; you are defining
#define Zone 0
and later saying
Zone[Zone] = GangZoneCreate(......);
this will end up in
0[0] = GangZoneCreate(......);