Help in enum
#1

Well, i used to write the co-ords of a capture zone in an enum and load co-ords from it for capture zone.
But there is a bug, once when i go attack a capture zone, all of the zones in the enum gets attacked. :/

Help pls.

My code :

pawn Код:
#define AREA51 0
#define DA 1

enum eCPZone
{
    Float:CX,
    Float:CY,
    Float:CZ,
    CTeam,
    CName,
    Float:CMinX,
    Float:CMinY,
    Float:CMaxX,
    Float:CMaxY,
    CMapIconNumber
}

new CZoneInfo[][eCPZone] = {
    {214.6418,1822.6184,6.4141,NONE,AREA51,-99.609375,1666.015625,466.796875,2140.625, 0}, //first 3 are Capture zone and second 4 gangzone
    {405.2332,2453.1125,16.5000,NONE,DA,78.125,2408.203125,501.953125,2634.765625, 1}
};


new CZoneID[sizeof(CZoneInfo)];

/// This one at OnGameModeInIt ///
for(new i=0; i < sizeof(CZoneInfo); i++)
    {
        CZoneID[CZoneInfo[i][CName]] = CreateDynamicCP(CZoneInfo[i][CX], CZoneInfo[i][CY], CZoneInfo[i][CZ],6.0, -1, -1, -1, 100.0);
        tCP[CZoneInfo[i][CName]] = NONE;
        Zone[CZoneInfo[i][CName]] = GangZoneCreate(CZoneInfo[i][CMinX], CZoneInfo[i][CMinY], CZoneInfo[i][CMaxX], CZoneInfo[i][CMaxY]);
        UnderAttack[CZoneInfo[i][CName]] = 0;
    }

////This one at OnPlayerConnect
for(new i=0; i < sizeof(CZoneInfo); i++)
    {
            SetPlayerMapIcon(playerid, CZoneInfo[i][CMapIconNumber], CZoneInfo[i][CX],CZoneInfo[i][CY],CZoneInfo[i][CZ], 19, MAPICON_GLOBAL);
            IsPlayerCapturing[playerid][CZoneInfo[i][CName]] = 0;
            CountVar[playerid][CZoneInfo[i][CName]] = 25;
            GangZoneShowForAll(Zone[CZoneInfo[i][CName]], 0x00000043);
            if(tCP[CZoneInfo[i][CName]] == NONE) GangZoneShowForAll(Zone[CZoneInfo[i][CName]], 0xFFFFFF46);
            else if(tCP[CZoneInfo[i][CName]] == TEAM_U) GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_U_COLOR);
            else if(tCP[CZoneInfo[i][CName]] == TEAM_R) GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_R_COLOR);
            else if(tCP[CZoneInfo[i][CName]] == TEAM_A) GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_A_COLOR);
            else if(tCP[CZoneInfo[i][CName]] == TEAM_A1) GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_A1_COLOR);
            else if(tCP[CZoneInfo[i][CName]] == TEAM_E) GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_E_COLOR);
    }



forward OnPlayerEnterDynamicCP(playerid, checkpointid);
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    for(new i=0; i < sizeof(CZoneInfo); i++)
    {
    if(checkpointid == CZoneID[CZoneInfo[i][CName]])
    {
        if(UnderAttack[CZoneInfo[i][CName]] == 0)
        {
            if(tCP[CZoneInfo[i][CName]] != gTeam[playerid])
            {
                CountVar[playerid][CZoneInfo[i][CName]] = 25;
                ActiveCAPZONE(playerid);

            } else return SendClientMessage(playerid, COLOR_RED,"*This zone is already captured by your team!");
        } else return CaptureZoneMessage(playerid,2);
    }
    }
    return 1;
}

forward OnPlayerLeaveDynamicCP(playerid, checkpointid);
public OnPlayerLeaveDynamicCP(playerid, checkpointid)
{
    for(new i=0; i < sizeof(CZoneInfo); i++)
    {
    if(checkpointid == CZoneID[CZoneInfo[i][CName]] && Captured[playerid][CZoneInfo[i][CName]] == 0 && IsPlayerCapturing[playerid][CZoneInfo[i][CName]] == 1 && !IsPlayerInDynamicCP(playerid, CZoneID[CZoneInfo[i][CName]]))
    {
        LeavingCAPZONE(playerid);
    }
    }
}

stock CaptureZoneMessage(playerid, messageid)
{
    switch(messageid)
    {
       case 1:
       {
           SendClientMessage(playerid, COLOR_RED,"You cannot capture while in a vehicle!");
       }
       case 2:
       {
           SendClientMessage(playerid, COLOR_RED,"This zone is already being taken over!");
       }
    }
    return 1;
}

stock ActiveCAPZONE(playerid)
{
        for(new i=0; i < sizeof(CZoneInfo); i++)
        {
        if(UnderAttack[CZoneInfo[i][CName]] == 0)
        {
            if(!IsPlayerInAnyVehicle(playerid))
            {
                UnderAttack[CZoneInfo[i][CName]] = 1;
                timer[playerid][CZoneInfo[i][CName]] = SetTimerEx("CAPZONETimer", 25000, false,"i",playerid);
                Captured[playerid][CZoneInfo[i][CName]] = 0;
                SendClientMessage(playerid, 0xFFFFFFFF,"| Stay in this checkpoint for 25 seconds to capture it! |");
               
                if(gTeam[playerid] == TEAM_U)
                {
                  GangZoneFlashForAll(Zone[CZoneInfo[i][CName]], TEAM_U_COLOR);
                }
                else if(gTeam[playerid] == TEAM_R)
                {
                  GangZoneFlashForAll(Zone[CZoneInfo[i][CName]], TEAM_R_COLOR);
                }
                else if(gTeam[playerid] == TEAM_A)
                {
                  GangZoneFlashForAll(Zone[CZoneInfo[i][CName]], TEAM_A_COLOR);
                }
                else if(gTeam[playerid] == TEAM_A1)
                {
                  GangZoneFlashForAll(Zone[CZoneInfo[i][CName]], TEAM_A1_COLOR);
                }
                else if(gTeam[playerid] == TEAM_E)
                {
                  GangZoneFlashForAll(Zone[CZoneInfo[i][CName]], TEAM_E_COLOR);
                }

                //------Message-----
                if(tCP[CZoneInfo[i][CName]] == TEAM_U)
                {
                  SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by team 1!");
                  SendClientMessageToAll(-1,"*Capture Zone is under attack!");
                }
                else if(tCP[CZoneInfo[i][CName]] == TEAM_R)
                {
                  SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by team 2!");
                  SendClientMessageToAll(-1,"*Capture Zone is under attack!");
                }
                else if(tCP[CZoneInfo[i][CName]] == TEAM_A)
                {
                  SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by team 2!");
                  SendClientMessageToAll(-1,"*Capture Zone is under attack!");
                }
                else if(tCP[CZoneInfo[i][CName]] == TEAM_A1)
                {
                  SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by team 2!");
                  SendClientMessageToAll(-1,"*Capture Zone is under attack!");
                }
                else if(tCP[CZoneInfo[i][CName]] == TEAM_E)
                {
                  SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by team 2!");
                  SendClientMessageToAll(-1,"*Capture Zone is under attack!");
                }

                else if(tCP[CZoneInfo[i][CName]] == NONE)
                {
                  SendClientMessage(playerid, COLOR_WHITE,"This flag is not controlled by any team!");
                }
                //---------loop-------//
                for(new n = 0; n < MAX_PLAYERS; n ++)
                {
                   IsPlayerCapturing[n][i] = 1;
                }
            }
            else return CaptureZoneMessage(playerid, 1);
        }
        else return CaptureZoneMessage(playerid, 2);
        }
        return 1;
}

stock CAPZONECaptured(playerid)
{
    for(new i=0; i < sizeof(CZoneInfo); i++)
    {
    Captured[playerid][CZoneInfo[i][CName]] = 1;
    UnderAttack[CZoneInfo[i][CName]] = 0;
    KillTimer(timer[playerid][CZoneInfo[i][CName]]);
    CountVar[playerid][CZoneInfo[i][CName]] = 25;
    GivePlayerScore(playerid, 5);
    GivePlayerMoney(playerid, 5000);
    SendClientMessage(playerid, COLOR_GREEN,"Congratulations! You have captured the area! You received +5 scores and +$5000 cash!");
    //==========================================================================
    for(new n = 0; n < MAX_PLAYERS; n++)
    {
       IsPlayerCapturing[n][i] = 0;
       if(gTeam[n] == gTeam[playerid])
       {
           SendClientMessage(n, 0xFFFFFFFF,"*Your team has captured the area! You received +1 score for it!");
           GivePlayerScore(n, 1);
       }
    }
    //==========================================================================
    tCP[CZoneInfo[i][CName]] = gTeam[playerid];
    GangZoneStopFlashForAll(CZoneInfo[i][CName]);
    //==========================================================================
                if(gTeam[playerid] == TEAM_U)
                {
                  GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_U_COLOR);
                }
                else if(gTeam[playerid] == TEAM_R)
                {
                  GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_R_COLOR);
                }
                else if(gTeam[playerid] == TEAM_A)
                {
                  GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_A_COLOR);
                }
                else if(gTeam[playerid] == TEAM_A1)
                {
                  GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_A1_COLOR);
                }
                else if(gTeam[playerid] == TEAM_E)
                {
                  GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_E_COLOR);
                }
    //==========================================================================
 
    //==========================================================================
    new str[128];
    format(str, sizeof(str),"%s has captured the capture zone!", GetName(playerid));
    SendClientMessageToAll(COLOR_ORANGE, str);
    }
    return 1;
}


stock LeavingCAPZONE(playerid)
{
    for(new i=0; i < sizeof(CZoneInfo); i++)
    {
    Captured[playerid][CZoneInfo[i][CName]] = 0;
    UnderAttack[CZoneInfo[i][CName]] = 0;
    KillTimer(timer[playerid][CZoneInfo[i][CName]]);
    CountVar[playerid][CZoneInfo[i][CName]] = 25;
    GangZoneStopFlashForAll(Zone[CZoneInfo[i][CName]]);
    for(new n = 0; n < MAX_PLAYERS; n++)
    {
       IsPlayerCapturing[n][i] = 0;
    }
    SendClientMessage(playerid, COLOR_RED,"*You have failed to capture this zone!");
    }
    return 1;
}

stock GivePlayerScore(playerid, score) // creating our stock
{
SetPlayerScore(playerid, GetPlayerScore(playerid) + score); // we're defining it as it will SetPlayerScore, since it's not known like GivePlayerMoney, there is just SetPlayerScore for the scores.
return 1;
}


forward CAPZONETimer(playerid);
public CAPZONETimer(playerid)
{
    CAPZONECaptured(playerid);
    return 1;
}
Reply
#2

show us your code
Reply
#3

Can you tell me your skype? So that i can personally contact you and tell you the code, i dont want my codes to be leaked.
Reply
#4

Not all your script.. just the attack bit where you're having trouble, including the enum.
Reply
#5

pawn Код:
#define AREA51 0
#define DA 1

enum eCPZone
{
    Float:CX,
    Float:CY,
    Float:CZ,
    CTeam,
    CName,
    Float:CMinX,
    Float:CMinY,
    Float:CMaxX,
    Float:CMaxY,
    CMapIconNumber
}

new CZoneInfo[][eCPZone] = {
    {214.6418,1822.6184,6.4141,NONE,AREA51,-99.609375,1666.015625,466.796875,2140.625, 0}, //first 3 are Capture zone and second 4 gangzone
    {405.2332,2453.1125,16.5000,NONE,DA,78.125,2408.203125,501.953125,2634.765625, 1}
};


new CZoneID[sizeof(CZoneInfo)];
This is the code, the thing is when i go attack area51, both desert airport and area51 are getting attacked and captured by me :/
Reply
#6

Can you show us the code about attacking an area? The mistake is probably from there.
Reply
#7

Sure, here is it :

pawn Код:
#define AREA51 0
#define DA 1

enum eCPZone
{
    Float:CX,
    Float:CY,
    Float:CZ,
    CTeam,
    CName,
    Float:CMinX,
    Float:CMinY,
    Float:CMaxX,
    Float:CMaxY,
    CMapIconNumber
}

new CZoneInfo[][eCPZone] = {
    {214.6418,1822.6184,6.4141,NONE,AREA51,-99.609375,1666.015625,466.796875,2140.625, 0}, //first 3 are Capture zone and second 4 gangzone
    {405.2332,2453.1125,16.5000,NONE,DA,78.125,2408.203125,501.953125,2634.765625, 1}
};


new CZoneID[sizeof(CZoneInfo)];

/// This one at OnGameModeInIt ///
for(new i=0; i < sizeof(CZoneInfo); i++)
    {
        CZoneID[CZoneInfo[i][CName]] = CreateDynamicCP(CZoneInfo[i][CX], CZoneInfo[i][CY], CZoneInfo[i][CZ],6.0, -1, -1, -1, 100.0);
        tCP[CZoneInfo[i][CName]] = NONE;
        Zone[CZoneInfo[i][CName]] = GangZoneCreate(CZoneInfo[i][CMinX], CZoneInfo[i][CMinY], CZoneInfo[i][CMaxX], CZoneInfo[i][CMaxY]);
        UnderAttack[CZoneInfo[i][CName]] = 0;
    }

////This one at OnPlayerConnect
for(new i=0; i < sizeof(CZoneInfo); i++)
    {
            SetPlayerMapIcon(playerid, CZoneInfo[i][CMapIconNumber], CZoneInfo[i][CX],CZoneInfo[i][CY],CZoneInfo[i][CZ], 19, MAPICON_GLOBAL);
            IsPlayerCapturing[playerid][CZoneInfo[i][CName]] = 0;
            CountVar[playerid][CZoneInfo[i][CName]] = 25;
            GangZoneShowForAll(Zone[CZoneInfo[i][CName]], 0x00000043);
            if(tCP[CZoneInfo[i][CName]] == NONE) GangZoneShowForAll(Zone[CZoneInfo[i][CName]], 0xFFFFFF46);
            else if(tCP[CZoneInfo[i][CName]] == TEAM_U) GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_U_COLOR);
            else if(tCP[CZoneInfo[i][CName]] == TEAM_R) GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_R_COLOR);
            else if(tCP[CZoneInfo[i][CName]] == TEAM_A) GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_A_COLOR);
            else if(tCP[CZoneInfo[i][CName]] == TEAM_A1) GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_A1_COLOR);
            else if(tCP[CZoneInfo[i][CName]] == TEAM_E) GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_E_COLOR);
    }



forward OnPlayerEnterDynamicCP(playerid, checkpointid);
public OnPlayerEnterDynamicCP(playerid, checkpointid)
{
    for(new i=0; i < sizeof(CZoneInfo); i++)
    {
    if(checkpointid == CZoneID[CZoneInfo[i][CName]])
    {
        if(UnderAttack[CZoneInfo[i][CName]] == 0)
        {
            if(tCP[CZoneInfo[i][CName]] != gTeam[playerid])
            {
                CountVar[playerid][CZoneInfo[i][CName]] = 25;
                ActiveCAPZONE(playerid);

            } else return SendClientMessage(playerid, COLOR_RED,"*This zone is already captured by your team!");
        } else return CaptureZoneMessage(playerid,2);
    }
    }
    return 1;
}

forward OnPlayerLeaveDynamicCP(playerid, checkpointid);
public OnPlayerLeaveDynamicCP(playerid, checkpointid)
{
    for(new i=0; i < sizeof(CZoneInfo); i++)
    {
    if(checkpointid == CZoneID[CZoneInfo[i][CName]] && Captured[playerid][CZoneInfo[i][CName]] == 0 && IsPlayerCapturing[playerid][CZoneInfo[i][CName]] == 1 && !IsPlayerInDynamicCP(playerid, CZoneID[CZoneInfo[i][CName]]))
    {
        LeavingCAPZONE(playerid);
    }
    }
}

stock CaptureZoneMessage(playerid, messageid)
{
    switch(messageid)
    {
       case 1:
       {
           SendClientMessage(playerid, COLOR_RED,"You cannot capture while in a vehicle!");
       }
       case 2:
       {
           SendClientMessage(playerid, COLOR_RED,"This zone is already being taken over!");
       }
    }
    return 1;
}

stock ActiveCAPZONE(playerid)
{
        for(new i=0; i < sizeof(CZoneInfo); i++)
        {
        if(UnderAttack[CZoneInfo[i][CName]] == 0)
        {
            if(!IsPlayerInAnyVehicle(playerid))
            {
                UnderAttack[CZoneInfo[i][CName]] = 1;
                timer[playerid][CZoneInfo[i][CName]] = SetTimerEx("CAPZONETimer", 25000, false,"i",playerid);
                Captured[playerid][CZoneInfo[i][CName]] = 0;
                SendClientMessage(playerid, 0xFFFFFFFF,"| Stay in this checkpoint for 25 seconds to capture it! |");
               
                if(gTeam[playerid] == TEAM_U)
                {
                  GangZoneFlashForAll(Zone[CZoneInfo[i][CName]], TEAM_U_COLOR);
                }
                else if(gTeam[playerid] == TEAM_R)
                {
                  GangZoneFlashForAll(Zone[CZoneInfo[i][CName]], TEAM_R_COLOR);
                }
                else if(gTeam[playerid] == TEAM_A)
                {
                  GangZoneFlashForAll(Zone[CZoneInfo[i][CName]], TEAM_A_COLOR);
                }
                else if(gTeam[playerid] == TEAM_A1)
                {
                  GangZoneFlashForAll(Zone[CZoneInfo[i][CName]], TEAM_A1_COLOR);
                }
                else if(gTeam[playerid] == TEAM_E)
                {
                  GangZoneFlashForAll(Zone[CZoneInfo[i][CName]], TEAM_E_COLOR);
                }

                //------Message-----
                if(tCP[CZoneInfo[i][CName]] == TEAM_U)
                {
                  SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by team 1!");
                  SendClientMessageToAll(-1,"*Capture Zone is under attack!");
                }
                else if(tCP[CZoneInfo[i][CName]] == TEAM_R)
                {
                  SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by team 2!");
                  SendClientMessageToAll(-1,"*Capture Zone is under attack!");
                }
                else if(tCP[CZoneInfo[i][CName]] == TEAM_A)
                {
                  SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by team 2!");
                  SendClientMessageToAll(-1,"*Capture Zone is under attack!");
                }
                else if(tCP[CZoneInfo[i][CName]] == TEAM_A1)
                {
                  SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by team 2!");
                  SendClientMessageToAll(-1,"*Capture Zone is under attack!");
                }
                else if(tCP[CZoneInfo[i][CName]] == TEAM_E)
                {
                  SendClientMessage(playerid, COLOR_WHITE,"This flag is controlled by team 2!");
                  SendClientMessageToAll(-1,"*Capture Zone is under attack!");
                }

                else if(tCP[CZoneInfo[i][CName]] == NONE)
                {
                  SendClientMessage(playerid, COLOR_WHITE,"This flag is not controlled by any team!");
                }
                //---------loop-------//
                for(new n = 0; n < MAX_PLAYERS; n ++)
                {
                   IsPlayerCapturing[n][i] = 1;
                }
            }
            else return CaptureZoneMessage(playerid, 1);
        }
        else return CaptureZoneMessage(playerid, 2);
        }
        return 1;
}

stock CAPZONECaptured(playerid)
{
    for(new i=0; i < sizeof(CZoneInfo); i++)
    {
    Captured[playerid][CZoneInfo[i][CName]] = 1;
    UnderAttack[CZoneInfo[i][CName]] = 0;
    KillTimer(timer[playerid][CZoneInfo[i][CName]]);
    CountVar[playerid][CZoneInfo[i][CName]] = 25;
    GivePlayerScore(playerid, 5);
    GivePlayerMoney(playerid, 5000);
    SendClientMessage(playerid, COLOR_GREEN,"Congratulations! You have captured the area! You received +5 scores and +$5000 cash!");
    //==========================================================================
    for(new n = 0; n < MAX_PLAYERS; n++)
    {
       IsPlayerCapturing[n][i] = 0;
       if(gTeam[n] == gTeam[playerid])
       {
           SendClientMessage(n, 0xFFFFFFFF,"*Your team has captured the area! You received +1 score for it!");
           GivePlayerScore(n, 1);
       }
    }
    //==========================================================================
    tCP[CZoneInfo[i][CName]] = gTeam[playerid];
    GangZoneStopFlashForAll(CZoneInfo[i][CName]);
    //==========================================================================
                if(gTeam[playerid] == TEAM_U)
                {
                  GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_U_COLOR);
                }
                else if(gTeam[playerid] == TEAM_R)
                {
                  GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_R_COLOR);
                }
                else if(gTeam[playerid] == TEAM_A)
                {
                  GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_A_COLOR);
                }
                else if(gTeam[playerid] == TEAM_A1)
                {
                  GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_A1_COLOR);
                }
                else if(gTeam[playerid] == TEAM_E)
                {
                  GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_E_COLOR);
                }
    //==========================================================================
 
    //==========================================================================
    new str[128];
    format(str, sizeof(str),"%s has captured the capture zone!", GetName(playerid));
    SendClientMessageToAll(COLOR_ORANGE, str);
    }
    return 1;
}


stock LeavingCAPZONE(playerid)
{
    for(new i=0; i < sizeof(CZoneInfo); i++)
    {
    Captured[playerid][CZoneInfo[i][CName]] = 0;
    UnderAttack[CZoneInfo[i][CName]] = 0;
    KillTimer(timer[playerid][CZoneInfo[i][CName]]);
    CountVar[playerid][CZoneInfo[i][CName]] = 25;
    GangZoneStopFlashForAll(Zone[CZoneInfo[i][CName]]);
    for(new n = 0; n < MAX_PLAYERS; n++)
    {
       IsPlayerCapturing[n][i] = 0;
    }
    SendClientMessage(playerid, COLOR_RED,"*You have failed to capture this zone!");
    }
    return 1;
}

stock GivePlayerScore(playerid, score) // creating our stock
{
SetPlayerScore(playerid, GetPlayerScore(playerid) + score); // we're defining it as it will SetPlayerScore, since it's not known like GivePlayerMoney, there is just SetPlayerScore for the scores.
return 1;
}


forward CAPZONETimer(playerid);
public CAPZONETimer(playerid)
{
    CAPZONECaptured(playerid);
    return 1;
}
this is the full code.
Reply
#8

You asked for the code and i showed it, now what?
Reply
#9

You loop through the zones and it actually capture all the zones.

Pass the zone's ID by either as parameter or by storing it in a variable and check inside the loop if the i is equal to that zoneid. If they do match, then continue with the rest of the code inside of it.
pawn Код:
stock CAPZONECaptured(playerid)
{
    for(new i=0; i < sizeof(CZoneInfo); i++)
    {
        Captured[playerid][CZoneInfo[i][CName]] = 1;
        UnderAttack[CZoneInfo[i][CName]] = 0;
        KillTimer(timer[playerid][CZoneInfo[i][CName]]);
        CountVar[playerid][CZoneInfo[i][CName]] = 25;
        GivePlayerScore(playerid, 5);
        GivePlayerMoney(playerid, 5000);
        SendClientMessage(playerid, COLOR_GREEN,"Congratulations! You have captured the area! You received +5 scores and +$5000 cash!");
        //==========================================================================
        for(new n = 0; n < MAX_PLAYERS; n++)
        {
            IsPlayerCapturing[n][i] = 0;
            if(gTeam[n] == gTeam[playerid])
            {
                SendClientMessage(n, 0xFFFFFFFF,"*Your team has captured the area! You received +1 score for it!");
                GivePlayerScore(n, 1);
            }
        }
        //==========================================================================
        tCP[CZoneInfo[i][CName]] = gTeam[playerid];
        GangZoneStopFlashForAll(CZoneInfo[i][CName]);
        //==========================================================================
        if(gTeam[playerid] == TEAM_U)
        {
            GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_U_COLOR);
        }
        else if(gTeam[playerid] == TEAM_R)
        {
            GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_R_COLOR);
        }
        else if(gTeam[playerid] == TEAM_A)
        {
            GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_A_COLOR);
        }
        else if(gTeam[playerid] == TEAM_A1)
        {
            GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_A1_COLOR);
        }
        else if(gTeam[playerid] == TEAM_E)
        {
            GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_E_COLOR);
        }
        //==========================================================================
       
        //==========================================================================
        new str[128];
        format(str, sizeof(str),"%s has captured the capture zone!", GetName(playerid));
        SendClientMessageToAll(COLOR_ORANGE, str);
    }
    return 1;
}
EDIT:
Quote:
Originally Posted by Pravin
Посмотреть сообщение
You asked for the code and i showed it, now what?
Be patient.. I cannot reply in the first minute and don't double post, there's an Edit button.
Reply
#10

Quote:
Originally Posted by Konstantinos
Посмотреть сообщение
You loop through the zones and it actually capture all the zones.

Pass the zone's ID by either as parameter or by storing it in a variable and check inside the loop if the i is equal to that zoneid. If they do match, then continue with the rest of the code inside of it.
pawn Код:
stock CAPZONECaptured(playerid)
{
    for(new i=0; i < sizeof(CZoneInfo); i++)
    {
        Captured[playerid][CZoneInfo[i][CName]] = 1;
        UnderAttack[CZoneInfo[i][CName]] = 0;
        KillTimer(timer[playerid][CZoneInfo[i][CName]]);
        CountVar[playerid][CZoneInfo[i][CName]] = 25;
        GivePlayerScore(playerid, 5);
        GivePlayerMoney(playerid, 5000);
        SendClientMessage(playerid, COLOR_GREEN,"Congratulations! You have captured the area! You received +5 scores and +$5000 cash!");
        //==========================================================================
        for(new n = 0; n < MAX_PLAYERS; n++)
        {
            IsPlayerCapturing[n][i] = 0;
            if(gTeam[n] == gTeam[playerid])
            {
                SendClientMessage(n, 0xFFFFFFFF,"*Your team has captured the area! You received +1 score for it!");
                GivePlayerScore(n, 1);
            }
        }
        //==========================================================================
        tCP[CZoneInfo[i][CName]] = gTeam[playerid];
        GangZoneStopFlashForAll(CZoneInfo[i][CName]);
        //==========================================================================
        if(gTeam[playerid] == TEAM_U)
        {
            GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_U_COLOR);
        }
        else if(gTeam[playerid] == TEAM_R)
        {
            GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_R_COLOR);
        }
        else if(gTeam[playerid] == TEAM_A)
        {
            GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_A_COLOR);
        }
        else if(gTeam[playerid] == TEAM_A1)
        {
            GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_A1_COLOR);
        }
        else if(gTeam[playerid] == TEAM_E)
        {
            GangZoneShowForAll(Zone[CZoneInfo[i][CName]], TEAM_E_COLOR);
        }
        //==========================================================================
       
        //==========================================================================
        new str[128];
        format(str, sizeof(str),"%s has captured the capture zone!", GetName(playerid));
        SendClientMessageToAll(COLOR_ORANGE, str);
    }
    return 1;
}
example?
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)