Skip to content

Commit

Permalink
feat(vehicles/stats): update some natives for vehicles stats (#965)
Browse files Browse the repository at this point in the history
* Update GetVehicleAcceleration
* Update GetMakeNameFromVehicleModel
* Update GetVehicleEstimatedMaxSpeed
* Update/Rename GetVehicleModelMoveResistance
  • Loading branch information
spacevx authored Dec 28, 2023
1 parent 8fb95eb commit c30300e
Show file tree
Hide file tree
Showing 5 changed files with 318 additions and 28 deletions.
96 changes: 96 additions & 0 deletions VEHICLE/GetBoatVehicleModelAgility.md
Original file line number Diff line number Diff line change
@@ -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}");
```
87 changes: 82 additions & 5 deletions VEHICLE/GetMakeNameFromVehicleModel.md
Original file line number Diff line number Diff line change
@@ -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}");
```
71 changes: 69 additions & 2 deletions VEHICLE/GetVehicleAcceleration.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
```
72 changes: 71 additions & 1 deletion VEHICLE/GetVehicleEstimatedMaxSpeed.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}");
```
20 changes: 0 additions & 20 deletions VEHICLE/GetVehicleModelMoveResistance.md

This file was deleted.

0 comments on commit c30300e

Please sign in to comment.