Jump to content

[Problem] Stop sound


//_Dragon

Recommended Posts

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
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
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
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
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

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...