Jump to content

[help ] Login Panel music


Shady1

Recommended Posts

addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function()
    setTimer(function()
        --playSound("winsound.mp3")
    end, 2000, 1)
end
)

How can I integrate the codes you wrote into them exactly? can you help me because i tried i couldn't. brruggghh :/

Link to comment

Well it's similar to the example I gave you.

local sound

addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), function()
    setTimer(function()
        sound = playSound("winsound.mp3")
    end, 2000, 1)
end
)

-- And in the function where the player logs in successfully put this:
if isElement(sound) then
    stopSound(sound)
end

 

Link to comment

You can solve this problem by creating an event on client side and running it with triggerClientEvent on server side

client:

local sound

addEventHandler("onClientResourceStart", resourceRoot, function()
    setTimer(function()
        sound = playSound("winsound.mp3")
    end, 2000, 1)
end
)

addEvent("stopLoginMusic", true)
addEventHandler("stopLoginMusic", root,
    function()
       if isElement(sound) then
          stopSound(sound)
       end
    end
)

server:

addEventHandler("onPlayerLogin", root,
    function()
       triggerClientEvent(source, "stopLoginMusic", source)
    end
)

 

Edited by Burak5312
  • Like 1
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...