Jump to content

Sound problem


zzx

Recommended Posts

Posted

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

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

Posted

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) 

Posted

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.

Posted
the probllem is with setRadioChannel(0)

8bp2dWf.png

5zscay0.png

Yeah as i thought you aren't define a type of the client file so it should be like that :

<script src="client.lua" type="client" /> 

Posted

Thanks it works perfectly, but another problem, how to stop the sound, and when i start the resource it directly plays the sound, but i want it to start when i type sux the command

Posted

thanks man <3 but the sound still restarting without stop at all, how to start it once until i type sux again pls and thanks man <3

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

prestige, the outputchatbox doesn't appear on the chat, and the sound keeps restarting without stop :/

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

Posted

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

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

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