//_Dragon Posted January 9, 2016 Share Posted January 9, 2016 I've problem in stoping soud When player do /fox he will listen music & all player will listen too but when he another music /pokerface the first music will stop & the second music will start but player they listen 2 music in same time i want when player do 2 music , first music stop & second music start , & player too will listen the second music ------pokerface function music12( name ) sound = playSound("music/pokerface.mp3") setSoundVolume(sound, 50) setSoundMaxDistance( sound, 5000 ) end addEvent( "pokerface", true ) addEventHandler( "pokerface", getRootElement(), music12 ) function stopMySound() stopSound( sound ) end addCommandHandler ( "pokerface", stopMySound ) ------fox function music12( name ) sound = playSound("music/fox.mp3") setSoundVolume(sound, 50) setSoundMaxDistance( sound, 5000 ) end addEvent( "fox", true ) addEventHandler( "fox", getRootElement(), music12 ) function stopMySound() stopSound( sound ) end addCommandHandler ( "fox", stopMySound ) Link to comment
ViRuZGamiing Posted January 9, 2016 Share Posted January 9, 2016 I'm not able to understand your text can you write in steps (1, 2, 3, ...) what you needs to happen. Link to comment
Revolt Posted January 10, 2016 Share Posted January 10, 2016 local music = { ["pokerface"] = "music/pokerface.mp3", ["fox"] = "music/fox.mp3" } local sound local soundname = "" function playMusic(command) if (sound) then stopSound(sound) destroyElement(sound) end if (soundname ~= command) then sound = playSound(music[command]) setSoundVolume(sound, 50) setSoundMaxDistance( sound, 5000 ) end soundname = command end for k in pairs(music) do addCommandHandler(k, root, playMusic) end Maybe this. Link to comment
ViRuZGamiing Posted January 10, 2016 Share Posted January 10, 2016 local music = { ["pokerface"] = "music/pokerface.mp3", ["fox"] = "music/fox.mp3" } local sound local soundname = "" function playMusic(command) if (sound) then stopSound(sound) destroyElement(sound) end if (soundname ~= command) then sound = playSound(music[command]) setSoundVolume(sound, 50) setSoundMaxDistance( sound, 5000 ) end soundname = command end for k in pairs(music) do addCommandHandler(k, root, playMusic) end Maybe this. Not that your code is bad but wouldn't be /play pokerface be more obvious? /play namesong Link to comment
//_Dragon Posted January 10, 2016 Author Share Posted January 10, 2016 local music = { ["pokerface"] = "music/pokerface.mp3", ["fox"] = "music/fox.mp3" } local sound local soundname = "" function playMusic(command) if (sound) then stopSound(sound) destroyElement(sound) end if (soundname ~= command) then sound = playSound(music[command]) setSoundVolume(sound, 50) setSoundMaxDistance( sound, 5000 ) end soundname = command end for k in pairs(music) do addCommandHandler(k, root, playMusic) end Maybe this. dude is not working | Debugscript : http://imgur.com/iuEuZdn Link to comment
ViRuZGamiing Posted January 10, 2016 Share Posted January 10, 2016 addCommandHandler(k, playMusic) and get rid of the triggers Link to comment
DarkByte Posted January 10, 2016 Share Posted January 10, 2016 So when this guy its asking for help its not rude ha? Link to comment
//_Dragon Posted January 10, 2016 Author Share Posted January 10, 2016 addCommandHandler(k, playMusic)and get rid of the triggers Nothen fixed ----server ----wtf function music(player, cmd) local name = getPlayerName(player) local r,g,b = getPlayerNametagColor (player) local accountname = getAccountName (getPlayerAccount(player)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Vip" ) ) then outputChatBox ( "" .. name .. ": #046C02 wtf booom", getRootElement(), r, g, b, true ) triggerClientEvent ("wtf", getRootElement()) else outputChatBox ( "this command for vip group", player, 255, 0, 0, true ) return end end addCommandHandler("wtf", music) ----RIP function music(player, cmd) local name = getPlayerName(player) local r,g,b = getPlayerNametagColor (player) local accountname = getAccountName (getPlayerAccount(player)) if isObjectInACLGroup ( "user." .. accountname, aclGetGroup ( "Vip" ) ) then triggerClientEvent ("RIP", getRootElement()) else outputChatBox ( "this command for vip group", player, 255, 0, 0, true ) return end end addCommandHandler("rip", music) ----client ------wtf function music12( name ) sound = playSound("music/wtf.mp3") setSoundVolume(sound, 50) setSoundMaxDistance( sound, 5000 ) end addEvent( "wtf", true ) addEventHandler( "wtf", getRootElement(), music12 ) function stopMySound() stopSound( sound ) end addCommandHandler ( "wtf", stopMySound ) ------RIP function music12( name ) sound = playSound("music/RIP.mp3") setSoundVolume(sound, 50) setSoundMaxDistance( sound, 5000 ) end addEvent( "RIP", true ) addEventHandler( "RIP", getRootElement(), music12 ) function stopMySound() stopSound( sound ) end addCommandHandler ( "rip", stopMySound ) Link to comment
-Doc- Posted January 10, 2016 Share Posted January 10, 2016 stopSound https://forum.multitheftauto.com/viewtopic.php?t=91915&sid=4f76aad0ef50de4aa7f367856f437fc0 if sound and isElement(sound) then stopSound(sound) 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