Jump to content

Sound problem


zzx

Recommended Posts

hi guys i made a script to start sounds in the server example: [sOUNDS]: ZeldaK has started WTF?! sound.

but there are some errors in the debugscript please help!.

function startMusic() 
    setRadioChannel(0) 
    song = playSound("yousuck.mp3",true) 
    outputChatBox("[sOUND] "..playerName(player).." has started sound " ..soundName..") 
end 
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),startMusic) 
addCommandHandler("sux",toggleSong) 

Debug:

U2HJqNd.png?1

Link to comment
Remove the last quote;
outputChatBox("[sOUND] "..playerName(player).." has started sound "..soundName) 

+

player isn't defined anywhere in your code .

PS. I think your trying to send the outPutChatBox Message to the players in the server it's for the client only 'localPlayer' .

Link to comment

this didn't give me any errors but the sound doesn't play ?

function startMusic() 
    setRadioChannel(0) 
    song = playSound("yousuck.mp3",true) 
        outputChatBox("[sOUND] "..playerName(player).." has started sound "..soundName) 
end 
addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),startMusic) 
addCommandHandler("sux",startMusic) 

Link to comment

I think you are using it server side :/ ?

Also :

outputChatBox("[sOUND] "..playerName(player).." has started sound "..soundName) 

Should be :

outputChatBox("[sOUND] "..playerName(localPlayer).." has started sound "..soundName) 

Are you sure about the path it's exists?

PS. If didn't work then post your meta.xml FILE.

Link to comment
function startMusic (       ) 
            setRadioChannel ( 0 ) 
        if song and isElement ( song ) then 
            destroyElement ( song ) 
            song = nil 
        end 
            song = playSound('yousuck.mp3',true) 
        outputChatBox ( '[sOUND] '..playerName ( localPlayer )..' has started sound '..soundName ) 
end 
addCommandHandler ( 'sux',startMusic ) 

PS. playerName and soundName defined?

Edited by Guest
Link to comment
function startMusic (       ) 
            setRadioChannel ( 0 ) 
        if song and isElement ( song ) then 
            destroyElement ( song ) 
            song = nil 
        end 
            song = playSound ( 'yousuck.mp3' ) 
          soundName = soundName or 'N/A' 
          playerName = playerName or getPlayerName ( localPlayer ) 
        outputChatBox ( '[sOUND] '..playerName ..' has started sound '..soundName ) 
end 
addCommandHandler ( 'sux',startMusic ) 

Link to comment
i have a WTF sound how to add it to the script? and to access it by the command "wtf" not "sux"

every sound has its own command

Change the function startMusic and command 'sux' to 'wtf' like:

function startMusic (       ) 
            setRadioChannel ( 0 ) 
        if song and isElement ( song ) then 
            destroyElement ( song ) 
            song = nil 
        end 
          song = playSound ( 'yousuck.mp3' ) 
          soundName = soundName or 'N/A' 
          playerName = playerName or getPlayerName ( localPlayer ) 
        outputChatBox ( '[sOUND] '..playerName ..' has started sound '..soundName ) 
end 
addCommandHandler ( 'sux',startMusic ) 
  
function wtfSound (       ) 
            setRadioChannel ( 0 ) 
        if wtf and isElement ( wtf ) then 
            destroyElement ( wtf ) 
            wtf = nil 
        end 
          wtf = playSound ( 'path of wtf.mp3' ) 
          soundName = soundName or 'N/A' 
          playerName = playerName or getPlayerName ( localPlayer ) 
        outputChatBox ( '[sOUND] '..playerName ..' has started sound '..soundName ) 
end 
addCommandHandler ( 'wtf',wtfSound ) 

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