Respawning Vehs
#1

So I use this to respawn vehicles
Код:
dcmd_respawnvehs(playerid,params[])
{
    #pragma unused params
    #pragma unused playerid
    for(new i=0;i<MAX_VEHICLES;i++)
    {
     	  if(!VehicleOccupied(i))
	  {
       	       SetVehicleToRespawn(i);
       	  }
     }
     SendClientMessageToAll(COLOR_ADMIN, "Administrator has respawned all unoccupied vehicles.");
     return 1;
}
and I use a command to spawn cars
Код:
PlayerInfo[playerid][pSpawnVehicle] = CreateVehicle(VehicleID, pX+5, pY, pZ+2.0, pAngle, ColorOne, ColorTwo, -1)
I want when I use /respawnvehs to respawn unoccupied vehicles + Destroy those spawned ones,Any Ideas ?
Reply
#2

PHP код:
native IsValidVehicle(vehicleid);
// Inside the function
for(new GetPlayerPoolSize(); > -1; --p) {
    if(
IsPlayerConnected(p)) {
        if(
IsValidVehicle(PlayerInfo[p][pSpawnVehicle])) {
            
DestroyVehicle(PlayerInfo[p][pSpawnVehicle]);
        }
    }

Reply
#3

1)can you explain to me why you wrote IsPlayerConnected ?
2)What if a player is riding this spawned one?like i want to make it destroy those vehs if not occupied
Reply
#4

1. If I'm looping through the players, it's good sense that I check if the current id is connected.

2. I may have misinterpreted what you said. I thought you wanted to destroy the spawned vehicles even if they're occupied.

PHP код:
for(new GetPlayerPoolSize(); > -1; --p) { 
    if(
IsPlayerConnected(p)) { 
        if(
IsValidVehicle(PlayerInfo[p][pSpawnVehicle])) {
            if(!
VehicleOccupied(PlayerInfo[p][pSpawnVehicle])) {
                
DestroyVehicle(PlayerInfo[p][pSpawnVehicle]); 
            }
        } 
    } 

Reply
#5

So IsPlayerConnected means the player who spawned the vehicle or what it means ? sorry for my dumbness

EDIT:This didn't help and didn't destroy Spawned Vehicles.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)