pub struct Vehicle { /* private fields */ }Implementations§
Source§impl Vehicle
impl Vehicle
pub fn get_handle(&self) -> *const c_void
pub fn new(handle: *const c_void) -> Self
Sourcepub fn create(
modelid: i32,
pos: Vector3,
rotation: f32,
colour1: i32,
colour2: i32,
respawnDelay: i32,
addSiren: bool,
) -> Option<Vehicle>
pub fn create( modelid: i32, pos: Vector3, rotation: f32, colour1: i32, colour2: i32, respawnDelay: i32, addSiren: bool, ) -> Option<Vehicle>
Creates a vehicle in the world.
Sourcepub fn is_streamed_in(&self, player: &Player) -> bool
pub fn is_streamed_in(&self, player: &Player) -> bool
Checks if a vehicle is streamed in for a player.
Sourcepub fn get_z_angle(&self) -> f32
pub fn get_z_angle(&self) -> f32
Get the rotation of a vehicle on the Z axis (yaw).
Sourcepub fn get_rotation_quat(&self) -> Vector4
pub fn get_rotation_quat(&self) -> Vector4
Returns a vehicle’s rotation on all axes as a quaternion.
Sourcepub fn get_distance_from_point(&self, pos: Vector3) -> f32
pub fn get_distance_from_point(&self, pos: Vector3) -> f32
This function can be used to calculate the distance (as a float) between a vehicle and another map coordinate.
Sourcepub fn set_z_angle(&self, angle: f32) -> bool
pub fn set_z_angle(&self, angle: f32) -> bool
Set the Z rotation (yaw) of a vehicle.
Sourcepub fn set_params_for_player(
&self,
player: &Player,
params: VehicleParams,
) -> bool
pub fn set_params_for_player( &self, player: &Player, params: VehicleParams, ) -> bool
Set the parameters of a vehicle for a player.
pub fn use_manual_engine_and_lights() -> bool
pub fn set_params(&self, params: VehicleParams) -> bool
pub fn get_params(&self) -> VehicleParams
Sourcepub fn set_to_respawn(&self)
pub fn set_to_respawn(&self)
Sets a vehicle back to the position at where it was created.
Sourcepub fn link_to_interior(&self, interiorid: i32)
pub fn link_to_interior(&self, interiorid: i32)
Links a vehicle to an interior.
Sourcepub fn add_component(&self, componentid: i32) -> bool
pub fn add_component(&self, componentid: i32) -> bool
Adds a ‘component’ (often referred to as a ‘mod’ (modification)) to a vehicle.
Sourcepub fn remove_component(&self, componentid: i32) -> bool
pub fn remove_component(&self, componentid: i32) -> bool
Remove a component from a vehicle.
Sourcepub fn change_color(&self, colour1: i32, colour2: i32) -> bool
pub fn change_color(&self, colour1: i32, colour2: i32) -> bool
Change a vehicle’s primary and secondary colors.
Sourcepub fn change_paintjob(&self, paintjobid: i32) -> bool
pub fn change_paintjob(&self, paintjobid: i32) -> bool
Change a vehicle’s paintjob.
Sourcepub fn set_health(&self, health: f32)
pub fn set_health(&self, health: f32)
Set a vehicle’s health.
Sourcepub fn get_health(&self) -> f32
pub fn get_health(&self) -> f32
Get the health of a vehicle.
Sourcepub fn attach_trailer(&self, trailer: &Vehicle) -> bool
pub fn attach_trailer(&self, trailer: &Vehicle) -> bool
Attach a vehicle to another vehicle as a trailer.
Sourcepub fn detach_trailer(&self) -> bool
pub fn detach_trailer(&self) -> bool
Detach the connection between a vehicle and its trailer, if any.
Sourcepub fn is_trailer_attached(&self) -> bool
pub fn is_trailer_attached(&self) -> bool
Checks if a vehicle has a trailer attached to it.
Sourcepub fn get_trailer(&self) -> Option<Vehicle>
pub fn get_trailer(&self) -> Option<Vehicle>
Get the ID of the trailer attached to a vehicle.
Sourcepub fn set_number_plate(&self, numberPlate: &str) -> bool
pub fn set_number_plate(&self, numberPlate: &str) -> bool
Set a vehicle numberplate.
Sourcepub fn get_component_in_slot(&self, slot: i32) -> i32
pub fn get_component_in_slot(&self, slot: i32) -> i32
Retrieves the installed component ID (modshop mod(ification)) on a vehicle in a specific slot.
Sourcepub fn get_component_type(componentid: i32) -> i32
pub fn get_component_type(componentid: i32) -> i32
Find out what type of component a certain ID is.
Sourcepub fn can_have_component(modelid: i32, componentid: i32) -> bool
pub fn can_have_component(modelid: i32, componentid: i32) -> bool
Is the component legal on the vehicle?
pub fn get_random_car_col_pair(modelid: i32) -> (i32, i32, i32, i32)
pub fn colour_index_to_colour(colourIndex: i32, alpha: i32) -> i32
Sourcepub fn repair(&self)
pub fn repair(&self)
Fully repairs a vehicle, including visual damage (bumps, dents, scratches, popped tires etc.
Sourcepub fn get_velocity(&self) -> Vector3
pub fn get_velocity(&self) -> Vector3
Get the velocity of a vehicle on the X, Y and Z axes.
Sourcepub fn set_velocity(&self, velocity: Vector3)
pub fn set_velocity(&self, velocity: Vector3)
Sets the X, Y and Z velocity of a vehicle.
Sourcepub fn set_angular_velocity(&self, velocity: Vector3) -> bool
pub fn set_angular_velocity(&self, velocity: Vector3) -> bool
Sets the angular X, Y and Z velocity of a vehicle.
Sourcepub fn get_damage_status(&self) -> VehicleDamageStatusData
pub fn get_damage_status(&self) -> VehicleDamageStatusData
Retrieve the damage statuses of a vehicle.
Sourcepub fn update_damage_status(
&self,
panels: i32,
doors: i32,
lights: i32,
tires: i32,
)
pub fn update_damage_status( &self, panels: i32, doors: i32, lights: i32, tires: i32, )
Sets the various visual damage statuses of a vehicle, such as popped tires, broken lights and damaged panels.
Sourcepub fn get_model_info(model: i32, infotype: i32) -> Vector3
pub fn get_model_info(model: i32, infotype: i32) -> Vector3
Retrieve information about a specific vehicle model such as the size or position of seats.
Sourcepub fn set_virtual_world(&self, virtualWorld: i32) -> bool
pub fn set_virtual_world(&self, virtualWorld: i32) -> bool
Sets the ‘virtual world’ of a vehicle.
Sourcepub fn get_virtual_world(&self) -> i32
pub fn get_virtual_world(&self) -> i32
Get the virtual world of a vehicle.
Sourcepub fn get_landing_gear_state(&self) -> i32
pub fn get_landing_gear_state(&self) -> i32
Gets the current vehicle landing gear state from the latest driver.
Sourcepub fn create_static(
modelid: i32,
spawn: Vector3,
angle: f32,
colour1: i32,
colour2: i32,
respawnDelay: i32,
addSiren: bool,
) -> Option<Vehicle>
pub fn create_static( modelid: i32, spawn: Vector3, angle: f32, colour1: i32, colour2: i32, respawnDelay: i32, addSiren: bool, ) -> Option<Vehicle>
Adds a ‘static’ vehicle (models are pre-loaded for players) to the gamemode.
Sourcepub fn enable_friendly_fire() -> bool
pub fn enable_friendly_fire() -> bool
Enable friendly fire for team vehicles.
Sourcepub fn get_spawn_info(&self) -> VehicleSpawnData
pub fn get_spawn_info(&self) -> VehicleSpawnData
Gets the vehicle spawn location and colours.
Sourcepub fn set_spawn_info(&self, data: VehicleSpawnData) -> bool
pub fn set_spawn_info(&self, data: VehicleSpawnData) -> bool
Adjusts vehicle model, spawn location, colours, respawn delay and interior.
Sourcepub fn get_model_count(modelid: i32) -> i32
pub fn get_model_count(modelid: i32) -> i32
Gets the model count of a vehicle model.
Sourcepub fn get_models_used() -> i32
pub fn get_models_used() -> i32
Get the number of used vehicle models on the server.
Sourcepub fn get_paintjob(&self) -> i32
pub fn get_paintjob(&self) -> i32
Gets the vehicle’s paintjob id.
pub fn get_color(&self) -> (i32, i32)
Sourcepub fn get_interior(&self) -> i32
pub fn get_interior(&self) -> i32
Get the interior id of a vehicle.
Sourcepub fn get_number_plate(&self) -> String
pub fn get_number_plate(&self) -> String
Get the number plate of a vehicle.
Sourcepub fn set_respawn_delay(&self, respawn_delay: i32) -> bool
pub fn set_respawn_delay(&self, respawn_delay: i32) -> bool
Set the respawn delay of a vehicle.
Sourcepub fn get_respawn_delay(&self) -> i32
pub fn get_respawn_delay(&self) -> i32
Get the respawn delay of a vehicle.
Sourcepub fn get_occupied_tick(&self) -> i32
pub fn get_occupied_tick(&self) -> i32
Get the occupied tick of a vehicle.
Sourcepub fn get_respawn_tick(&self) -> i32
pub fn get_respawn_tick(&self) -> i32
Get the respawn tick of a vehicle.
Sourcepub fn has_been_occupied(&self) -> bool
pub fn has_been_occupied(&self) -> bool
Check if a vehicle is occupied.
Sourcepub fn is_occupied(&self) -> bool
pub fn is_occupied(&self) -> bool
Check if a vehicle is occupied.
Sourcepub fn toggle_siren_enabled(&self, status: bool) -> bool
pub fn toggle_siren_enabled(&self, status: bool) -> bool
Turn the siren for a vehicle on or off.
Sourcepub fn is_siren_enabled(&self) -> bool
pub fn is_siren_enabled(&self) -> bool
Checks if a vehicle siren is on or off.
Sourcepub fn get_last_driver(&self) -> Option<Player>
pub fn get_last_driver(&self) -> Option<Player>
Get the last driver of a vehicle.
Sourcepub fn get_driver(&self) -> Option<Player>
pub fn get_driver(&self) -> Option<Player>
Get the playerid of the person driving the vehicle.
Sourcepub fn get_siren_state(&self) -> i32
pub fn get_siren_state(&self) -> i32
Gets the siren state of the vehicle.
Sourcepub fn get_hydra_reactor_angle(&self) -> u32
pub fn get_hydra_reactor_angle(&self) -> u32
Gets the hydra reactor angle of the vehicle.
Sourcepub fn get_train_speed(&self) -> f32
pub fn get_train_speed(&self) -> f32
Gets the speed of the train.
Sourcepub fn get_matrix(&self) -> VehicleMatrix
pub fn get_matrix(&self) -> VehicleMatrix
Gets the actual rotation matrix of the vehicle.