Scripting/Squirrel/Functions/Vehicles/RespawnAt

From VC-MP Wiki

Jump to: navigation, search

This function respawns the vehicle and sets its position to the given coordinates. The position will be reset to the original spawn position on next respawn. Note that if the vehicle has players inside while respawning it that may cause a client crash for everyone else but the driver.

Syntax

bool vehicle.RespawnAt( Vector vPos, float angle )

Arguments

  • vPos - This is the position the vehicle after respawning it
  • angle - This will be the z-angle of the vehicle after respawning

Example

This command will change the respawn position of the vehicle to the current player position with '/c spawnat <car id>'.

function onPlayerCommand( player, cmd, text )
{
     if ( cmd == "spawnat" )
     {
          local vehicle = FindVehicle( text.tointeger() );
          vehicle.RespawnAt( player.Pos, player.Angle );
     }
}

Notes

The call onPlayerCommand and functions Player.Pos, Player.Angle, FindVehicle were also used in this example. More info about this in the corresponding page.

Related Functions

Personal tools
squirrel scripting