if(tCP[CAPZONE1])
{
...
if(tCP[CAPZONE2])
{
...
//creating a definition of 'MAX_CAPZONE, easier to loop it when it's needed'
#define MAX_CAPZONE \
( 30 )
#define CAPZONE
#define CAPZONE1
#define CAPZONE2
// and so on, until 29 + 1 = 30
//creating an array with a size of 30 and it should be 1 Dimensional array
new
tCP[ MAX_CAPZONE ]
;
//I do not suggest using Else if etc.. I suggest you using 'switch statement + loop', for example
new
i = 0; // creating an i variable
while(i < MAX_CAPZONE) // creating a loop, there's 2 way to create a loop, try searching the for(...)
{
switch( tCP[i]
{
case CAPZONE: // and so on
}
}
// or
while(i < MAX_CAPZONE) // creating a loop, there's 2 way to create a loop, try searching the for(...)
{
switch( tCP[i]
{
case 0: // and so on
}
}
Explanation inside.
pawn Код:
|
Explanation inside.
pawn Код:
|
while(i < MAX_CAPZONE) // creating a loop, there's 2 way to create a loop, try searching the for(...)
{
switch( tCP[i] )
{
case CAPZONE:
{
if(gTeam[i] == gTeam[playerid])
{
//rest of capture stuff here?D:
}
}
case CAPZONE1:
{
if(gTeam[i] == gTeam[playerid])
{
//rest of capture stuff here?D:
}
}
}
}
stock CAPZONECaptured(playerid)
{
Captured[playerid][CAPZONE] = 1;
UnderAttack[CAPZONE] = 0;
KillTimer(timer[playerid][CAPZONE]);
CountVar[playerid][CAPZONE] = 25;
GivePlayerScore(playerid, 3);
GivePlayerMoney(playerid, 5000);
GameTextForPlayer(playerid, "~g~Captured!~n~~g~+3 ~w~score~n~~w~+5'000~g~$", 3500, 3);
//==========================================================================
for(new i = 0; i < MAX_PLAYERS; i++)
{
IsPlayerCapturing[i][CAPZONE] = 0;
if(gTeam[i] == gTeam[playerid])
{
SendClientMessage(i, 0xFFFFFFFF,"[NOTE] - Your team has captured the train-station! You received +1 score for it!");
GivePlayerScore(i, 1);
}
}
//==========================================================================
tCP[CAPZONE] = gTeam[playerid];
GangZoneStopFlashForAll(Zone[CAPZONE]);
//==========================================================================
if(gTeam[playerid] == USArmy)
{
GangZoneShowForAll(Zone[CAPZONE], US_COLOR);
}
else if(gTeam[playerid] == RussianSpetsnaz)
{
GangZoneShowForAll(Zone[CAPZONE], COLOR_RED);
}
//==========================================================================
new str[128];
format(str, sizeof(str),"* %s has captured the Train-Station!!", GetName(playerid)); //aa
SendClientMessageToAll(COLOR_ORANGE, str);
return 1;
}
stock LeavingCAPZONE(playerid)
{
Captured[playerid][CAPZONE] = 0;
UnderAttack[CAPZONE] = 0;
KillTimer(timer[playerid][CAPZONE]);
CountVar[playerid][CAPZONE] = 25;
GangZoneStopFlashForAll(Zone[CAPZONE]);
for(new i = 0; i < MAX_PLAYERS; i++)
{
IsPlayerCapturing[i][CAPZONE] = 0;
}
SendClientMessage(playerid, COLOR_RED,"[NOTE] - You have failed to capture this zone!");
return 1;
}