[HELP] Respawn Empty Cars ONLY
#1

Hello, can someone help me make this command respawn ONLY empty cars instead of all? thanks.

Код:
	command(vehrespawn, playerid, params[])
	{
		#pragma unused params
		if( Player[playerid][AdminLevel] >= 5)
		{
			for(new i = 0; i < MAX_VEHICLES; i++)
			{
				if(Vehicles[i][GameID] >= 1)
				{
					SetVehicleToRespawn(Vehicles[i][GameID]);
				}
			}

			SendClientMessage( playerid, WHITE, "All saved vehicles have been respawned." );
		}
		return 1;
	}
Reply
#2

Take a look at this example I wrote a while ago:
pawn Код:
forward RespawnCars();
public RespawnCars()
{
   new
      needed[MAX_VEHICLES],
      i,
      v;
     
   while(i != MAX_PLAYERS)
   {
       needed[GetPlayerVehicleID(i)] = (IsPlayerInAnyVehicle(i) == 1) ? (1) : (0);
            ++i;
   }
   while(v != MAX_VEHICLES)
   {
       if(!needed[v]) SetVehicleToRespawn(v);
       ++v;
   }
   return 1;
}
Reply
#3

Quote:
Originally Posted by Camacorn
Посмотреть сообщение
Hello, can someone help me make this command respawn ONLY empty cars instead of all? thanks.

Код:
	command(vehrespawn, playerid, params[])
	{
		#pragma unused params
		if( Player[playerid][AdminLevel] >= 5)
		{
			for(new i = 0; i < MAX_VEHICLES; i++)
			{
				if(Vehicles[i][GameID] >= 1)
				{
					SetVehicleToRespawn(Vehicles[i][GameID]);
				}
			}

			SendClientMessage( playerid, WHITE, "All saved vehicles have been respawned." );
		}
		return 1;
	}
Honestly, I have answered many of this topics yet. Search and you will find...
Reply
#4

DeathOnAStick, it works, but it keeps reloading the cars over and over and over. They load from a .djson file.
Reply
#5

Quote:
Originally Posted by Camacorn
Посмотреть сообщение
DeathOnAStick, it works, but it keeps reloading the cars over and over and over. They load from a .djson file.
Show me your exact code and I will try to fix it.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)