Help respawn cars +rep
#1

Hello , i have problem with /rac.

i want to don't respawn the trailers attach because, when i type /rac it respawns all cars including trailers.

i try many time to fix it, mm((
code:
Код:
forward RACtime();
public RACtime()
{
		new bool:unwanted[CAR_AMOUNT];
	    for(new player=0; player<MAX_PLAYERS; player++)
     	{
			 	if(IsPlayerConnected(player))
				{
					if(IsTrailerAttachedToVehicle(player)) { unwanted[GetPlayerVehicleID(player)]=true; }
            		if(IsPlayerInAnyVehicle(player)) { unwanted[GetPlayerVehicleID(player)]=true; }
				}
     	}
		for(new car = 1; car <= 420; car++)
		{
		    if(!unwanted[car]) SetVehicleToRespawn(car);
		}
}
Код:
CMD:rac(playerid, params[])
{
	if(gPlayerLogged[playerid] == 0) return SendClientMessage(playerid, COLOR_LIGHTRED, "Nu esti logat!");
	if(IsPlayerConnected(playerid))
	{
		if(PlayerInfo[playerid][pAdmin] >= 3)
		{
				new sendername[MAX_PLAYER_NAME];
				new string[128];
		        GetPlayerName(playerid, sendername, sizeof(sendername));
		    	format(string, sizeof(string), "Vehiculele vor fi respawnate in 10 secunde de catre administrator %s!", sendername);
	     		SetTimer("RACtime", 10000, 0);
				ABroadCast(0xA9C4E4FF,string,1);
		}
	}
	return 1;
}
this code was before
Код:
public RACtime(playerid)
{
      for(new player=0; player<MAX_PLAYERS; player++)
      {
      if(!IsVehicleOccupied(player)) SetVehicleToRespawn(player);
      }
      for(new car = 1; car <= 1300; car++)
      {
          if(!IsVehicleOccupied(car)) SetVehicleToRespawn(car);

      }
      return 1;
}
I hope any can help me. , Thanks.
Reply
#2

pawn Код:
if(!IsVehicleOccupied(car) && !VehicleHasTrailer(car)...
pawn Код:
VehicleHasTrailer(vehicleid)
{
      if(IsValidVehicle(vehicleid))
      {
            if(!GetVehicleTrailer(vehicleid)) {
                  return 0;
            }
         
            return 1;
      }
     
      else return INVALID_VEHICLE_ID;
}
Reply
#3

Quote:
Originally Posted by Abagail
Посмотреть сообщение
pawn Код:
if(!IsVehicleOccupied(car) && !VehicleHasTrailer(car)...
pawn Код:
VehicleHasTrailer(vehicleid)
{
      if(IsValidVehicle(vehicleid))
      {
            if(!GetVehicleTrailer(vehicleid)) {
                  return 0;
            }
         
            return 1;
      }
     
      else return INVALID_VEHICLE_ID;
}
Thanks for answer and Help, can u explique more give clear code) mean full).
Reply
#4

Bump any please!
Reply
#5

UPP!
Reply
#6

pawn Код:
forward RACtime();
public RACtime()
{
    static vehID, trailerid;
    new bool:unwanted[CAR_AMOUNT char];

    for(new player=0; player<MAX_PLAYERS; player++)
        if(IsPlayerConnected(player))
        {
            vehID = GetPlayerVehicleID(player);
            if(!(0 < vehID < CAR_AMOUNT)) continue; // if player is not in any vehicle we skip
            unwanted{vehID} = true;

            trailerid = GetVehicleTrailer(vehID);
            if(0 < trailerid < CAR_AMOUNT) // if trailer is attached
                unwanted{trailerid} = true;
        }

    for(new car = 1; car < CAR_AMOUNT; car++)
        if(!unwanted{car} && GetVehicleModel(car) > 0) // or https://sampwiki.blast.hk/wiki/IsValidVehicle instead GetVehicleModel
            SetVehicleToRespawn(car);
}
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)