Jump to content

[Problem] Stop sound


//_Dragon

Recommended Posts

Posted

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 ) 

Posted

I'm not able to understand your text can you write in steps (1, 2, 3, ...) what you needs to happen.

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

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

Need a scripter? Feel free to contact me for inexpensive high-quality service!

Skype username: friedonibot

Posted
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

"If debugging is the process of removing software bugs, then programming must be the process of putting them in."

Posted
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

Posted

So when this guy its asking for help its not rude ha?

When I hear someone saying Mac is better than PC.

o0pjNKG.gif w0t?VeJXjxD.gifw0t? evspcFJ.gifw0t?

Great minds discuss ideas, average minds discuss events and small minds discuss people.

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

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