Hello FiveM,
First of all, this is an edit of DieselDave’s script found here
I thought the script was a great idea but it could be improved, so I made my own!
Features:
- Client sided
- Faster syncing
- Smoke based on RPM
- More realistic smoke
- Support for multiple exhausts
Bugs:
- When using vehicles with rear-facing exhausts, depending on the heading of the vehicle, the smoke direction is offset (no idea how to fix this)
- FPS drops with big smoke pools (burnouts, etc)
Source (client.lua)
local allowedVehicles = {
"sandking"
}
local intensity = 2
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
for i = -1, 255 do
Citizen.CreateThread(function()
local ped = GetPlayerPed(i)
if ped == -1 then
return
end
if IsPedInAnyVehicle(ped) then
local vehicle = GetVehiclePedIsIn(ped, false)
if GetPedInVehicleSeat(vehicle, -1) ~= ped then
return
end
for k,v in pairs(allowedVehicles) do
if GetHashKey(v) == GetEntityModel(vehicle) then
RequestNamedPtfxAsset("core")
while not HasNamedPtfxAssetLoaded("core") do
Citizen.Wait(0)
end
local RPM = GetVehicleCurrentRpm(vehicle)*intensity
if ped == GetPlayerPed(-1) then
if not IsControlPressed(0, 71) then
RPM = RPM/intensity
end
end
for i=1, 16 do
Citizen.CreateThread(function()
local bone = "exhaust_"..i
if i == 1 then
bone = "exhaust"
end
if GetEntityBoneIndexByName(vehicle, bone) == -1 then
return
end
local coords = GetWorldPositionOfEntityBone(vehicle, bone)
local loopAmount = RPM*25
local particleEffects = {}
for x=0,loopAmount do
UseParticleFxAssetNextCall("core")
local particle = StartParticleFxLoopedOnEntityBone("ent_amb_exhaust_thick", vehicle, coords.x, coords.y, coords.z, 0.0, 0.0, 0.0, GetEntityBoneIndexByName(vehicle, bone), RPM, false, false, false)
SetParticleFxLoopedEvolution(particle, "ent_amb_exhaust_thick", RPM, 0)
table.insert(particleEffects, 1, particle)
Citizen.Wait(0)
end
Citizen.Wait(10)
for _,particle in pairs(particleEffects) do
StopParticleFxLooped(particle, true)
end
end)
end
end
end
end
end)
end
end
end)