pocko Posted January 28, 2011 Posted January 28, 2011 hallo how was the command When write somethink to start sound ?
pocko Posted January 28, 2011 Author Posted January 28, 2011 can you give me a example. When i write /wtf to start sount
Aibo Posted January 28, 2011 Posted January 28, 2011 there are examples on the wiki, you know. function playMySound() local sound = playSound("mySoundFile.mp3") end addCommandHandler("wtf", playMySound) dont forget that sound file should also be added to meta.xml of your resource: <file src="mySoundFile.mp3" />
pocko Posted January 28, 2011 Author Posted January 28, 2011 Please Help me again i have somewhere mistake function AngryEmotion(player, command) outputChatBox( "* "..getPlayerName(player).." is angry", getRootElement(), 255, 0, 255, true ) end addCommandHandler("angry", AngryEmotion) function angry() local sound = angry("sounds/angry.mp3") end addCommandHandler("angry", angry)
DakiLLa Posted January 28, 2011 Posted January 28, 2011 (edited) function AngryEmotion(command) outputChatBox( "* "..getPlayerName(getLocalPlayer()).." is angry", 255, 0, 255, true ) angry() end addCommandHandler("angry", AngryEmotion) function angry() local sound = playSound("sounds/angry.mp3") --typo end Since it is a client-side, no one will see your message. If you want to output your message to everyone, you should add a server side event and trigger it when you type /angry. So the final result will be: --client function AngryEmotion(command) triggerServerEvent( "onAngry", getLocalPlayer() ) angry() end addCommandHandler("angry", AngryEmotion) function angry() local sound = playSound("sounds/angry.mp3") end --server addEvent( "onAngry", true ) addEventHandler( "onAngry", root, function() outputChatBox( "* "..getPlayerName(source).." is angry", root, 255, 0, 255, true ) end ) Edited January 28, 2011 by Guest
pocko Posted January 28, 2011 Author Posted January 28, 2011 i tryed the text working Now left only the sound when i write now debugscript 3 write me this ERROR emotions\angry.lua:2: attempt to call global 'getLocalPlayer' (a nil value) Error emotions\angry.lua:8: stack overflow
DakiLLa Posted January 28, 2011 Posted January 28, 2011 Show me your meta.xml file. Did you define that script as client-side? ="my_script.lua" type="client" /> Edit: oh, and look at the 8th line, it must be: local sound = playSound("sounds/angry.mp3")
pocko Posted January 28, 2011 Author Posted January 28, 2011 yes there was the problem.I corrected it now working ty i was forgot to make one space sounds= playsound I m new and that is my first script ty
pocko Posted January 29, 2011 Author Posted January 29, 2011 hey the script work perfect but i found another problem the other can t hear the sound when i start the command.I don t know but i want only admins to can active the sound
pocko Posted January 29, 2011 Author Posted January 29, 2011 here my try addEvent( "onAngry", true ) addEventHandler( "onAngry", root, function() local sound = playSound("sound/angry.mp3") end
Aibo Posted January 29, 2011 Posted January 29, 2011 you forgot ) after end to close addEventHandler.
pocko Posted January 29, 2011 Author Posted January 29, 2011 you forgot ) after end to close addEventHandler. I close it but not work again :DTHe others can t hear the sound /debugscript 3 and write this error Error: emotions/s_angry.lua attempt to cal global 'playsound' (a nil value)
Aibo Posted January 29, 2011 Posted January 29, 2011 you probably are trying to playSound server-side.
pocko Posted January 29, 2011 Author Posted January 29, 2011 yep i trying to start from s_angry.lua .But i want and others to can hear the sound
Aibo Posted January 29, 2011 Posted January 29, 2011 on the server you need only to trigger the event, that's all. and in client event handler for this event you place the playSound function.
Aibo Posted January 29, 2011 Posted January 29, 2011 well you should try to understand. --client addEvent( "onAngry", true ) addEventHandler( "onAngry", root, function() local sound = playSound("sounds/angry.mp3") end ) --server function AngryEmotion(player, command) outputChatBox( "* "..getPlayerName(player).." is angry", root, 255, 0, 255, true ) triggerClientEvent("onAngry", root) -- this will trigger onAngry event for all players. end addCommandHandler("angry", AngryEmotion)
pocko Posted January 29, 2011 Author Posted January 29, 2011 yes you are right ! it s hard but i made it and now start to re read the script and to find edition ty
pocko Posted January 29, 2011 Author Posted January 29, 2011 hey i start to make a new emotion and write this !The text is showing but the sound can t please help me again and tell me where i making the problem Client: function GoodbyeEmotion(command) triggerServerEvent( "onbye", getLocalPlayer() ) end addCommandHandler("bb", GoodbyeEmotion) addEvent( "onbye", true ) addEventHandler( "onbye", root, function() local sound = playSound("sound/goodbuy.mp3") end ) Server addEvent( "onbye", true ) addEventHandler( "onbye", root, function() outputChatBox( "* "..getPlayerName(source).." said: Goodbye all", root, 255, 0, 255, true ) end ) function GoodbyeEmotions(player, command) triggerClientEvent("onbye", root) end addCommandHandler("bb", GoodbyeEmotion)
Castillo Posted January 29, 2011 Posted January 29, 2011 why didn't you copy Aiboforcen's code? --client addEvent( "onBye", true ) addEventHandler( "onBye", root, function() local sound = playSound("sounds/goodbuy.mp3") end ) --server function ByeEmotion(player, command) outputChatBox( "* "..getPlayerName(player).."said: Goodbye all", root, 255, 0, 255, true ) triggerClientEvent("onBye", root) end addCommandHandler("bye", ByeEmotion)
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