Want to improve the docs? Take a look at scripting-api-data!
Found a bug? jc3mp/bugs is a good place to let us know.
Vehicle
new Vehicle(number modelHash, Vector3f position, Vector3f rotation)
var vehicle = new Vehicle(28454791, new Vector3f(), new Vector3f());
Name | Type | Description |
---|---|---|
driver | Player | the player driving the vehicle |
position | Vector3f | the Vehicle's position in the game world |
rotation | Vector3f | the vehicles rotation |
networkId | number | read only the network id of this entity. It is not unique across different entities and will be re-assigned once this entity was destroyed |
destroyed | boolean | read only is the vehicle is destroyed or not (read-only) |
nitroEnabled | boolean | whether the vehicle is equipped with bavarium nitro |
turboJumpEnabled | boolean | whether the vehicle is equipped with the bavarium jump modification |
primaryColor | number | the vehicles color ID |
linearVelocity | Vector3f | the vehicles positional speed |
angularVelocity | Vector3f | the vehicles rotational speed |
aimPostion | Vector3f | |
health | number | the vehicles health |
modelHash | number | read only model hash of the Vehicle (TODO: reference to all hashes) |
handling | VehicleHandling | read only |
dimension | number | world dimension of the Vehicle. |
Fully repairs the given vehicle
jcmp.events.Add('VehicleDestroyed', vehicle => {
vehicle.Repair();
});
Respawns the vehicle at its initial spawning position
jcmp.events.Add('VehicleDestroyed', vehicle => {
vehicle.Respawn();
});
Get the occupant of a vehicle seat
returns: Player or undefined
Name | Type | Description |
---|---|---|
seat | number | the vehicles seat |
jcmp.events.Add('PlayerExitVehicle', (player, vehicle) => {
if (vehicle.GetOccupant(0)) {
console.log('There is still a driver in the vehicle.');
}
});
Set the occupant of the given vehicle.
Note: if the player is not in the vicinity of the vehicle, he will first be teleported there automatically (slightly above the vehicle in the air).
Name | Type | Description |
---|---|---|
seat | number | the vehicles seat |
player | Player | the player entity |
jcmp.events.Add('PlayerReady', player => {
var vehicle = new Vehicle(28454791, player.position, player.rotation); //Spawn the vehicle at the players position
vehicle.SetOccupant(0, player); //Assign the player to the driver seat
});
Destroys the Vehicle
By becoming the newest member of our growing forums, we and hundreds of other players will always keep you up to date on everything JC3:MP related.