Skip to content

Instantly share code, notes, and snippets.

@Blumlaut
Last active February 20, 2020 10:47
Show Gist options
  • Save Blumlaut/18b3607707a7989c724dfeb6851c7338 to your computer and use it in GitHub Desktop.
Save Blumlaut/18b3607707a7989c724dfeb6851c7338 to your computer and use it in GitHub Desktop.
dirt kick-up simulation thingy for FiveM
local DiRT = {
1144315879,
510490462,
-1907520769,
-1286696947,
-1885547121,
-700658213,
2128369009,
-1595148316,
-765206029,
509508168,
1333033863,
951832588,
-840216541,
-1907520769,
510490462,
-1942898710,
2352068586,
2387446527,
2699818980,
510490462,
2409420175,
3008270349,
}
local sand = {}
local Wheels = {
"wheel_lf",
"wheel_rf",
"wheel_lm",
"wheel_rm",
"wheel_lr",
"wheel_rr"
}
function GetGroundHash(veh)
local coords = GetEntityCoords(veh)
local num = StartShapeTestCapsule(coords.x,coords.y,coords.z+4,coords.x,coords.y,coords.z-2.0, 1,1,veh,7)
local arg1, arg2, arg3, arg4, arg5 = GetShapeTestResultEx(num)
return arg5
end
function isRaining()
local num2 = GetPrevWeatherTypeHashName()
if (num2 <= -1233681761) then
if (num2 <= -1429616491) then
if (num2 == -1530260698) then
return true;
end
if (num2 == -1429616491) then
return true;
end
else
if (num2 == -1368164796) then
return true;
end
if (num2 == -1233681761) then
return true;
end
end
else
if (num2 <= 603685163) then
if (num2 == -273223690) then
return true;
end
if (num2 == 603685163) then
return true;
end
else
if (num2 == 669657108) then
return true;
end
if (num2 == 1420204096) then
return true;
end
if (num2 == 1840358669) then
return true;
end
end
end
return false;
end
function doesTableContain(t,a)
if t and a then
for i,theKey in pairs(t) do
if theKey == a then
return true
end
end
end
return false
end
Citizen.CreateThread(function()
while true do
Citizen.Wait(2)
for i,thePTFX in pairs(sand) do
if i > 5 then
StopParticleFxLooped(thePTFX, false)
RemoveParticleFx(thePTFX, false)
table.remove(sand,i)
end
end
end
end)
Citizen.CreateThread(function()
while true do
SetWeatherTypeNow("CLEAR")
SetWeatherTypeNowPersist("CLEAR")
Citizen.Wait(10)
local veh = GetVehiclePedIsIn(PlayerPedId())
if veh ~= 0 and DoesEntityExist(veh) then
if (not isRaining()) and doesTableContain(DiRT, GetGroundHash(veh)) and GetEntitySpeed(veh) > 17.0 then
RequestNamedPtfxAsset("core")
UseParticleFxAssetNextCall("core")
ptfx = StartParticleFxLoopedOnEntity("weap_veh_turbulance_sand", veh,0.0,-2.0,0.2, 0.0, 0.0, 0.0, (GetModelDimensions(GetEntityModel(veh)).x), true, true )
table.insert(sand,1,ptfx)
local dl = GetVehicleDirtLevel(veh)
if dl < 14.98 then
SetVehicleDirtLevel(veh, dl+0.002)
end
else
for i,thePTFX in pairs(sand) do
if DoesParticleFxLoopedExist(thePTFX) then
StopParticleFxLooped(thePTFX, false)
RemoveParticleFx(thePTFX, false)
table.remove(sand,i)
end
end
end
end
end
end)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment