/taketurf
#1

i want that this command will work only when 5 players in the point
and i want that if the 5 players were killed during the command the command will stop
PHP код:
command(taketurfplayeridparams[])
{
new 
pname[128];
GetPlayerName(playeridpnamesizeof(pname));
new 
string[128];
if(
gTeam[playerid] == Allied)
{
    if (
PlayerToPoint(25playerid,2422.2668,167.7081,25.0297))
    {
    
GangZoneFlashForAll(Russia,White);
    
SendClientMessage(playeridRed"Taking turf started");
    
SendClientMessage(playeridRed"Dont move and wait 2min");
    
GameTextForPlayer(playerid,"~Red~Taking turf started",5000,5);
    
SetTimer("TakeTurfReset",3000000);
    
format(stringsizeof(string), "Solder %s(%d) taking your's turf. Hurry up!"pnameplayerid);
    
SendClientMessageToAllAxis(string);
    }
}
return 
1;

Reply
#2

1. Inside the command, after the check to see if they're within the area, loop through all the players. Make a variable to keep track of the number of players who are inside the area as well. At the end of the loop, if there are not enough players, abort the operation. If so, continue with the code. It should look something like this:
pawn Код:
new z;
for( new i = 0; i < MAX_PLAYERS; i++ )
{
   if( !IsPlayerConnected( i ) ) continue;
   if( PlayerToPoint( 25, i, 2422.2668,167.7081,25.0297 ) ) z ++;
}
if( z < 5 )
{
   // Not enough players, abort the operation
}
else
{
   // Enough players, continue
}
2. To see if there were 5 people killed inside the zone, use OnPlayerDeath callback and make a global variable to keep track. When they die, check if they were inside the area, and increment the value. When they type the command, and if that value is above or equal to 5, abort the operation. You should be able to pull this off by the code I provided above, following the same method.
Reply
#3

about the first tnx man it's working
but i do in piblic OnPlayerDeath
like this.
PHP код:
  if(gTeam[playerid] == Allied)
        {
            new 
z;
            for( new 
0MAX_PLAYERSi++ )
            {
            if( !
IsPlayerConnected) ) continue;
            if( 
PlayerToPoint25i2422.2668,167.7081,25.0297 ) ) ++;
            }
            if( 
)
            {
            
KillTimer(timer1);
            
GangZoneStopFlashForAll(Russia);
            
format(stringsizeof(string), "Taking turf stoped you are win"pnameplayerid);
            
SendClientMessageToAllAxis(string);
            }
            else
            {
            
// Enough players, continue
            
}
            return 
1;
        } 
and not working
Reply
#4

pawn Код:
// global variable on top of the script
new killed_players;

public OnPlayerDeath( playerid, killerid, reason )
{
   if( PlayerToPoint( 25, playerid, 2422.2668,167.7081,25.0297 ) )
   {
      killed_players ++;
      if( killed_players == 5 )
      {
         // stop the takeover
      }
   }
   return 1;
}
Reply
#5

tnx for helping.
but it's not working.
Reply
#6

You need to be much more descriptive than just say, "it's not working".

What code did you use inside the 'stop the takeover' section? Did you kill the timer, send the messages and anything else involved with stopping the takeover of the gang zone? If it's not working, you should also debug the code to see why it's not working correctly. This can be done by putting various print statements throughout the code, with details about the script, seeing when/where the code isn't functioning how it should.
Reply
#7

i think everything ok in this code.
PHP код:
    if( PlayerToPoint25playerid2422.2668,167.7081,25.0297 ) )
    {
    
killed_players ++;
    if(
killed_players == 5)
    {
    
KillTimer(timer1);
    
GangZoneStopFlashForAll(Russia);
    
format(stringsizeof(string), "Taking turf stoped you are win"pnameplayerid);
    
SendClientMessageToAllAxis(string);
    }
    return 
1;
    } 
maybe i need delete
PHP код:
    return 1;

man i tried a lot of things i dont know why not working.
but it also a big work because i need to script that it will save.
everytime when player die,the gangzones show him like as they were.

because this code..
PHP код:
public OnPlayerSpawn(playerid)
{
    
// GANG ZONES
    
GangZoneShowForPlayer(playeridRussiaRed);
    
GangZoneShowForPlayer(playeridGermanyGreen); 
tnx for helping but i thing i will threw that away.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)