-.Paradox.- Posted March 23, 2014 Share Posted March 23, 2014 Hello, i made this music system, but when i have one problem, when a random player run the music, and i run another one in the same time, the music that he runned must stop automatically, can somebody find a solution for this please? thanks Client: function proxy() local sound = playSound("music/proxy.mp3") setSoundVolume(sound, 50) end addEvent( "proxy", true ) addEventHandler( "proxy", getRootElement(), proxy ) function crackin( name ) local sound = playSound("music/crackin.mp3") setSoundVolume(sound, 50) setSoundMaxDistance( sound, 5000 ) end addEvent( "crackin", true ) addEventHandler( "crackin", getRootElement(), crackin ) Server: function proxy(player, cmd) local name1 = getPlayerName(player) local r,g,b = getPlayerNametagColor (player) local accountname = getAccountName (getPlayerAccount(player)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then outputChatBox ( "" .. name1 .. "#2600FF Playing Proxy", getRootElement(), r, g, b, true ) triggerClientEvent ("proxy", getRootElement()) else outputChatBox ( "This command for Admins group", player, 255, 0, 0, true ) return end end addCommandHandler("proxy", proxy ) function crackin(player, cmd) local name = getPlayerName(player) local r,g,b = getPlayerNametagColor (player) local accountname = getAccountName (getPlayerAccount(player)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Admin" ) ) then outputChatBox ( "" .. name .. "#2600FF Playing Crackin", getRootElement(), r, g, b, true ) triggerClientEvent ("crackin", getRootElement()) else outputChatBox ( "This command is for Admin group", player, 255, 0, 0, true ) return end end addCommandHandler("crackin", crackin) Link to comment
Karuzo Posted March 23, 2014 Share Posted March 23, 2014 Just check if theres another music streaming and than destroy the element or stop the sound. Link to comment
-.Paradox.- Posted March 23, 2014 Author Share Posted March 23, 2014 I think same, but how? I know the stopSound function but idk about check music streaming Link to comment
Karuzo Posted March 23, 2014 Share Posted March 23, 2014 Just check if sound is an element and then destroy it. if isElement(sound) == true then destroyElement(sound) end Link to comment
WhoAmI Posted March 23, 2014 Share Posted March 23, 2014 I want just to say, that you dont need this part == true it can be like this if isElement(sound) then Link to comment
-.Paradox.- Posted March 23, 2014 Author Share Posted March 23, 2014 In client or server? Link to comment
Karuzo Posted March 23, 2014 Share Posted March 23, 2014 @WhoAmI: Yeah, since isElement returns true. @Nikolai96: Clientside. Because playSound is a client - side function. Link to comment
-.Paradox.- Posted March 23, 2014 Author Share Posted March 23, 2014 function proxy() if isElement(sound) then destroyElement(sound) local sound = playSound("music/proxy.mp3") setSoundVolume(sound, 50) end end addEvent( "proxy", true ) addEventHandler( "proxy", getRootElement(), proxy ) function crackin( name ) local sound = playSound("music/crackin.mp3") setSoundVolume(sound, 50) setSoundMaxDistance( sound, 5000 ) end addEvent( "crackin", true ) addEventHandler( "crackin", getRootElement(), crackin ) ? Link to comment
Karuzo Posted March 23, 2014 Share Posted March 23, 2014 You're creating the sound after you check it. local sound = ... should be above isElement. Link to comment
-.Paradox.- Posted March 23, 2014 Author Share Posted March 23, 2014 Can't understand, can you fix it? Link to comment
WhoAmI Posted March 23, 2014 Share Posted March 23, 2014 local currentPlaying function proxy() if isElement(currentPlaying) then destroyElement(currentPlaying) local currentPlaying = playSound("music/proxy.mp3") setSoundVolume(currentPlaying, 50) end end addEvent( "proxy", true ) addEventHandler( "proxy", getRootElement(), proxy ) function crackin( name ) currentPlaying = playSound("music/crackin.mp3") setSoundVolume(currentPlaying, 50) setSoundMaxDistance( currentPlaying, 5000 ) end addEvent( "crackin", true ) Link to comment
-.Paradox.- Posted March 23, 2014 Author Share Posted March 23, 2014 Thanks, but when i play proxy first and then crackin, i can hear both of them, so i tried to fix it but didnt work, now both of them cannot be played local currentPlaying function proxy() if isElement(currentPlaying) then destroyElement(currentPlaying) local currentPlaying = playSound("music/proxy.mp3") setSoundVolume(currentPlaying, 50) --setSoundMaxDistance( currentPlaying, 5000 ) end end addEvent( "proxy", true ) addEventHandler( "proxy", getRootElement(), proxy ) function crackin( name ) if isElement(currentPlaying) then destroyElement(currentPlaying) local currentPlaying = playSound("music/crackin.mp3") setSoundVolume(currentPlaying, 50) setSoundMaxDistance( currentPlaying, 5000 ) end end addEvent( "crackin", true ) addEventHandler( "crackin", getRootElement(), crackin ) Link to comment
WhoAmI Posted March 23, 2014 Share Posted March 23, 2014 local currentPlaying function proxy() if isElement(currentPlaying) then destroyElement(currentPlaying) currentPlaying = playSound("music/proxy.mp3") setSoundVolume(currentPlaying, 50) --setSoundMaxDistance( currentPlaying, 5000 ) end end addEvent( "proxy", true ) addEventHandler( "proxy", getRootElement(), proxy ) function crackin( name ) if isElement(currentPlaying) then destroyElement(currentPlaying) currentPlaying = playSound("music/crackin.mp3") setSoundVolume(currentPlaying, 50) setSoundMaxDistance( currentPlaying, 5000 ) end end addEvent( "crackin", true ) addEventHandler( "crackin", getRootElement(), crackin ) Link to comment
-.Paradox.- Posted March 23, 2014 Author Share Posted March 23, 2014 Still can't hear both of them 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