Triggerelni is fölösleges, elég az elementData + onClientElementDataChange.
local vehiclesWithCustomHorns = {}
local previewingHorn = nil
bindKey(\"f2\", \"down\", -- Egyedi random duda beszerelés a kocsiba
function()
local vehicle = getPedOccupiedVehicle(localPlayer)
if vehicle then
if getVehicleOccupant(vehicle, 0) == localPlayer then
setElementData(vehicle, \"tuning.customHorn\", math.random(1, 10))
end
end
end
)
bindKey(\"f3\", \"down\", -- Egyedi duda eltávolítása a kocsiból
function()
local vehicle = getPedOccupiedVehicle(localPlayer)
if vehicle then
if getVehicleOccupant(vehicle, 0) == localPlayer then
setElementData(vehicle, \"tuning.customHorn\", nil)
end
end
end
)
bindKey(\"h\", \"down\",
function()
local vehicle = getPedOccupiedVehicle(localPlayer)
if vehicle then
if getVehicleOccupant(vehicle, 0) == localPlayer then
local customHorn = getElementData(vehicle, \"tuning.customHorn\") or nil
if customHorn then
toggleControl(\"horn\", false)
setElementData(vehicle, \"customHorn.state\", true)
else
toggleControl(\"horn\", true)
end
end
end
end
)
bindKey(\"h\", \"up\",
function()
local vehicle = getPedOccupiedVehicle(localPlayer)
if vehicle then
if getVehicleOccupant(vehicle, 0) == localPlayer then
local customHorn = getElementData(vehicle, \"tuning.customHorn\") or nil
if customHorn then
toggleControl(\"horn\", false)
setElementData(vehicle, \"customHorn.state\", false)
else
toggleControl(\"horn\", true)
end
end
end
end
)