PDA

View Full Version : LeaveDynamicArea


SalmaN97
02/08/2015, 01:31 AM
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



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 == 1)
{
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;
}




thanks in advance

xVIP3Rx
02/08/2015, 02:17 AM
Try it like this

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;
}

SalmaN97
02/08/2015, 04:10 AM
Try it like this

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

jamesbond007
02/08/2015, 05:04 AM
try putting the "if count" statement outside of the for loop

SalmaN97
02/08/2015, 05:41 AM
try putting the "if count" statement outside of the for loop


if(areaid == MariaBeach)
{
if(zUnderAttack[MariaBeach] == 1)
{
new count;
if(count < 2)
{
for(new i; i< MAX_PLAYERS; i++) if(IsPlayerConnected(i) && IsPlayerInDynamicArea(i, MariaBeach) && gTeam[i] == gTeam[playerid]) count++;

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;
}


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

jamesbond007
02/08/2015, 06:03 AM
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;
}

SalmaN97
02/08/2015, 06:12 AM
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

xVIP3Rx
02/08/2015, 06:51 AM
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.

SecretBoss
02/08/2015, 06:56 AM
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

SalmaN97
02/08/2015, 08:10 AM
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

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.php?t=583485&highlight=turf+capturing

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


thanks

SalmaN97
04/08/2015, 12:35 AM
Anyone???

SalmaN97
04/08/2015, 08:03 PM
Bump

jamesbond007
04/08/2015, 10:13 PM
man this is so simple.... there is many ways u can solve this.. just try this
(havent tried compiling)



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 == 1)
{
for(new i=0; i< MAX_PLAYERS; i++)
{
if(IsPlayerInDynamicArea(i, MariaBeach)) {
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;
}

SalmaN97
05/08/2015, 05:02 AM
man this is so simple.... there is many ways u can solve this.. just try this
(havent tried compiling)



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 == 1)
{
for(new i=0; i< MAX_PLAYERS; i++)
{
if(IsPlayerInDynamicArea(i, MariaBeach)) {
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;
}



This code is not working i started capturing then left with all my gang members but the capturing still was on