LeaveDynamicArea
#1

Helo guys
i have made this code so when the team is capturing when a player leave dynamic area if the count of team is less thean two members then the capture should stop but if its two or more then it should continue


but my problem is that when there is three players if a player leaves the capturing stop for the other two also

PHP код:

    
if(areaid == MariaBeach)
    {
        if(
zUnderAttack[MariaBeach] == 1)
        {
            new 
count;
            for(new 
i=0iMAX_PLAYERSi++)
            {
                if(
IsPlayerInDynamicArea(iMariaBeach) && gTeam[i] == gTeam[playerid])
                
count++;
                if(
count == 1)
                {
                    
zUnderAttack[MariaBeach] = 0;
                    
GangZoneStopFlashForAll(GangZone[MariaBeach]);
                    
KillTimer(tBarTimer[i]);
                    
KillTimer(ZTimer[i][MariaBeach]);
                    
captureTime[i]= 0;
                    
PlayerTextDrawHide(iBar);
                    
SendClientMessage(i, -1,"not enough members turf cancled.");
                }
            }
        }
        return 
1;
    } 
thanks in advance
Reply
#2

Try it like this
pawn Код:
if(areaid == MariaBeach)
    {
        if(zUnderAttack[MariaBeach] == 1)
        {
            new count;
            for(new i; i< MAX_PLAYERS; i++) if(IsPlayerConnected(i) && IsPlayerInDynamicArea(i, MariaBeach) && gTeam[i] == gTeam[playerid]) count++;

            if(count < 2)
            {
                zUnderAttack[MariaBeach] = 0;
                GangZoneStopFlashForAll(GangZone[MariaBeach]);
                KillTimer(tBarTimer[i]);
                KillTimer(ZTimer[i][MariaBeach]);
                captureTime[i]= 0;
                PlayerTextDrawHide(i, Bar);
                SendClientMessage(i, -1,"not enough members turf cancled.");
            }
        }
        return 1;
    }
Reply
#3

Quote:
Originally Posted by xVIP3Rx
Посмотреть сообщение
Try it like this
pawn Код:
if(areaid == MariaBeach)
    {
        if(zUnderAttack[MariaBeach] == 1)
        {
            new count;
            for(new i; i< MAX_PLAYERS; i++) if(IsPlayerConnected(i) && IsPlayerInDynamicArea(i, MariaBeach) && gTeam[i] == gTeam[playerid]) count++;

            if(count < 2)
            {
                zUnderAttack[MariaBeach] = 0;
                GangZoneStopFlashForAll(GangZone[MariaBeach]);
                KillTimer(tBarTimer[i]);
                KillTimer(ZTimer[i][MariaBeach]);
                captureTime[i]= 0;
                PlayerTextDrawHide(i, Bar);
                SendClientMessage(i, -1,"not enough members turf cancled.");
            }
        }
        return 1;
    }
i have done that but sadly its the same and the more disturbing thing is even enemy group members leaves the area capturing stops

please help me
Reply
#4

try putting the "if count" statement outside of the for loop
Reply
#5

Quote:
Originally Posted by jamesbond007
Посмотреть сообщение
try putting the "if count" statement outside of the for loop
PHP код:
   if(areaid == MariaBeach)
    {
        if(
zUnderAttack[MariaBeach] == 1)
        {
            new 
count;
            if(
count 2)
           {
            for(new 
iiMAX_PLAYERSi++) if(IsPlayerConnected(i) && IsPlayerInDynamicArea(iMariaBeach) && gTeam[i] == gTeam[playerid]) count++;
                 
zUnderAttack[MariaBeach] = 0;
                  
GangZoneStopFlashForAll(GangZone[MariaBeach]);
                  
KillTimer(tBarTimer[i]);
                  
KillTimer(ZTimer[i][MariaBeach]);
                 
captureTime[i]= 0;
                  
PlayerTextDrawHide(iBar);
                  
SendClientMessage(i, -1,"not enough members turf cancled.");
             }
        }
        return 
1;
    } 
Is it possible? as far as i know we have to loop save the number in count then use if count

correct me if i am wrong please

thanks
Reply
#6

pawn Код:
if(areaid == MariaBeach)
    {
        if(zUnderAttack[MariaBeach] == 1)
        {
            new count;
            for(new i=0; i< MAX_PLAYERS; i++)
            {
                if(IsPlayerInDynamicArea(i, MariaBeach) && gTeam[i] == gTeam[playerid])
                count++;
            }
            if(count < 2)
            {
                zUnderAttack[MariaBeach] = 0;
                GangZoneStopFlashForAll(GangZone[MariaBeach]);
                KillTimer(tBarTimer[i]);
                KillTimer(ZTimer[i][MariaBeach]);
                    captureTime[i]= 0;
                PlayerTextDrawHide(i, Bar);
                SendClientMessage(i, -1,"not enough members turf cancled.");
            }
        }
        return 1;
    }
Reply
#7

Quote:
Originally Posted by jamesbond007
Посмотреть сообщение
pawn Код:
if(areaid == MariaBeach)
    {
        if(zUnderAttack[MariaBeach] == 1)
        {
            new count;
            for(new i=0; i< MAX_PLAYERS; i++)
            {
                if(IsPlayerInDynamicArea(i, MariaBeach) && gTeam[i] == gTeam[playerid])
                count++;
            }
            if(count < 2)
            {
                zUnderAttack[MariaBeach] = 0;
                GangZoneStopFlashForAll(GangZone[MariaBeach]);
                KillTimer(tBarTimer[i]);
                KillTimer(ZTimer[i][MariaBeach]);
                    captureTime[i]= 0;
                PlayerTextDrawHide(i, Bar);
                SendClientMessage(i, -1,"not enough members turf cancled.");
            }
        }
        return 1;
    }
Getting undefined symbols

Код:
				KillTimer(tBarTimer[i]);
				KillTimer(ZTimer[i][MariaBeach]);
		        	captureTime[i]= 0;
				PlayerTextDrawHide(i, Bar);
				SendClientMessage(i, -1,"not enough members turf cancled.");
i is undefined thats why i put the count inside loop
Reply
#8

pawn Код:
if(areaid == MariaBeach)
    {
        if(zUnderAttack[MariaBeach] == 1)
        {
            new count;
            for(new i; i< MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i))
                {
                    format(string, sizeof(string), "%d is connected", i), SendClientMessageToAll(-1, string);
                    if(IsPlayerInDynamicArea(i, MariaBeach))
                    {
                        format(string, sizeof(string), "%d is in the dynamic area", i), SendClientMessageToAll(-1, string);
                        if(gTeam[i] == gTeam[playerid])
                        {
                            format(string, sizeof(string), "%d is on the same team", i), SendClientMessageToAll(-1, string);
                           
                            count++;
                        }
                    }
                }
            }
            format(string, sizeof(string), "%d players in area", count), SendClientMessageToAll(-1, string);

            if(count < 2)
            {
                zUnderAttack[MariaBeach] = 0;
                GangZoneStopFlashForAll(GangZone[MariaBeach]);
                KillTimer(tBarTimer[i]);
                KillTimer(ZTimer[i][MariaBeach]);
                captureTime[i]= 0;
                PlayerTextDrawHide(i, Bar);
                SendClientMessage(i, -1,"not enough members turf cancled.");
            }
        }
        return 1;
    }
Tell me what does it say on the mainchat.
Reply
#9

Well you can make it with timers, for ex to check players each 1 second then if it gets 2 players it will cancel the capturing
Reply
#10

Quote:
Originally Posted by xVIP3Rx
Посмотреть сообщение
pawn Код:
if(areaid == MariaBeach)
    {
        if(zUnderAttack[MariaBeach] == 1)
        {
            new count;
            for(new i; i< MAX_PLAYERS; i++)
            {
                if(IsPlayerConnected(i))
                {
                    format(string, sizeof(string), "%d is connected", i), SendClientMessageToAll(-1, string);
                    if(IsPlayerInDynamicArea(i, MariaBeach))
                    {
                        format(string, sizeof(string), "%d is in the dynamic area", i), SendClientMessageToAll(-1, string);
                        if(gTeam[i] == gTeam[playerid])
                        {
                            format(string, sizeof(string), "%d is on the same team", i), SendClientMessageToAll(-1, string);
                           
                            count++;
                        }
                    }
                }
            }
            format(string, sizeof(string), "%d players in area", count), SendClientMessageToAll(-1, string);

            if(count < 2)
            {
                zUnderAttack[MariaBeach] = 0;
                GangZoneStopFlashForAll(GangZone[MariaBeach]);
                KillTimer(tBarTimer[i]);
                KillTimer(ZTimer[i][MariaBeach]);
                captureTime[i]= 0;
                PlayerTextDrawHide(i, Bar);
                SendClientMessage(i, -1,"not enough members turf cancled.");
            }
        }
        return 1;
    }
Tell me what does it say on the mainchat.
same problem as jamesbonds code i is undefined

Quote:
Originally Posted by SecretBoss
Посмотреть сообщение
Well you can make it with timers, for ex to check players each 1 second then if it gets 2 players it will cancel the capturing
i have a timer take a look at this:
http://forum.sa-mp.com/showthread.ph...turf+capturing

and can you please show me an example of what you said above


thanks
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)