Jump to content

Speakers error


Baseplate

Recommended Posts

addEvent("startSound", true) 
addEventHandler("startSound", root, 
function(url) 
destroyElement(sound) 
local x, y, z = getElementPosition(source) 
sound = playSound(tostring(url), x, y, z) 
end 
) 
  
addEventHandler("onClientGUIClick", root, 
function() 
if (source == playButton) then 
if (not guiGetText(linkEdit) == "") then 
triggerServerEvent("setCustomStream", root, guiGetText(linkEdit)) 
else 
local radioUrl = guiGridListGetItemText(radioGrid, guiGridListGetSelectedItem(radioGrid), 2) 
triggerServerEvent("setCustomStream", root, radioUrl) 
end 
end 
end 
) 

addEvent("setCustomStream", true) 
addEventHandler("setCustomStream", root, 
function(radio, p) 
if (p == source) then 
local x, y, z = getElementPosition(p) 
destroyElement(speaker)  
speaker = createObject(2229, x, y, z) 
triggerClientEvent(root, "startSound", root, radio) 
local vehicle = getPedOccupiedVehicle(p) 
attachElements(speaker, vehicle) 
end 
end 
) 

Not working, nothing happens, no errors on debug.

Link to comment

Replace line 17 with:

triggerServerEvent("setCustomStream", root, radioUrl, localPlayer) 

And remove this with one 'end'.

if (p == source) then 

And change this:

triggerClientEvent(root, "startSound", root, radio) 

To:

triggerClientEvent(root, "startSound", p, radio) 

Link to comment
addEvent("startSound", true) 
addEventHandler("startSound", root, 
function(url, speaker) 
    if isElement(sound) then destroyElement(sound) end 
    local x, y, z = getElementPosition(speaker) 
    sound = playSound3D(url, x, y, z) 
    attachElements(sound, speaker) 
end) 
  
addEventHandler("onClientGUIClick", root, 
function() 
    if (source == playButton) then 
        local link = guiGetText(linkEdit) 
        if (link ~=) then 
            triggerServerEvent("setCustomStream", root, link) 
        else 
            local radioUrl = guiGridListGetItemText(radioGrid, guiGridListGetSelectedItem(radioGrid), 2) 
            if (radioUrl ~= "") then 
                triggerServerEvent("setCustomStream", localPlayer, radioUrl) 
            end 
        end 
    end 
end) 

addEvent("setCustomStream", true) 
addEventHandler("setCustomStream", root, 
function(radio) 
    if isElement(speaker) then destroyElement(speaker) end 
    local vehicle = getPedOccupiedVehicle(source) 
    if vehicle then 
        local x, y, z = getElementPosition(source) 
        speaker = createObject(2229, x, y, z) 
        triggerClientEvent(root, "startSound", root, radio, speaker) 
        attachElements(speaker, vehicle) 
    end 
end) 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...