Vehicle auto respawn with SetTimer?
#1

I haven't figured out how to make all server vehicles respawn with SetTimer and function?
Can anyone here explain ?
Reply
#2

pawn Код:
// Somewhere, like in a command
SetTimer( "RespawnVehicles", 5000, false ); // Change '5000' to make a different delay

// After main( )
forward RespawnVehicles( );
public RespawnVehicles( )
{
   for( new i = 0; i < MAX_VEHICLES; i ++ )
   {
      SetVehicleToRespawn( i );
   }
}
Reply
#3

Thank you =).
Reply
#4

Well it is working, anyhow...
I don't want the car you're using to respawn if you're in it, as they do. Is it possible to only make the cars respawn if they are empty and moved out of spawn point?
Reply
#5

Just check if a player is in the current vehicle before respawning it.
Reply
#6

Sorry but I don't understand. Do you mean via command nor function?
Reply
#7

pawn Код:
// Somewhere, like in a command
SetTimer( "RespawnVehicles", 5000, false ); // Change '5000' to make a different delay

// After main( )
forward RespawnVehicles( );
public RespawnVehicles( )
{
   for( new i = 0; i < MAX_VEHICLES; i ++ )
   {
      if(!IsPlayerInAnyVehicle(i))
    {
      SetVehicleToRespawn( i );
}
   }
}
Reply
#8

blackwave, that code will not work, the following is what you are looking for (still untested)
pawn Код:
// Somewhere, like in a command
SetTimer( "RespawnVehicles", 5000, false ); // Change '5000' to make a different delay

// After main( )
forward RespawnVehicles( );
public RespawnVehicles( )
{
   new vehicles[ MAX_VEHICLES ];
   for( new i = 0; i < MAX_PLAYERS; i ++ )
   {
      if( IsPlayerInAnyVehicle( i ) )
      {
         vehicles[ GetPlayerVehicleID( i ) ] = 1;
      }
   }

   for( new v = 0; v < MAX_VEHICLES; v ++ )
   {
      if( vehicles[ v ] == 1 ) continue;
      SetVehicleToRespawn( v );
   }
   return 1;
}
I can't think of a better way at approaching this at the time.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)