SA-MP Forums Archive
Capture zone problem rep+ - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+--- Thread: Capture zone problem rep+ (/showthread.php?tid=636699)



Capture zone problem rep+ - Mijata - 02.07.2017

When one player capturing zone, and when other player from same team comes to capture same zone, this zone starts capturing only for last one who comes not for first one who started to capture...
I mean when second player from same team comes to capture same zone player who first started not capturing and message is showing for second player you have failed to capture

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



stock ActiveCAPZONE(playerid)
{
        if(UnderAttack[CAPZONE] == 0)
        {
            if(!IsPlayerInAnyVehicle(playerid))
            {
                UnderAttack[CAPZONE] = 1;
                timer[playerid][CAPZONE] = SetTimerEx("CAPZONETimer", 25000, false,"i",playerid);
                Captured[playerid][CAPZONE] = 0;
                GameTextForPlayer(playerid, "~w~Stay in this checkpoint for ~r~25 seconds ~w~to capture it", 5000, 1);
                if(gTeam[playerid] == C1)
                {
                  GangZoneFlashForAll(Zone[CAPZONE], 0x000088FF);
                }
                else if(gTeam[playerid] == T1)
                {
                  GangZoneFlashForAll(Zone[CAPZONE],0xFF17179B);
                }

                //------Message-----
                if(tCP[CAPZONE] == C1)
                {
                  SendClientMessage(playerid, C_COLOR,"This flag is controlled by Army!");

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

stock CAPZONECaptured(playerid)
{

    Captured[playerid][CAPZONE] = 1;
    UnderAttack[CAPZONE] = 0;
    KillTimer(timer[playerid][CAPZONE]);
    CountVar[playerid][CAPZONE] = 25;
    GivePlayerScore(playerid, 5);
    F_GivePlayerMoney(playerid, 5000);
    SendClientMessage(playerid, -1,"{FF0000}Congratulations! You have captured the Desert Airport! You received +5 scores and +$5000 cash!");
    //==========================================================================
    for(new i = 0; i < MAX_PLAYERS; i++)
    {
       IsPlayerCapturing[i][CAPZONE] = 0;
       if(gTeam[i] == gTeam[playerid])
       {
           SendClientMessage(i, -1,"{FF0000}Your team has captured the Desert Airport! You received +1 score for it!");
           GivePlayerScore(i, 1);
       }
    }
    //==========================================================================
    tCP[CAPZONE] = gTeam[playerid];
    GangZoneStopFlashForAll(Zone[CAPZONE]);
    //==========================================================================
    if(gTeam[playerid] == C1)
    {
       GangZoneShowForAll(Zone[CAPZONE], 0x000088FF);
    }
    else if(gTeam[playerid] == T1)
    {
    GangZoneShowForAll(Zone[CAPZONE], 0xFF17179B);
    }

    //==========================================================================
    new str[128];
    format(str, sizeof(str),"{2BA12F}%s has captured the Desert Airport!", GetName(playerid));
    SendClientMessageToAll(-1, str);
    return 1;
}

stock LeavingCAPZONE(playerid)
{
    Captured[playerid][CAPZONE] = 1;
    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, red,"You have failed to capture the Desert Airport!");
    return 1;
}

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



Re: Capture zone problem rep+ - Eoussama - 02.07.2017

Before capturing a zone check if anyone is already capturing it


Re: Capture zone problem rep+ - Mijata - 02.07.2017

What about this, message is showing "this zone is already being taken over" but zone stopped capturing and when this player leave zone its says u have failed to capture, for first player who started capturing nothing shows after this
Quote:

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




Re: Capture zone problem rep+ - mongi - 03.07.2017

Quote:
Originally Posted by Mijata
Посмотреть сообщение
What about this, message is showing "this zone is already being taken over" but zone stopped capturing and when this player leave zone its says u have failed to capture, for first player who started capturing nothing shows after this
Add a return. Example :
Return SendClientMessage(......);

This should work