20.08.2012, 15:16
(
Последний раз редактировалось Jarnu; 16.09.2012 в 10:56.
Причина: Fixed misstype. :S
)
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
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
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
Same for GangZone
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
First: Checking if the zone is already capture by the player's team
Second: Checking if the zone is already being taken over
Third: Checking if the player who is trying to enter zone is in vehicle
If the above situations are not there.. then setting it UnderAttack.
Setting up the timer to capture the zone.
Flashing the zone when player enter Checkpoint.
Sending message to all the this zone is being taken over.
defining the zone for next setting up for player's team
Proper code for above situation
Now OnPlayerLeaveDynamicCP
First doing UnderAttack = 0;
Stopping the zone's flash
Killing the timer
_________________________
Reaching towards final steps.
_________________________
Following codes are self understandable.
SetGangZone is also self Understandable
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.. ^-^
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:
pawn Код:
new CP[30];
-Gang Zones
pawn Код:
new Zone[30];
-Main variables use to define the Gang zone for particular team
pawn Код:
new tCheck[30];
new zDefine[MAX_PLAYERS];
new UnderAttack[30];
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];
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.
pawn Код:
#define Zone 0
Now creating the checkpoint for this we will use CreateDynamicCP
Under OnGameModeInit we will put the following code
pawn Код:
CP[Zone] = CreateDynamicCP(.....);
pawn Код:
Zone[Zone] = GangZoneCreate(......);
___________________________________________
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]) {
pawn Код:
if(tCheck[Zone] == gTeam[playerid]) return SendClientMessage(playerid, 0xFF0000FF,"ERROR: This zone is already captured by your team");
pawn Код:
if(UnderAttack == 1) return SendClientMessage(playerid, 0xFF0000FF,"ERROR: This zone is already being taken over!");
pawn Код:
if(IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, 0xFF0000FF,"ERROR: You cannot capture while in vehicle!");
pawn Код:
UnderAttack[Zone] = 1;
pawn Код:
timer[playerid][Zone] = SetTimerEx("SetZone",25000,false,"i", playerid);
pawn Код:
GangZoneFlashForAll(Zone[Zone],COLOR_RED);
pawn Код:
SendClientMessageToAll(0x00FF00FF,"*Zone is being taken over!");
pawn Код:
zDefine[playerid] = Zone;
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;
}
pawn Код:
if(checkpointid == CP[Zone]) {
pawn Код:
UnderAttack[Zone] = 0;
pawn Код:
GangZoneStopFlashForAll(Zone[Zone]);
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;
}
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.. ^-^