LiOneLMeSsIShoT Posted November 22, 2013 Posted November 22, 2013 I've made this script to start sound when player Join. Client Side but not work. Client: function onPlayerJoin () local sound = playSound ("Sounds/PanelSounds.mp3") setSoundVolume (sound, 1.0) end addEventHandler("onPlayerJoin", getRootElement(), onPlayerJoin) Why?
myonlake Posted November 22, 2013 Posted November 22, 2013 onPlayerJoin is a server-side event. Use onClientResourceStart to properly initialize the sound when the player joins. addEventHandler("onClientResourceStart", resourceRoot, function() local sound = playSound("Sounds/PanelSounds.mp3", false) setSoundVolume(sound, 1.0) end )
LiOneLMeSsIShoT Posted November 22, 2013 Author Posted November 22, 2013 onPlayerJoin is a server-side event. Use onClientResourceStart to properly initialize the sound when the player joins. addEventHandler("onClientResourceStart", resourceRoot, function() local sound = playSound("Sounds/PanelSounds.mp3", false) setSoundVolume(sound, 1.0) end ) Yeah i know that...but i want the song starts only when the player join...and then stops it when he Login.
myonlake Posted November 22, 2013 Posted November 22, 2013 Then use this. Client-side local sound addEventHandler("onClientResourceStart", resourceRoot, function() sound = playSound("Sounds/PanelSounds.mp3", false) setSoundVolume(sound, 1.0) end ) addEvent("stopIntro", true) -- Create a custom event in order to stop when player logs in addEventHandler("stopIntro", root, -- When the custom event is triggered, execute the function function() if (sound) and (isElement(sound)) then -- If the sound is an element destroyElement(sound) -- Destroy the sound element end end ) Server-side addEventHandler("onPlayerLogin", root, -- Trigger when a player logs in function() triggerClientEvent(source, "stopIntro", source) -- Trigger a client-side event to stop the music end )
LiOneLMeSsIShoT Posted November 22, 2013 Author Posted November 22, 2013 Then use this.Client-side local sound addEventHandler("onClientResourceStart", resourceRoot, function() sound = playSound("Sounds/PanelSounds.mp3", false) setSoundVolume(sound, 1.0) end ) addEvent("stopIntro", true) -- Create a custom event in order to stop when player logs in addEventHandler("stopIntro", root, -- When the custom event is triggered, execute the function function() if (sound) and (isElement(sound)) then -- If the sound is an element destroyElement(sound) -- Destroy the sound element end end ) Server-side addEventHandler("onPlayerLogin", root, -- Trigger when a player logs in function() triggerClientEvent(source, "stopIntro", source) -- Trigger a client-side event to stop the music end ) Works Fine Thanks a lot
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