turf capturing
#1

Hello I am trying to make a turf system if a player wants to take a turf then there should be 2 or more players from same team to start capturing this thing works well but while 2 players from same team capturing incase if one player dies or leave turf area i want the capturing to stop for the other guy

so in few words if there is more than 2 players capturing should be fine but when there is less than 2 players i want the capturing stop

here is my code:

Command :

PHP код:

CMD
:tt(playeridparams[])
{
    new 
gang[50], string[128], count;
    else if(
gTeam[playerid] == TEAM_BALLASformat(gangsizeof(gang), "Ballas");
    else if(
gTeam[playerid] == TEAM_GROVESformat(gangsizeof(gang), "Groves");
    else if(
gTeam[playerid] == TEAM_VAGOSformat(gangsizeof(gang), "Vagos");
    if(
IsPlayerInDynamicArea(playeridTurfArea[SantaMariaBeach]))
    {
        foreach(new 
Player)
        {if(
IsPlayerInDynamicArea(iTurfArea[SantaMariaBeach]) && gTeam[i] == gTeam[playerid]) count++;}
        if(
TeamCheck[SantaMariaBeach] == gTeam[playerid]) return SendClientMessage(playerid, -1,"{FFD443}[ TurfWar ]: {FFE797}This Turf Is Already Captured By Your Gang.");
        if(
count <=1) return SendClientMessage(playerid, -1,"{FF0000}[ TurfWar ]: {FFCCCC}You Need Atleast One Gang Member To Help You Capturing The Turf!");
        if(
aDuty[playerid] == 1) return SendClientMessage(playerid, -1,"{FF0000}[ TurfWar ]: {FFCCCC}You Cant Capture A Turf While OnDuty!");
        if(
IsPlayerInAnyVehicle(playerid)) return SendClientMessage(playerid, -1,"{FF0000}[ TurfWar ]: {FFCCCC}You Cannot Capture A Turf While In Vehicle!");
        if(
zUnderAttack[SantaMariaBeach] == 0)
        {
            
zUnderAttack[SantaMariaBeach] = 1;
             
IsPlayerCapturing[playerid] = 1;
             
PlayerTextDrawShow(playeridBar);
            
ProgBarTimer[playerid] = SetTimerEx("tProgressbarTimer",1000,true,"i"playerid);
             
GangZoneFlashForAll(GangZone[SantaMariaBeach],GetPlayerColor(playerid));
             
format(stringsizeof(string), "Beach' is being TakenBy %s Gang."gang);
             
SendClientMessageToAll(-1string);
             
ZoneDefine[playerid] = Beach;
         }
    }

Timer and score giving:
PHP код:
public ProgressTimer(playerid)
{
    
captureTime[playerid] += 1000;
    if(
captureTime[playerid]== 1000)
    {
        
PlayerTextDrawSetString(playeridBar"l");
    }
    else if(
captureTime[playerid]== 2000)
    {
        
PlayerTextDrawSetString(playeridBar"ll");
    }
    else if(
captureTime[playerid]== 3000)
    {
        
PlayerTextDrawSetString(playeridBar"lll");
    }
    else if(
captureTime[playerid]== 4000)
    {
        
PlayerTextDrawSetString(playeridBar"llll");
    }
    else if(
captureTime[playerid] == 5000)
    {
        
PlayerTextDrawSetString(playeridBar"lllll");
    }
    else if(
captureTime[playerid]== 6000)
    {
        
PlayerTextDrawSetString(playeridBar"llllll");
    }
    else if(
captureTime[playerid]== 7000)
    {
        
PlayerTextDrawSetString(playeridBar"lllllll");
    }
    else if(
captureTime[playerid]== 8000)
    {
        
PlayerTextDrawSetString(playeridBar"llllllll");
    }
    else if(
captureTime[playerid]== 9000)
    {
        
PlayerTextDrawSetString(playeridBar"lllllllll");
    }
    else if(
captureTime[playerid]== 10000)
    {
        
PlayerTextDrawSetString(playeridBar"llllllllll");
    }
    else if(
captureTime[playerid]== 11000)
    {
        
PlayerTextDrawSetString(playeridBar"lllllllllll");
    }
    else if(
captureTime[playerid]== 12000)
    {
        
PlayerTextDrawSetString(playeridBar"llllllllllll");
    }
    else if(
captureTime[playerid]== 13000)
    {
        
PlayerTextDrawSetString(playeridBar"lllllllllllll");
    }
    else if(
captureTime[playerid]== 14000)
    {
        
PlayerTextDrawSetString(playeridBar"llllllllllllll");
    }
    else if(
captureTime[playerid]== 15000)
    {
        
PlayerTextDrawSetString(playeridBar"lllllllllllllll");
    }
    else if(
captureTime[playerid]== 16000)
    {
        
PlayerTextDrawSetString(playeridBar"llllllllllllllll");
    }
    else if(
captureTime[playerid]== 17000)
    {
        
PlayerTextDrawSetString(playeridBar"lllllllllllllllll");
    }
    else if(
captureTime[playerid]== 18000)
    {
        
PlayerTextDrawSetString(playeridBar"llllllllllllllllll");
    }
    else if(
captureTime[playerid]== 19000)
    {
        
PlayerTextDrawSetString(playeridBar"lllllllllllllllllll");
    }
    else if(
captureTime[playerid] == 20000)
    {
        
PlayerTextDrawSetString(playeridBar"llllllllllllllllllll");
    }
    else if(
captureTime[playerid]== 21000)
    {
        
PlayerTextDrawSetString(playeridBar"lllllllllllllllllllll");
    }
    else if(
captureTime[playerid]== 22000)
    {
        
PlayerTextDrawSetString(playeridBar"llllllllllllllllllllll");
    }
    else if(
captureTime[playerid]== 23000)
    {
        
PlayerTextDrawSetString(playeridBar"lllllllllllllllllllllll");
    }
    else if(
captureTime[playerid]== 24000)
    {
        
PlayerTextDrawSetString(playeridBar"llllllllllllllllllllllll");
    }
    else if(
captureTime[playerid]== 25000)
    {
        
PlayerTextDrawSetString(playeridBar"lllllllllllllllllllllllll");
    }
    else if(
captureTime[playerid]== 26000)
    {
        
PlayerTextDrawSetString(playeridBar"llllllllllllllllllllllllll");
    }
    else if(
captureTime[playerid]== 27000)
    {
        
PlayerTextDrawSetString(playeridBar"lllllllllllllllllllllllllll");
    }
    else if(
captureTime[playerid]== 28000)
    {
        
PlayerTextDrawSetString(playeridBar"llllllllllllllllllllllllllll");
    }
    else if(
captureTime[playerid]== 29000)
    {
        
PlayerTextDrawSetString(playeridBar"lllllllllllllllllllllllllllll");
    }
    else if(
captureTime[playerid]== 30000)
    {
        
PlayerTextDrawSetString(playeridBar" ");
        
PlayerTextDrawHide(playeridBar);
        
captureTime[playerid]= 0;
        
//The finish code here:
        
foreach(new Player)
        {
            if(
gTeam[i] == gTeam[playerid])
            {
                
SetPlayerScore(iGetPlayerScore(i) + 5); //Giving score and money
                
GivePlayerMoney(i5000);
                
SendClientMessage(playerid,-1,"You get 5 scores and 5000!");
            }
        }
        
KillTimer(ZoneTimer[playerid][SBeach]);
        
KillTimer(Bar[playerid]);
        
SetGangZone(playerid);
    }
    return 
1;

When player leave area:
PHP код:
public OnPlayerLeaveDynamicArea(playeridareaid)
{
    foreach(new 
Player)
    if(
areaid == TurfArea[Beach])
    {
        new 
count;
        {if(
IsPlayerInDynamicArea(iTurfArea[Beach]) && gTeam[i] == gTeam[playerid])count++;}
        if(
UnderAttack[Beach] == && (count <=1))
        {
            
UnderAttack[Beach] = 0;
            
GangZoneStopFlashForAll(GangZone[Beach]);
            
KillTimer(Bar[i]);
            
KillTimer(ZoneTimer[i][Beach]);
            
captureTime[i]= 0;
              
PlayerTextDrawSetString(playeridBar" ");
            
PlayerTextDrawHide(playeridBar);
            
SendClientMessage(playerid, -1,"Turf attack cancled");
        }
        return 
1;
    } 
Please help
Reply
#2

Added more codes any kind of help will be appreciated
Reply
#3

BUMP
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)