Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 9 additions & 8 deletions client/boost.lua
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,17 @@ end
Citizen.CreateThread(function ()
local function BackfireLoop()
-- TODO: Only do this for nearby vehicles.
for vehicle in pairs(vehicles) do
CreateVehicleExhaustBackfire(vehicle, 1.25)
for vehicle in pairs(vehicles) do
--CreateVehicleExhaustBackfire(vehicle, 1.25)
SetVehicleNitroEnabled(vehicle, true, 0.0, 0.0, 0.0, true)
end
end
end

while true do
Citizen.Wait(0)
BackfireLoop()
end
end)
while true do
Citizen.Wait(0)
BackfireLoop()
end
end)

Citizen.CreateThread(function ()
local function BoostLoop()
Expand Down
45 changes: 23 additions & 22 deletions client/main.lua
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ local function NitroLoop(lastVehicle)
SetVehicleNitroBoostEnabled(vehicle, false)
SetVehicleLightTrailEnabled(vehicle, false)
SetVehicleNitroPurgeEnabled(vehicle, false)
SetVehicleNitroEnabled(vehicle, false)
TriggerServerEvent('nitro:__sync', false, false, false)
end

Expand All @@ -90,25 +91,25 @@ AddEventHandler('nitro:__update', function (playerServerId, boostEnabled, purgeE
--
-- Say, the source player enables nitro, but is not connected in our session.
-- Nitro is then synced on the vehicle for player -1, which is us, so nitro is
-- activated on our vehicle. However, because we're not actually pressing the
-- nitro key, our client will update the nitro state accordingly, and turn it
-- off. That then syncs to the original source player, who has the exact same
-- network issue as we do. Nitro will be disabled on his vehicle, but he's
-- still pressing the nitro key, so it's being enabled right after. Long story
-- short, this causes an infinite sync loop between all clients as long as at
-- least one player has nitro activated.
--
-- Therefor, simply check if the source player is connected to our session. If
-- not, ignore the synced state and don't do anything.
if not NetworkIsPlayerConnected(playerId) then
return
end

local player = GetPlayerPed(playerId)
local vehicle = GetVehiclePedIsIn(player, lastVehicle)
local driver = GetPedInVehicleSeat(vehicle, -1)

SetVehicleNitroBoostEnabled(vehicle, boostEnabled)
SetVehicleLightTrailEnabled(vehicle, boostEnabled)
SetVehicleNitroPurgeEnabled(vehicle, purgeEnabled)
end)
-- activated on our vehicle. However, because we're not actually pressing the
-- nitro key, our client will update the nitro state accordingly, and turn it
-- off. That then syncs to the original source player, who has the exact same
-- network issue as we do. Nitro will be disabled on his vehicle, but he's
-- still pressing the nitro key, so it's being enabled right after. Long story
-- short, this causes an infinite sync loop between all clients as long as at
-- least one player has nitro activated.
--
-- Therefor, simply check if the source player is connected to our session. If
-- not, ignore the synced state and don't do anything.
if not NetworkIsPlayerConnected(playerId) then
return
end

local player = GetPlayerPed(playerId)
local vehicle = GetVehiclePedIsIn(player, lastVehicle)
local driver = GetPedInVehicleSeat(vehicle, -1)

SetVehicleNitroBoostEnabled(vehicle, boostEnabled)
SetVehicleLightTrailEnabled(vehicle, boostEnabled)
SetVehicleNitroPurgeEnabled(vehicle, purgeEnabled)
end)
22 changes: 11 additions & 11 deletions client/ptfx.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@ function CreateVehicleExhaustBackfire(vehicle, scale)
local pos = GetWorldPositionOfEntityBone(vehicle, boneIndex)
local off = GetOffsetFromEntityGivenWorldCoords(vehicle, pos.x, pos.y, pos.z)

UseParticleFxAssetNextCall('core')
StartParticleFxNonLoopedOnEntity('veh_backfire', vehicle, off.x, off.y, off.z, 0.0, 0.0, 0.0, scale, false, false, false)
UseParticleFxAsset('veh_xs_vehicle_mods')
StartParticleFxNonLoopedOnEntity('veh_nitrous', vehicle, off.x, off.y, off.z, 0.0, 0.0, 0.0, scale, false, false, false)
end
end
end
Expand Down Expand Up @@ -71,12 +71,12 @@ end
-- local particles = {}
--
-- for i = 0, density do
-- UseParticleFxAssetNextCall('core')
-- local fx1 = StartParticleFxLoopedOnEntity('ent_sht_steam', vehicle, off.x - 0.5, off.y + 0.05, off.z, 40.0, -20.0, 0.0, 0.5, false, false, false)
-- SetParticleFxLoopedColour(fx1, r, g, b)
--
-- UseParticleFxAssetNextCall('core')
-- local fx2 = StartParticleFxLoopedOnEntity('ent_sht_steam', vehicle, off.x + 0.5, off.y + 0.05, off.z, 40.0, 20.0, 0.0, 0.5, false, false, false)
-- SetParticleFxLoopedColour(fx2, r, g, b)
-- end
-- end
-- UseParticleFxAssetNextCall('core')
-- local fx1 = StartParticleFxLoopedOnEntity('ent_sht_steam', vehicle, off.x - 0.5, off.y + 0.05, off.z, 40.0, -20.0, 0.0, 0.5, false, false, false)
-- SetParticleFxLoopedColour(fx1, r, g, b)
--
-- UseParticleFxAssetNextCall('core')
-- local fx2 = StartParticleFxLoopedOnEntity('ent_sht_steam', vehicle, off.x + 0.5, off.y + 0.05, off.z, 40.0, 20.0, 0.0, 0.5, false, false, false)
-- SetParticleFxLoopedColour(fx2, r, g, b)
-- end
-- end