zzx Posted April 8, 2014 Posted April 8, 2014 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:
Dealman Posted April 8, 2014 Posted April 8, 2014 Remove the last quote; outputChatBox("[sOUND] "..playerName(player).." has started sound "..soundName)
iPrestege Posted April 8, 2014 Posted April 8, 2014 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' .
iPrestege Posted April 8, 2014 Posted April 8, 2014 'toggleSong' Function isn't defined anywhere that's the problem.
zzx Posted April 8, 2014 Author Posted April 8, 2014 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)
zzx Posted April 8, 2014 Author Posted April 8, 2014 no here is the problem when i write sux, the command handler.
iPrestege Posted April 8, 2014 Posted April 8, 2014 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.
iPrestege Posted April 8, 2014 Posted April 8, 2014 the probllem is with setRadioChannel(0) 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" />
zzx Posted April 8, 2014 Author Posted April 8, 2014 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
iPrestege Posted April 8, 2014 Posted April 8, 2014 Remove this part : addEventHandler("onClientResourceStart",getResourceRootElement(getThisResource()),startMusic)
zzx Posted April 8, 2014 Author Posted April 8, 2014 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
iPrestege Posted April 8, 2014 Posted April 8, 2014 (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 April 8, 2014 by Guest
Saml1er Posted April 8, 2014 Posted April 8, 2014 Use --- [/code] --- ------- [code=lua] ----script-----
zzx Posted April 8, 2014 Author Posted April 8, 2014 prestige, the outputchatbox doesn't appear on the chat, and the sound keeps restarting without stop
iPrestege Posted April 8, 2014 Posted April 8, 2014 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 )
zzx Posted April 8, 2014 Author Posted April 8, 2014 Worked thanks a lot <3 how can i add another sounds?
iPrestege Posted April 8, 2014 Posted April 8, 2014 Worked thanks a lot <3how can i add another sounds? You mean random sounds?
iPrestege Posted April 8, 2014 Posted April 8, 2014 like that sound but with different names What you mean by that? That sound but with different name? What's the reason for that?
zzx Posted April 8, 2014 Author Posted April 8, 2014 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
iPrestege Posted April 8, 2014 Posted April 8, 2014 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 )
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