-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(extra-natives/five): GET_VEHICLE_GEAR_RATIO and SET_VEHICLE_GEAR…
…_RATIO
- Loading branch information
Showing
3 changed files
with
131 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
--- | ||
ns: CFX | ||
apiset: client | ||
--- | ||
## GET_VEHICLE_GEAR_RATIO | ||
|
||
```c | ||
float GET_VEHICLE_GEAR_RATIO(Vehicle vehicle, int gear); | ||
``` | ||
Gets vehicles gear ratio on choosen gear. | ||
## Parameters | ||
* **vehicle**: The vehicle handle. | ||
* **gear**: The vehicles gear you want to get. | ||
## Examples | ||
```lua | ||
local Vehicle = GetVehiclePedIsIn(PlayerPedId(-1)) | ||
local currentGear = GetVehicleCurrentGear(Vehicle) | ||
print(GetVehicleGearRatio(Vehicle, currentGear)) -- will print current vehicle gear to console | ||
``` | ||
|
||
```js | ||
const Vehicle = GetVehiclePedIsIn(PlayerPedId(-1)); | ||
const currentGear = GetVehicleCurrentGear(Vehicle); | ||
|
||
console.log(GetVehicleGearRatio(Vehicle, currentGear)); // will print current vehicle gear to console | ||
``` | ||
|
||
```cs | ||
using static CitizenFX.Core.API; | ||
|
||
Vehicle veh = Game.PlayerPed.CurrentVehicle; | ||
int currentGear = GetVehicleCurrentGear(veh.Handle); | ||
|
||
Debug.WriteLine($"{GetVehicleGearRatio(veh.Handle, currentGear)}"); | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
--- | ||
ns: CFX | ||
apiset: client | ||
--- | ||
## SET_VEHICLE_GEAR_RATIO | ||
|
||
```c | ||
void SET_VEHICLE_GEAR_RATIO(Vehicle vehicle, int gear, float ratio); | ||
``` | ||
Sets the vehicles gear ratio on choosen gear, reverse gear needs to be a negative float and forward moving gear needs to be a positive float. Refer to the examples if confused. | ||
## Parameters | ||
* **vehicle**: The vehicle handle. | ||
* **gear**: The vehicles gear you want to change. | ||
* **ratio**: The gear ratio you want to use. | ||
## Examples | ||
```lua | ||
local function Set8SpeedVehicleGears(Vehicle) | ||
SetVehicleGearRatio(Vehicle, 0, -3.32) -- reverse gear at -3.21:1 | ||
SetVehicleGearRatio(Vehicle, 1, 4.71) -- 1st gear at 4.71:1 | ||
SetVehicleGearRatio(Vehicle, 2, 3.14) -- 2nd gear at 3.14:1 | ||
SetVehicleGearRatio(Vehicle, 3, 2.11) -- 3rd gear at 2.11:1 | ||
SetVehicleGearRatio(Vehicle, 4, 1.67) -- 4th gear at 1.67:1 | ||
SetVehicleGearRatio(Vehicle, 5, 1.29) -- 5th gear at 1.29:1 | ||
SetVehicleGearRatio(Vehicle, 6, 1.0) -- 6th gear at 1.0:1 | ||
SetVehicleGearRatio(Vehicle, 7, 0.84) -- 7th gear at 0.84:1 | ||
SetVehicleGearRatio(Vehicle, 8, 0.67) -- 8th gear at 0.67:1 | ||
return | ||
end | ||
``` | ||
|
||
```js | ||
function Set8SpeedVehicleGears(Vehicle) { | ||
SetVehicleGearRatio(Vehicle, 0, -3.32); // reverse gear at -3.21:1 | ||
SetVehicleGearRatio(Vehicle, 1, 4.71); // 1st gear at 4.71:1 | ||
SetVehicleGearRatio(Vehicle, 2, 3.14); // 2nd gear at 3.14:1 | ||
SetVehicleGearRatio(Vehicle, 3, 2.11); // 3rd gear at 2.11:1 | ||
SetVehicleGearRatio(Vehicle, 4, 1.67); // 4th gear at 1.67:1 | ||
SetVehicleGearRatio(Vehicle, 5, 1.29); // 5th gear at 1.29:1 | ||
SetVehicleGearRatio(Vehicle, 6, 1.0); // 6th gear at 1.0:1 | ||
SetVehicleGearRatio(Vehicle, 7, 0.84); // 7th gear at 0.84:1 | ||
SetVehicleGearRatio(Vehicle, 8, 0.67); // 8th gear at 0.67:1 | ||
return; | ||
} | ||
``` | ||
|
||
```cs | ||
using static CitizenFX.Core.API; | ||
|
||
public static void Set8SpeedVehicleGears(int Vehicle) | ||
{ | ||
SetVehicleGearRatio(Vehicle, 0, -3.32); // reverse gear at -3.21:1 | ||
SetVehicleGearRatio(Vehicle, 1, 4.71); // 1st gear at 4.71:1 | ||
SetVehicleGearRatio(Vehicle, 2, 3.14); // 2nd gear at 3.14:1 | ||
SetVehicleGearRatio(Vehicle, 3, 2.11); // 3rd gear at 2.11:1 | ||
SetVehicleGearRatio(Vehicle, 4, 1.67); // 4th gear at 1.67:1 | ||
SetVehicleGearRatio(Vehicle, 5, 1.29); // 5th gear at 1.29:1 | ||
SetVehicleGearRatio(Vehicle, 6, 1.0); // 6th gear at 1.0:1 | ||
SetVehicleGearRatio(Vehicle, 7, 0.84); // 7th gear at 0.84:1 | ||
SetVehicleGearRatio(Vehicle, 8, 0.67); // 8th gear at 0.67:1 | ||
return; | ||
} | ||
``` |