-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
64 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
-- Config | ||
local nitrousChargeTime = 10 -- Time in seconds it takes to fully charge the nitrous tank | ||
local nitrousBoostTime = 5 -- Time in seconds the nitrous boost lasts | ||
local nitrousPowerMultiplier = 2.0 -- Multiplier for vehicle speed during nitrous boost | ||
|
||
|
||
function chargeNitrousTank(vehicle) | ||
Citizen.CreateThread(function() | ||
SetVehicleEngineOn(vehicle, false, true, false) | ||
local nitrousChargeSound = GetSoundId() | ||
PlaySoundFromEntity(nitrousChargeSound, "NITRO_BUTTON_PRESS", vehicle, "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS", true, 0) | ||
local startTime = GetGameTimer() | ||
local endTime = startTime + (nitrousChargeTime * 1000) | ||
while GetGameTimer() < endTime do Citizen.Wait(0) end | ||
StopSound(nitrousChargeSound) | ||
SetVehicleEngineOn(vehicle, true, true, false) | ||
end) | ||
end | ||
|
||
function activateNitrousBoost(vehicle) | ||
Citizen.CreateThread(function() | ||
local nitrousBoostSound = GetSoundId() | ||
PlaySoundFromEntity(nitrousBoostSound, "NITRO_BOOST_ON", vehicle, "DLC_HEISTS_GENERAL_FRONTEND_SOUNDS", true, 0) | ||
SetVehicleBoostActive(vehicle, true) | ||
SetVehicleForwardSpeed(vehicle, | ||
GetEntitySpeed(vehicle) * nitrousPowerMultiplier) | ||
local startTime = GetGameTimer() | ||
local endTime = startTime + (nitrousBoostTime * 1000) | ||
while GetGameTimer() < endTime do Citizen.Wait(0) end | ||
StopSound(nitrousBoostSound) | ||
SetVehicleBoostActive(vehicle, false) | ||
end) | ||
end | ||
|
||
function handleNitrousKeyPress(vehicle, nitrousKey) | ||
Citizen.CreateThread(function() | ||
if DoesVehicleHaveNitrous(vehicle) then | ||
if IsVehicleNitroActive(vehicle, 0) then | ||
activateNitrousBoost(vehicle) | ||
else | ||
chargeNitrousTank(vehicle) | ||
end | ||
end | ||
end) | ||
end | ||
|
||
AddEventHandler("playerEnteredVehicle", function(vehicle, seat) | ||
if seat == -1 then | ||
local nitrousKey = 38 -- Change this to the key you wish to use https://docs.fivem.net/docs/game-references/controls/ | ||
RegisterKeyMapping("nitrous", "Nitrous Boost", "keyboard", nitrousKey) | ||
RegisterCommand("nitrous", function() | ||
handleNitrousKeyPress(vehicle, nitrousKey) | ||
end, false) | ||
end | ||
end) |
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,9 @@ | ||
fx_version "cerulean" | ||
game "gta5" | ||
|
||
author "CDocc#1888" | ||
description "Standalone Nitrous Script" | ||
|
||
client_scripts { | ||
'client.lua' | ||
} |