Reacer Posted January 20, 2012 Posted January 20, 2012 I have a problem with adding sounds to my commandhandler! addCommandHandler("bye", function (thePlayer) outputChatBox(getPlayerName(thePlayer).." would like to say Bye Everyone!",getRootElement(),255,0,0) end) elseif command == "bye" then playSoundToAll( "sounds/bye.mp3"); text = ptag1 .. "would like to say Bye Everyone!
DakiLLa Posted January 20, 2012 Posted January 20, 2012 This is a totally mess. What 'elseif' is doing outside of your function? Where is the 'command' variable declared and what the hell is 'playSoundToAll' ? --SERVER SIDE addCommandHandler( "bye", function( thePlayer, cmd ) outputChatBox( getPlayerName( thePlayer ).." would like to say Bye Everyone!", root, 255, 0, 0 ) triggerClientEvent( root, "playByeSound", root ) end ) --CLIENT SIDE addEvent( "playByeSound", true ) addEventHandler( "playByeSound", root, function() playSound( "byebye.mp3", false ) end )
Reacer Posted January 20, 2012 Author Posted January 20, 2012 I don't know i thought it was right like that I don't know alot about scripting yet.. it still doesn't work like you did.. what do u mean with client side and server side?
Reacer Posted January 20, 2012 Author Posted January 20, 2012 Image how I did it.. looks oke i guess http://img407.imageshack.us/img407/1928/commands.png
GanJaRuleZ Posted January 20, 2012 Posted January 20, 2012 o.0 There are 2 separate files client.lua addEvent( "playByeSound", true ) addEventHandler( "playByeSound", root, function() playSound( "byebye.mp3", false ) end ) server.lua addCommandHandler( "bye", function( thePlayer, cmd ) outputChatBox( getPlayerName( thePlayer ).." would like to say Bye Everyone!", root, 255, 0, 0 ) triggerClientEvent( root, "playByeSound", root ) end ) and you must add them in meta
DakiLLa Posted January 20, 2012 Posted January 20, 2012 Also, don't forget to put your 'byebye.mp3' file in this resource and put it in meta too:
unknooooown Posted January 20, 2012 Posted January 20, 2012 Image how I did it.. looks oke i guesshttp://img407.imageshack.us/img407/1928/commands.png You really shouldnt work with the standard notepad. Have a look at this notepad: http://notepad-plus-plus.org/
Reacer Posted January 20, 2012 Author Posted January 20, 2012 Thanks guys! I begin one week ago with scripting and i understand it more everyday! I already have notepad++ but forgot to open it with ++ I didn't know about client side and server side but now i know Where can i find the commands to use? i wanna make a mediaplayer in server to
Reacer Posted January 20, 2012 Author Posted January 20, 2012 then i tried to make the coloured names addCommandHandler( "bye", function colouredchat( chatterName, cmd ) local r,g,b = getPlayerNameTagColor ( source ) local chatterName = getPlayerName ( source ) outputChatBox ( chatterName..":#FFFFFF"..would like to say Bye Everyone!, getRootElement(), r, g, b, true ) end but that doesn't work??
Al3grab Posted January 20, 2012 Posted January 20, 2012 functions are case sensitive , getPlayerNameTagColor = getPlayerNametagColor addCommandHandler( "bye", function ( chatterName, cmd ) -- removed function name from here , because you dont use it inside command handler local r,g,b = getPlayerNametagColor( chatterName ) -- and why source is here ? , source should be the player who entered the command local chatterName = getPlayerName ( chatterName ) outputChatBox ( chatterName..":#FFFFFFwould like to say Bye Everyone!", getRootElement(), r, g, b, true ) -- messages have to be in "string" end ) -- you have to close the command handler
Reacer Posted January 20, 2012 Author Posted January 20, 2012 It doesn't work.. only RED text appears and there isn't red text in my name, my name is Bg"#FF0098Reacerr I did exactly what u told me.
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