diff --git a/omp-gdk/src/scripting/vehicles/mod.rs b/omp-gdk/src/scripting/vehicles/mod.rs index 7353f5c..9e42b7f 100644 --- a/omp-gdk/src/scripting/vehicles/mod.rs +++ b/omp-gdk/src/scripting/vehicles/mod.rs @@ -21,6 +21,7 @@ impl Vehicle { pub fn new(handle: *const c_void) -> Self { Self { handle } } + /// Creates a vehicle in the world. pub fn create( modelid: isize, pos: Vector3, @@ -40,37 +41,47 @@ impl Vehicle { addSiren, ) } + /// Gets the number of seats in the vehicle. pub fn get_seats(modelid: isize) -> isize { functions::GetVehicleSeats(modelid) } + /// Destroy a vehicle. pub fn destroy(&self) { functions::DestroyVehicle(self) } + /// Checks if a vehicle is streamed in for a player. pub fn is_streamed_in(&self, player: &Player) -> bool { functions::IsVehicleStreamedIn(self, player) } + /// Gets the position of a vehicle. pub fn get_pos(&self) -> Vector3 { let mut pos = Vector3::default(); functions::GetVehiclePos(self, &mut pos); pos } + /// Set a vehicle's position. pub fn set_pos(&self, pos: Vector3) { functions::SetVehiclePos(self, pos) } + /// Get the rotation of a vehicle on the Z axis (yaw). pub fn get_z_angle(&self) -> f32 { functions::GetVehicleZAngle(self) } + /// Returns a vehicle's rotation on all axes as a quaternion. pub fn get_rotation_quat(&self) -> Vector4 { let mut rotation = Vector4::default(); functions::GetVehicleRotationQuat(self, &mut rotation); rotation } + /// This function can be used to calculate the distance (as a float) between a vehicle and another map coordinate. pub fn get_distance_from_point(&self, pos: Vector3) -> f32 { functions::GetVehicleDistanceFromPoint(self, pos) } + /// Set the Z rotation (yaw) of a vehicle. pub fn set_z_angle(&self, angle: f32) { functions::SetVehicleZAngle(self, angle) } + /// Set the parameters of a vehicle for a player. pub fn set_params_for_player(&self, player: &Player, params: VehicleParams) { functions::SetVehicleParamsForPlayer(self, player, params) } @@ -85,54 +96,71 @@ impl Vehicle { functions::GetVehicleParams(self, &mut params); params } + /// Sets a vehicle back to the position at where it was created. pub fn set_to_respawn(&self) { functions::SetVehicleToRespawn(self) } + /// Links a vehicle to an interior. pub fn link_to_interior(&self, interiorid: isize) { functions::LinkVehicleToInterior(self, interiorid) } + /// Adds a 'component' (often referred to as a 'mod' (modification)) to a vehicle. pub fn add_component(&self, componentid: isize) { functions::AddVehicleComponent(self, componentid) } + /// Remove a component from a vehicle. pub fn remove_component(&self, componentid: isize) { functions::RemoveVehicleComponent(self, componentid) } + /// Change a vehicle's primary and secondary colors. pub fn change_color(&self, colour1: isize, colour2: isize) { functions::ChangeVehicleColor(self, colour1, colour2) } + /// Change a vehicle's paintjob. pub fn change_paintjob(&self, paintjobid: isize) { functions::ChangeVehiclePaintjob(self, paintjobid) } + /// Set a vehicle's health. pub fn set_health(&self, health: f32) { functions::SetVehicleHealth(self, health) } + /// Get the health of a vehicle. pub fn get_health(&self) -> f32 { functions::GetVehicleHealth(self) } + /// Attach a vehicle to another vehicle as a trailer. pub fn attach_trailer(&self, trailer: &Vehicle) { functions::AttachTrailerToVehicle(self, trailer) } + /// Detach the connection between a vehicle and its trailer, if any. pub fn detach_trailer(&self) { functions::DetachTrailerFromVehicle(self) } + /// Checks if a vehicle has a trailer attached to it. pub fn is_trailer_attached(&self) -> bool { functions::IsTrailerAttachedToVehicle(self) } + /// Get the ID of the trailer attached to a vehicle. pub fn get_trailer(&self) -> Option { functions::GetVehicleTrailer(self) } + /// Set a vehicle numberplate. pub fn set_number_plate(&self, numberPlate: &str) { functions::SetVehicleNumberPlate(self, numberPlate) } + /// Gets the model ID of a vehicle. pub fn get_model(&self) -> isize { functions::GetVehicleModel(self) } + /// Retrieves the installed component ID (modshop mod(ification)) on a vehicle in a specific slot. pub fn get_component_in_slot(&self, slot: isize) -> isize { functions::GetVehicleComponentInSlot(self, slot) } + /// Find out what type of component a certain ID is. pub fn get_component_type(componentid: isize) -> isize { functions::GetVehicleComponentType(componentid) } + /// Is the component legal on the vehicle? pub fn can_have_component(modelid: isize, componentid: isize) -> bool { functions::VehicleCanHaveComponent(modelid, componentid) } @@ -150,20 +178,25 @@ impl Vehicle { pub fn car_col_index_to_colour(colourIndex: isize, alpha: isize) -> isize { functions::CarColIndexToColour(colourIndex, alpha) } + /// Fully repairs a vehicle, including visual damage (bumps, dents, scratches, popped tires etc. pub fn repair(&self) { functions::RepairVehicle(self) } + /// Get the velocity of a vehicle on the X, Y and Z axes. pub fn get_velocity(&self) -> Vector3 { let mut velocity = Vector3::default(); functions::GetVehicleVelocity(self, &mut velocity); velocity } + /// Sets the X, Y and Z velocity of a vehicle. pub fn set_velocity(&self, velocity: Vector3) { functions::SetVehicleVelocity(self, velocity) } + /// Sets the angular X, Y and Z velocity of a vehicle. pub fn set_angular_velocity(&self, velocity: Vector3) { functions::SetVehicleAngularVelocity(self, velocity) } + /// Retrieve the damage statuses of a vehicle. pub fn get_damage_status(&self) -> VehicleDamageStatusData { let (mut panels, mut doors, mut lights, mut tires) = Default::default(); @@ -176,23 +209,29 @@ impl Vehicle { tires, } } + /// Sets the various visual damage statuses of a vehicle, such as popped tires, broken lights and damaged panels. pub fn update_damage_status(&self, panels: isize, doors: isize, lights: isize, tires: isize) { functions::UpdateVehicleDamageStatus(self, panels, doors, lights, tires) } + /// Retrieve information about a specific vehicle model such as the size or position of seats. pub fn get_model_info(model: isize, infotype: isize) -> Vector3 { let mut pos = Vector3::default(); functions::GetVehicleModelInfo(model, infotype, &mut pos); pos } + /// Sets the 'virtual world' of a vehicle. pub fn set_virtual_world(&self, virtualWorld: isize) { functions::SetVehicleVirtualWorld(self, virtualWorld) } + /// Get the virtual world of a vehicle. pub fn get_virtual_world(&self) -> isize { functions::GetVehicleVirtualWorld(self) } + /// Gets the current vehicle landing gear state from the latest driver. pub fn get_landing_gear_state(&self) -> isize { functions::GetVehicleLandingGearState(self) } + /// Adds a 'static' vehicle (models are pre-loaded for players) to the gamemode. pub fn create_static( modelid: isize, spawn: Vector3, @@ -212,9 +251,11 @@ impl Vehicle { addSiren, ) } + /// Enable friendly fire for team vehicles. pub fn enable_friendly_fire(set: bool) { functions::EnableVehicleFriendlyFire(set) } + /// Gets the vehicle spawn location and colours. pub fn get_spawn_info(&self) -> VehicleSpawnData { let ( mut position, @@ -250,6 +291,7 @@ impl Vehicle { interior, } } + /// Adjusts vehicle model, spawn location, colours, respawn delay and interior. pub fn set_spawn_info(&self, data: VehicleSpawnData) { functions::SetVehicleSpawnInfo( self, @@ -262,12 +304,15 @@ impl Vehicle { data.interior, ) } + /// Gets the model count of a vehicle model. pub fn get_model_count(modelid: isize) -> isize { functions::GetVehicleModelCount(modelid) } + /// Get the number of used vehicle models on the server. pub fn get_models_used() -> isize { functions::GetVehicleModelsUsed() } + /// Gets the vehicle's paintjob id. pub fn get_paintjob(&self) -> isize { functions::GetVehiclePaintjob(self) } @@ -277,60 +322,78 @@ impl Vehicle { functions::GetVehicleColor(self, &mut colour1, &mut colour2); (colour1, colour2) } + /// Get the interior id of a vehicle. pub fn get_interior(&self) -> isize { functions::GetVehicleInterior(self) } + /// Get the number plate of a vehicle. pub fn get_number_plate(&self) -> String { let mut number_plate = String::new(); functions::GetVehicleNumberPlate(self, &mut number_plate); number_plate } + /// Set the respawn delay of a vehicle. pub fn set_respawn_delay(&self, respawn_delay: isize) { functions::SetVehicleRespawnDelay(self, respawn_delay) } + /// Get the respawn delay of a vehicle. pub fn get_respawn_delay(&self) -> isize { functions::GetVehicleRespawnDelay(self) } + /// Get the ID of the cab attached to a vehicle. pub fn get_cab(&self) -> Option { functions::GetVehicleCab(self) } + /// Get the occupied tick of a vehicle. pub fn get_occupied_tick(&self) -> isize { functions::GetVehicleOccupiedTick(self) } + /// Get the respawn tick of a vehicle. pub fn get_respawn_tick(&self) -> isize { functions::GetVehicleRespawnTick(self) } + /// Check if a vehicle is occupied. pub fn has_been_occupied(&self) -> bool { functions::HasVehicleBeenOccupied(self) } + /// Check if a vehicle is occupied. pub fn is_occupied(&self) -> bool { functions::IsVehicleOccupied(self) } + /// Check if a vehicle is dead. pub fn is_dead(&self) -> bool { functions::IsVehicleDead(self) } + /// Turn the siren for a vehicle on or off. pub fn toggle_siren_enabled(&self, status: bool) { functions::ToggleVehicleSirenEnabled(self, status) } + /// Checks if a vehicle siren is on or off. pub fn is_siren_enabled(&self) -> bool { functions::IsVehicleSirenEnabled(self) } + /// Get the last driver of a vehicle. pub fn get_last_driver(&self) -> isize { functions::GetVehicleLastDriver(self) } + /// Get the playerid of the person driving the vehicle. pub fn get_driver(&self) -> Option { functions::GetVehicleDriver(self) } + /// Gets the siren state of the vehicle. pub fn get_siren_state(&self) -> isize { functions::GetVehicleSirenState(self) } + /// Gets the hydra reactor angle of the vehicle. pub fn get_hydra_reactor_angle(&self) -> isize { functions::GetVehicleHydraReactorAngle(self) } + /// Gets the speed of the train. pub fn get_train_speed(&self) -> f32 { functions::GetVehicleTrainSpeed(self) } + /// Gets the actual rotation matrix of the vehicle. pub fn get_matrix(&self) -> VehicleMatrix { let (mut right, mut up, mut at) = Default::default();