Faction Car Respawn
#1

I have this command, that will respawn all the cars from a certain faction. The problem is, that it respawns the car, even if a player is driving it. What should i do, to respawn only the unused faction cars?


Код:
	if(strcmp(cmd, "/fvr", true)) //Brooklyn Family
    {
	  if(PlayerInfo[playerid][pLeader] == 6)
	  {
         SetVehicleToRespawn(brooklyncar[0]); SetVehicleToRespawn(brooklyncar[1]); SetVehicleToRespawn(brooklyncar[2]); SetVehicleToRespawn(brooklyncar[3]); SetVehicleToRespawn(brooklyncar[4]); SetVehicleToRespawn(brooklyncar[5]); SetVehicleToRespawn(brooklyncar[6]); SetVehicleToRespawn(brooklyncar[7]); SetVehicleToRespawn(brooklyncar[8]); SetVehicleToRespawn(brooklyncar[9]);
         for(new i = 0; i < MAX_PLAYERS; i ++)
         {
		   if(PlayerInfo[i][pMember] == 6 ||PlayerInfo[i][pLeader] == 6)
		   {
                GetPlayerName(playerid, sendername, sizeof(sendername));
                format(string, sizeof(string), " All faction cars have been respawned by Leader %s.", sendername);
                SendClientMessage(i,COLOR_LIGHTBLUE,string);
           }
   		 }

      }
      else
      {
		SendClientMessage(playerid,COLOR_GREY," You are not the leader of an illegal faction !");
	  }
	}
Reply
#2

You could use
Код:
if(!IsPlayerInVehicle(playerid, vehicleid)
with
Case
Reply
#3

@SWGamer, can u be more explicit please? I have the same problem..
Reply
#4

pawn Код:
stock IsVehicleOccupied(vehicleid)
{
    for(new i = 0; i < MAX_PLAYERS; i ++)
    {
        if(IsPlayerInVehicle(i,vehicleid)) return 1;
    }
    return 0;
}
if(!IsVehicleOccupied(VEHID))
Reply
#5

pawn Код:
if(PlayerInfo[playerid][pLeader] == 6)
      {
               for(new i = 0; i < sizeof(BrooklynCars); i++)
               {
                     if(!IsVehicleOccupied(BrooklynCars[i]))
                     {
                              SetVehicleToRespawn(BrooklynCars[i]);
                     }
            }
This code is also much more dynamic / flexible because it will respawn cars as new ones are added. It requires an IsVehicleOccupied function such as the one above.
Reply


Forum Jump:


Users browsing this thread: 2 Guest(s)