Capture zones >>JimmyCh's Tutorial<<
#1

Well, i followed JimmyCh's tutorial ( http://forum.sa-mp.com/showthread.ph...hlight=Capture )
But i don't understand how do i add multiple capture zones.
Should i just add:
pawn Код:
if(tCP[CAPZONE1])
{
...
if(tCP[CAPZONE2])
{
...
etc..?
Reply
#2

Explanation inside.

pawn Код:
//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
    }
}
Reply
#3

Quote:
Originally Posted by pds2k12
Посмотреть сообщение
Explanation inside.

pawn Код:
//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
    }
}
Eh, alright, i will try to process that, lol.
If not, i will bump this topic tomorrow or so :d
Reply
#4

Quote:
Originally Posted by pds2k12
Посмотреть сообщение
Explanation inside.

pawn Код:
//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
    }
}
Uh, sorry for the double-post, but do i need to remove the JimmyCh's Capzone stuff? e_e
Reply
#5

EDIT: Alright, well... I finally understood how pds2k12's version works..
But what do i do inside the case CAPZONE:
Do i do it like

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:
               }
          }
    }
}
Or..?

Also, do i need to remove all this ->

pawn Код:
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;
}
..?
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)