Így valahogy?
Client:
--client
local sounds = {}
function startSirene ( vehicle )
local x,y,z = getElementPosition( vehicle )
local sirene = playSound3D( \"files\\\\siren.mp3\", x, y, z, true)
setSoundVolume(sirene, 0.9)
setSoundMinDistance ( sirene, 90 )
setSoundMaxDistance ( sirene, 150 )
attachElements ( sirene, vehicle)
sounds [ vehicle ] = sirene
end
addEvent( \"startSirene\", true )
addEventHandler(\"startSirene\", getRootElement(), startSirene)
function stopSirene( vehicle )
local sirene = sounds [ vehicle ]
stopSound ( sirene )
end
addEvent( \"stopSirene\", true )
addEventHandler(\"stopSirene\", getRootElement(), stopSirene)
function bindTheKeys ()
bindKey ( \"x\", \"down\", startSirene )
bindKey ( \"x\", \"up\", stopSirene )
end
Server:
--server
function startSirene( player, cmd )
local commandant = getPedOccupiedVehicle(player)
triggerClientEvent ( \"startSirene\", getRootElement(), commandant )
end
addCommandHandler ( \"sirenon\", startSirene)
function stopSirene( player, cmd )
local commandant = getPedOccupiedVehicle(player)
triggerClientEvent ( \"stopSirene\", getRootElement(), commandant )
end
addCommandHandler ( \"sirenoff\", stopSirene)
function bindTheKeys ( player, commandName )
bindKey ( player, \"x\", \"down\", startSirene )
bindKey ( player, \"x\", \"up\", stopSirene )
end