Nakka Lindo Posted April 12, 2023 Share Posted April 12, 2023 sound = {}; sound['veh'] = playSound(...) radioSound = { } addEventHandler("onClientResourceStart", resourceRoot, function() bindKey("R", "down", clientToggleRadio) end ) addEventHandler("onClientVehicleEnter", root, function(thePlayer, seat) if thePlayer == getLocalPlayer() then local msg = "Pressione 'R' Para Ligar a Rádio." if radioSound[source] == nil then outputChatBox(msg, 255, 255, 255) else if radioSound[source].soundElement == nil then outputChatBox(msg, 255, 255, 255) end end end end ) addEventHandler("onClientSoundStream", root, function(success, length, streamName) if streamName then local veh = getPedOccupiedVehicle(getLocalPlayer()) if veh then if radioSound[veh] == nil then return end if radioSound[veh].soundElement == source then end end end end ) addEventHandler("onClientSoundChangedMeta", root, function(streamTitle) if streamTitle then local veh = getPedOccupiedVehicle(getLocalPlayer()) if veh then if radioSound[veh] == nil then return end if radioSound[veh].soundElement == source then outputChatBox("#696969Música: #AA2222 " .. streamTitle, 255, 255, 255, true) end end end end ) addEvent("onServerToggleRadio", true) addEventHandler("onServerToggleRadio", getLocalPlayer(), function(toggle, url, veh, volume) if (sound['veh']) then -- Verificando se existe aquele som na tabela usando o identificador do som. stopSound(sound['veh']); -- Parando o som. sound['veh'] = nil; return end if toggle == true then local x, y, z = getElementPosition(veh) if radioSound[veh] ~= nil then if (sound['veh']) then -- Verificando se existe aquele som na tabela usando o identificador do som. stopSound(sound['veh']); -- Parando o som. sound['veh'] = nil; --local sound = playSound3D(url, x, y, z) sound['veh'] = playSound('som.mp3') if volume ~= nil then end setSoundMinDistance(sound, 6) setSoundMaxDistance(sound, 200) attachElements(sound, veh) radioSound[veh] = {} radioSound[veh].soundElement = sound else local sound = playSound3D(url, x, y, z) sound['veh'] = playSound('som.mp3') if volume ~= nil then end setSoundMinDistance(sound, 6) setSoundMaxDistance(sound, 200) attachElements(sound, veh) radioSound[veh] = {} radioSound[veh].soundElement = sound end else if radioSound[veh] ~= nil then if (sound['veh']) then -- Verificando se existe aquele som na tabela usando o identificador do som. stopSound(sound['veh']); -- Parando o som. sound['veh'] = nil; radioSound[veh].soundElement = nil end end end end end ) addEvent("onServerRadioURLChange", true) addEventHandler("onServerRadioURLChange", getLocalPlayer(), function(newurl, veh, volume) if radioSound[veh] ~= nil then if (sound['veh']) then -- Verificando se existe aquele som na tabela usando o identificador do som. stopSound(sound['veh']); -- Parando o som. sound['veh'] = nil; local x, y, z = getElementPosition(veh) --local sound = playSound3D(newurl, x, y, z) sound['veh'] = playSound('newurl.mp3') if volume ~= nil then end setSoundMinDistance(sound, 6) setSoundMaxDistance(sound, 200) attachElements(sound, veh) radioSound[veh] = {} radioSound[veh].soundElement = sound end end end ) addEvent("onServerVolumeChangeAccept", true) addEventHandler("onServerVolumeChangeAccept", getLocalPlayer(), function(veh, newVolume) if veh then if radioSound[veh] ~= nil then setSoundVolume(radioSound[veh].soundElement, newVolume) end end end ) function clientToggleRadio() triggerServerEvent("onPlayerToggleRadio", getLocalPlayer()) end Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now