About some months ago, some people including me were working on a new server called Rob The Vehicles, at the beginning there's a very terrible bug that whenever server teleported players in vehicles, it ejects players in vehicles or sometimes the drivers are even kicked, we were confused about this, soon it was SahiL who came up with this idea and our server is now using this function to teleport players, no matter you're in vehicles or not, you can teleport to the place. Now I'm going to share the codes with you.
1 -> Place a vehicle at a place where nobody could be able to enter it, this vehicle is only used to "eject" players, remember you have got ID of the vehicle.
2 -> Paste the following function in your script, remember that you have to change the ID_OF_THE_SPECIAL_VEHICLE to the ID you created.
Code: [Select]
3 -> Use this function above whenever you need to teleport players, here is a drowning function:
Code: [Select]
1 -> Place a vehicle at a place where nobody could be able to enter it, this vehicle is only used to "eject" players, remember you have got ID of the vehicle.
2 -> Paste the following function in your script, remember that you have to change the ID_OF_THE_SPECIAL_VEHICLE to the ID you created.
function Teleport( player, posx, posy, posz )
{
if ( player.IsSpawned )
{
if ( player.Vehicle ) player.Vehicle = FindVehicle( ID_OF_THE_SPECIAL_VEHICLE );
player.Pos = Vector( posx, posy, posz );
}
}
3 -> Use this function above whenever you need to teleport players, here is a drowning function:
function Drown( player, reason )
{
Message( "Admin server drowned [ " + player.Name + " ] reason:[ " + reason + " ]." );
Teleport( player, -376.6, 47.8846, 10.7041 ); //teleporting the player
}