can use this code to achieve vehicle tire smog, but only I can see, I want to let all players synchronize, how to modify my code.Thank you!client.lua (3.4 KB)
1 Like
--[[===================]]
--[[=== C O N F I G ===]]
--[[===================]]
local _SIZE = 1.2
local _DENS = 200
local _BURNOUT_SIZE = 0.33
local _BIND_KEY = 73 -- Default: X
local _SMOKE_ON = true
--[[===============]]
--[[=== C O D E ===]]
--[[===============]]
local bone_list = {"wheel_lf","wheel_rf"}
local bone_list1 = {"wheel_lr","wheel_rr"}
Citizen.CreateThread(function()
base = "scr_bike_contraband"
base2 = "scr_bike_contraband"
Request(base)
Request(base2)
while true do Citizen.Wait(2)
ped = GetPlayerPed(-1)
car = GetVehiclePedIsUsing(ped)
ang,speed = angle(car)
if IsControlJustPressed(0, _BIND_KEY) then
_SMOKE_ON = not _SMOKE_ON
if _SMOKE_ON then Notify('~c~[漂移烟雾] ~g~已开启') else Notify('~c~[漂移烟雾] ~r~已关闭') end
end
if _SMOKE_ON then
if IsPedInAnyVehicle(GetPlayerPed(-1), false) then
if speed >= 3.0 and ang ~= 0 then
DriftSmoke(base,"scr_bike_truck_weed_smoke", car, _DENS, _SIZE)
elseif speed < 1.0 and IsVehicleInBurnout(car) then
DriftSmoke(base2,"scr_bike_truck_weed_smoke", car, 3, _BURNOUT_SIZE)
end
end
end
end
end)
--[[===============]]
--[[=== F U N C ===]]
--[[===============]]
function Request(name)
RequestNamedPtfxAsset(name)
while not HasNamedPtfxAssetLoaded(name) do
Wait(1)
end
end
function DriftSmoke(base, sub, car, dens, size)
all_part = {}
for i = 0,dens do
SetPtfxAssetNextCall(base)
local part1 = StartParticleFxLoopedOnEntityBone(sub, car, 0.05, 0, 0, 0, 0, 0, GetEntityBoneIndexByName(car, bone_list[1]), size, 0, 0, 0)
SetPtfxAssetNextCall(base)
local part2 = StartParticleFxLoopedOnEntityBone(sub, car, 0.05, 0, 0, 0, 0, 0, GetEntityBoneIndexByName(car, bone_list[2]), size, 0, 0, 0)
SetPtfxAssetNextCall(base)
local part3 = StartParticleFxLoopedOnEntityBone(sub, car, 0.05, 0, 0, 0, 0, 0, GetEntityBoneIndexByName(car, bone_list1[1]), size, 0, 0, 0)
SetPtfxAssetNextCall(base)
local part4 = StartParticleFxLoopedOnEntityBone(sub, car, 0.05, 0, 0, 0, 0, 0, GetEntityBoneIndexByName(car, bone_list1[2]), size, 0, 0, 0)
table.insert(all_part, 1, part1)
table.insert(all_part, 2, part2)
table.insert(all_part, 1, part3)
table.insert(all_part, 2, part4)
end
Citizen.Wait(1000)
for _,W1 in pairs(all_part) do
StopParticleFxLooped(W1, true)
end
end
function angle(veh)
if not veh then return false end
local vx,vy,vz = table.unpack(GetEntityVelocity(veh))
local modV = math.sqrt(vx*vx + vy*vy)
local rx,ry,rz = table.unpack(GetEntityRotation(veh,0))
local sn,cs = -math.sin(math.rad(rz)), math.cos(math.rad(rz))
if GetEntitySpeed(veh)* 3.6 < 5 or GetVehicleCurrentGear(veh) == 0 then return 0,modV end --speed over 30 km/h
local cosX = (sn*vx + cs*vy)/modV
if cosX > 0.966 or cosX < 0 then return 0,modV end
return math.deg(math.acos(cosX))*0.5, modV
end
function Notify(text)
SetNotificationTextEntry('STRING')
AddTextComponentString(text)
DrawNotification(true, false)
end
1 Like
In terms of your question. This thread might help you
[HELP] Need to know how to make particles sync with other players
1 Like
I tried this method. It didn’t seem to work.
I also hope you help us with this. It’s a good script but they don’t support it anymore. and it would be great if everyone could see the smoke