From c30300e2f815e977e26f985f9831b48753518990 Mon Sep 17 00:00:00 2001 From: Space V <40030799+ahcenezdh@users.noreply.github.com> Date: Thu, 28 Dec 2023 12:27:45 +0100 Subject: [PATCH] feat(vehicles/stats): update some natives for vehicles stats (#965) * Update GetVehicleAcceleration * Update GetMakeNameFromVehicleModel * Update GetVehicleEstimatedMaxSpeed * Update/Rename GetVehicleModelMoveResistance --- VEHICLE/GetBoatVehicleModelAgility.md | 96 ++++++++++++++++++++++++ VEHICLE/GetMakeNameFromVehicleModel.md | 87 +++++++++++++++++++-- VEHICLE/GetVehicleAcceleration.md | 71 +++++++++++++++++- VEHICLE/GetVehicleEstimatedMaxSpeed.md | 72 +++++++++++++++++- VEHICLE/GetVehicleModelMoveResistance.md | 20 ----- 5 files changed, 318 insertions(+), 28 deletions(-) create mode 100644 VEHICLE/GetBoatVehicleModelAgility.md delete mode 100644 VEHICLE/GetVehicleModelMoveResistance.md diff --git a/VEHICLE/GetBoatVehicleModelAgility.md b/VEHICLE/GetBoatVehicleModelAgility.md new file mode 100644 index 000000000..db1118d66 --- /dev/null +++ b/VEHICLE/GetBoatVehicleModelAgility.md @@ -0,0 +1,96 @@ +--- +ns: VEHICLE +aliases: ["0x5AA3F878A178C4FC", "_GET_VEHICLE_MODEL_MOVE_RESISTANCE"] +--- +## GET_BOAT_VEHICLE_MODEL_AGILITY + +```c +// 0x5AA3F878A178C4FC 0x87C5D271 +float GET_BOAT_VEHICLE_MODEL_AGILITY(Hash modelHash); +``` + +Retrieves the agility for a specific boat model, including any vehicle mods. Unlike other vehicles where Rockstar Games typically assess performance based on traction, boats use agility as a measure. This static value is distinct from the traction metrics used for other vehicle types. + +``` +NativeDB Introduced: v323 +``` + +## Parameters +* **modelHash**: The model hash of the boat. + +## Return value +Returns the agility value of the specified boat as a float number. + +## Examples +```lua +-- This example prints the agility of the player's current boat. + +-- Retrieve the player ped. +local playerPed = PlayerPedId() + +-- Retrieve the vehicle the player is currently in. +local vehicle = GetVehiclePedIsIn(playerPed, false) + +-- Retrieve the model hash of the boat. +local boatHash = GetEntityModel(vehicle) + +-- If the vehicle does not exist or is not a boat, end the execution of the code here. +if not DoesEntityExist(vehicle) or not IsThisModelABoat(boatHash) then + return +end + +-- Retrieve the agility of the boat. +local agility = GetBoatVehicleModelAgility(boatHash) + +-- Print the agility of the boat. +print("Boat Agility: " .. agility) +``` + +```js +// This example prints the agility of the player's current boat. + +// Retrieve the player ped. +const playerPed = PlayerPedId(); + +// Retrieve the vehicle the player is currently in. +const vehicle = GetVehiclePedIsIn(playerPed, false); + +// Retrieve the model hash of the boat. +const boatHash = GetEntityModel(vehicle); + +// If the vehicle does not exist or is not a boat, end the execution of the code here. +if (!DoesEntityExist(vehicle) || !IsThisModelABoat(boatHash)) { + return; +} + +// Retrieve the agility of the boat. +const agility = GetBoatVehicleModelAgility(boatHash); + +// Print the agility of the boat. +console.log(`Boat Agility: ${agility}`); +``` + +```cs +// This example prints the agility of the player's current boat. +using static CitizenFX.Core.Native.API; + +// Retrieve the player ped. +Ped playerPed = PlayerPedId(); + +// Retrieve the vehicle the player is currently in. +Vehicle vehicle = GetVehiclePedIsIn(playerPed, false); + +// Retrieve the model hash of the boat. +uint boatHash = GetEntityModel(vehicle); + +// If the vehicle does not exist or is not a boat, end the execution of the code here. +if (!DoesEntityExist(vehicle) || !IsThisModelABoat(boatHash)) { + return; +} + +// Retrieve the agility of the boat. +const float agility = GetBoatVehicleModelAgility(boatHash); + +// Print the agility of the boat. +Debug.WriteLine($"Boat Agility: {agility}"); +``` \ No newline at end of file diff --git a/VEHICLE/GetMakeNameFromVehicleModel.md b/VEHICLE/GetMakeNameFromVehicleModel.md index e9b8fd2ab..ef79f7145 100644 --- a/VEHICLE/GetMakeNameFromVehicleModel.md +++ b/VEHICLE/GetMakeNameFromVehicleModel.md @@ -1,19 +1,96 @@ --- ns: VEHICLE +aliases: ["_GET_MAKE_NAME_FROM_VEHICLE_MODEL"] --- -## _GET_MAKE_NAME_FROM_VEHICLE_MODEL +## GET_MAKE_NAME_FROM_VEHICLE_MODEL ```c // 0xF7AF4F159FF99F97 -char* _GET_MAKE_NAME_FROM_VEHICLE_MODEL(Hash modelHash); +char* GET_MAKE_NAME_FROM_VEHICLE_MODEL(Hash modelHash); ``` -Will return a vehicle's manufacturer display label. -Returns "CARNOTFOUND" if the hash doesn't match a vehicle hash. +Retrieves the manufacturer's name for a specified vehicle. ``` NativeDB Introduced: v1868 ``` ## Parameters -* **modelHash**: +* **modelHash**: The model hash of the vehicle. + +## Return value +Returns the display label of the manufacturer if the vehicle model is recognized, or "CARNOTFOUND" if the hash does not correspond to any known vehicle model. + +## Examples +```lua +-- This example prints the manufacturer of the player's current vehicle. + +-- Retrieve the player ped. +local playerPed = PlayerPedId() + +-- Retrieve the vehicle the player is currently in. +local vehicle = GetVehiclePedIsIn(playerPed, false) + +-- If the vehicle does not exist, end the execution of the code here. +if not DoesEntityExist(vehicle) then + return +end + +-- Retrieve the model hash of the vehicle. +local vehicleHash = GetEntityModel(vehicle) + +-- Retrieve the manufacturer of the vehicle. +local manufacturer = GetMakeNameFromVehicleModel(vehicleHash) + +-- Print the manufacturer of the vehicle. +print("Vehicle Manufacturer: " .. manufacturer) +``` + +```js +// This example prints the manufacturer of the player's current vehicle. + +// Retrieve the player ped. +const playerPed = PlayerPedId(); + +// Retrieve the vehicle the player is currently in. +const vehicle = GetVehiclePedIsIn(playerPed, false); + +// If the vehicle does not exist, end the execution of the code here. +if (!DoesEntityExist(vehicle)) { + return; +} + +// Retrieve the model hash of the vehicle. +const vehicleHash = GetEntityModel(vehicle); + +// Retrieve the manufacturer of the vehicle. +const manufacturer = GetMakeNameFromVehicleModel(vehicleHash); + +// Print the manufacturer of the vehicle. +console.log(`Vehicle Manufacturer: ${manufacturer}`); +``` + +```cs +// This example prints the manufacturer of the player's current vehicle. +using static CitizenFX.Core.Native.API; + +// Retrieve the player ped. +Ped playerPed = PlayerPedId(); + +// Retrieve the vehicle the player is currently in. +Vehicle vehicle = GetVehiclePedIsIn(playerPed, false); + +// If the vehicle does not exist, end the execution of the code here. +if (!DoesEntityExist(vehicle)) { + return; +} + +// Retrieve the model hash of the vehicle. +uint vehicleHash = (uint)GetEntityModel(vehicle); + +// Retrieve the manufacturer of the vehicle. +string manufacturer = GetMakeNameFromVehicleModel(vehicleHash); + +// Print the manufacturer of the vehicle. +Debug.WriteLine($"Vehicle Manufacturer: {manufacturer}"); +``` \ No newline at end of file diff --git a/VEHICLE/GetVehicleAcceleration.md b/VEHICLE/GetVehicleAcceleration.md index 857dfb672..a5f5ea609 100644 --- a/VEHICLE/GetVehicleAcceleration.md +++ b/VEHICLE/GetVehicleAcceleration.md @@ -7,12 +7,79 @@ ns: VEHICLE // 0x5DD35C8D074E57AE 0x00478321 float GET_VEHICLE_ACCELERATION(Vehicle vehicle); ``` +Retrieves a static value representing the maximum drive force of specific a vehicle, including any vehicle mods. This value does not change dynamically during gameplay. This value provides an approximation and should be considered alongside other performance metrics like top speed for a more comprehensive understanding of the vehicle's capabilities. ``` -static - max acceleration +NativeDB Introduced: v323 ``` ## Parameters -* **vehicle**: +* **vehicle**: The vehicle for which to obtain the acceleration. ## Return value +Returns the acceleration value of the specified vehicle as a float number. + +## Examples +```lua +-- This example prints the acceleration of the player's current vehicle. + +-- Retrieve the player ped. +local playerPed = PlayerPedId() + +-- Retrieve the vehicle the player is currently in. +local vehicle = GetVehiclePedIsIn(playerPed, false) + +-- If the vehicle does not exist, end the execution of the code here. +if not DoesEntityExist(vehicle) then + return +end + +-- Retrieve the acceleration of the vehicle. +local acceleration = GetVehicleAcceleration(vehicle) + +-- Print the acceleration of the vehicle. +print("Vehicle Acceleration: " .. acceleration) +``` + +```js +// This example prints the acceleration of the player's current vehicle. + +// Retrieve the player ped. +const playerPed = PlayerPedId(); + +// Retrieve the vehicle the player is currently in. +const vehicle = GetVehiclePedIsIn(playerPed, false); + +// If the vehicle does not exist, end the execution of the code here. +if (!DoesEntityExist(vehicle)) { + return; +} + +// Retrieve the acceleration of the vehicle. +const acceleration = GetVehicleAcceleration(vehicle); + +// Print the acceleration of the vehicle. +console.log(`Vehicle Acceleration: ${acceleration}`); +``` + +```cs +// This example prints the acceleration of the player's current vehicle. +using static CitizenFX.Core.Native.API; + +// Retrieve the player ped. +Ped playerPed = PlayerPedId(); + +// Retrieve the vehicle the player is currently in. +Vehicle vehicle = GetVehiclePedIsIn(playerPed, false); + +// If the vehicle does not exist, end the execution of the code here. +if (!DoesEntityExist(vehicle)) { + return; +} + +// Retrieve the acceleration of the vehicle. +const float acceleration = GetVehicleAcceleration(vehicle); + +// Print the acceleration of the vehicle. +Debug.WriteLine($"Vehicle Acceleration: {acceleration}"); +``` \ No newline at end of file diff --git a/VEHICLE/GetVehicleEstimatedMaxSpeed.md b/VEHICLE/GetVehicleEstimatedMaxSpeed.md index ef6c0e5e9..d874fafce 100644 --- a/VEHICLE/GetVehicleEstimatedMaxSpeed.md +++ b/VEHICLE/GetVehicleEstimatedMaxSpeed.md @@ -8,9 +8,79 @@ aliases: ["0x53AF99BAA671CA47","_GET_VEHICLE_MAX_SPEED"] // 0x53AF99BAA671CA47 0x7D1A0616 float GET_VEHICLE_ESTIMATED_MAX_SPEED(Vehicle vehicle); ``` +Retrieves a static value representing the estimated max speed of a specific vehicle, including any vehicle mods. This value does not change dynamically during gameplay. +``` +NativeDB Introduced: v323 +``` ## Parameters -* **vehicle**: +* **vehicle**: The vehicle for which to obtain the estimated max speed. ## Return value +Returns the estimated maximum speed of the specified vehicle as a float number. + +## Examples +```lua +-- This example prints the estimated max speed of the player's current vehicle. + +-- Retrieve the player ped. +local playerPed = PlayerPedId() + +-- Retrieve the vehicle the player is currently in. +local vehicle = GetVehiclePedIsIn(playerPed, false) + +-- If the vehicle does not exist, end the execution of the code here. +if not DoesEntityExist(vehicle) then + return +end + +-- Retrieve the estimated max speed of the vehicle. +local estimatedMaxSpeed = GetVehicleEstimatedMaxSpeed(vehicle) + +-- Print the estimated max speed of the vehicle. +print("Estimated Max Speed: " .. estimatedMaxSpeed) +``` + +```js +// This example prints the estimated max speed of the player's current vehicle. + +// Retrieve the player ped. +const playerPed = PlayerPedId(); + +// Retrieve the vehicle the player is currently in. +const vehicle = GetVehiclePedIsIn(playerPed, false); + +// If the vehicle does not exist, end the execution of the code here. +if (!DoesEntityExist(vehicle)) { + return; +} + +// Retrieve the estimated max speed of the vehicle. +const estimatedMaxSpeed = GetVehicleEstimatedMaxSpeed(vehicle); + +// Print the estimated max speed of the vehicle. +console.log(`Estimated Max Speed: ${estimatedMaxSpeed}`); +``` + +```cs +// This example prints the estimated max speed of the player's current vehicle. +using static CitizenFX.Core.Native.API; + +// Retrieve the player ped. +Ped playerPed = PlayerPedId(); + +// Retrieve the vehicle the player is currently in. +Vehicle vehicle = GetVehiclePedIsIn(playerPed, false); + +// If the vehicle does not exist, end the execution of the code here. +if (!DoesEntityExist(vehicle)) { + return; +} + +// Retrieve the estimated max speed of the vehicle. +const float estimatedMaxSpeed = GetVehicleEstimatedMaxSpeed(vehicle); + +// Print the estimated max speed of the vehicle. +Debug.WriteLine($"Estimated Max Speed: {estimatedMaxSpeed}"); +``` \ No newline at end of file diff --git a/VEHICLE/GetVehicleModelMoveResistance.md b/VEHICLE/GetVehicleModelMoveResistance.md deleted file mode 100644 index 03be33fa9..000000000 --- a/VEHICLE/GetVehicleModelMoveResistance.md +++ /dev/null @@ -1,20 +0,0 @@ ---- -ns: VEHICLE -aliases: ["0x5AA3F878A178C4FC"] ---- -## _GET_VEHICLE_MODEL_MOVE_RESISTANCE - -```c -// 0x5AA3F878A178C4FC 0x87C5D271 -float _GET_VEHICLE_MODEL_MOVE_RESISTANCE(Hash modelHash); -``` - -``` -GET_VEHICLE_MODEL_* -called if the vehicle is a boat -- returns vecMoveResistanceX? -``` - -## Parameters -* **modelHash**: - -## Return value