Frugle Posted August 28, 2009 Share Posted August 28, 2009 function ClientChat(text) if ( text == "pos" ) then outputConsole ( "SUCCESS" ) outputChatBox ( "SUCCESS", getRootElement(), 255, 255, 255, true ) else outputConsole ( "FAILURE" ) outputChatBox ( "FAILURE", getRootElement(), 255, 255, 255, true ) end end addEventHandler ("OnClientChatMessage", getRootElement(), ClientChat) I am trying to output SUCCESS to chatbox and console if player types pos, but nothing happens Not even FAILURE output. Need help! Link to comment
CodeMaster Posted August 28, 2009 Share Posted August 28, 2009 You're not major noob... It happens if you're still an unexperienced scripter. Don't worry experience comes with time function ClientChat(text) if ( text == "pos" ) then outputConsole ( "SUCCESS" ) outputChatBox ( "SUCCESS", getRootElement(), 255, 255, 255, true ) else outputConsole ( "FAILURE" ) outputChatBox ( "FAILURE", getRootElement(), 255, 255, 255, true ) end end addEventHandler ("onClientChatMessage", getRootElement(), ClientChat) There that'll work. You wrote "OnClientChatMessage" instead of "onClientChatMessage". Cheers Nidza Link to comment
Frugle Posted August 28, 2009 Author Share Posted August 28, 2009 Thank you but it still doesn't work for some reason . Link to comment
50p Posted August 28, 2009 Share Posted August 28, 2009 You're not major noob... It happens if you're still an unexperienced scripter. Don't worry experience comes with time, CodeMaster For client-side outputChatBox, 2nd arguments is not visibleTo.. it's the red colour. Frugle, use /debugscript 3, command to open a "debug window" where you'll see all the errors/warnings when executing your scripts but before you type that command in you have to login as an admin. Link to comment
Frugle Posted August 29, 2009 Author Share Posted August 29, 2009 I've tried everything but I can't get it to work. Link to comment
50p Posted August 29, 2009 Share Posted August 29, 2009 I've tried everything but I can't get it to work. Show us your current code and tell us what you do to test the script. Link to comment
Frugle Posted August 29, 2009 Author Share Posted August 29, 2009 function joinHandler() local x = 244.0065612793 local y = 2507.7377929688 local z = 16.496959686279 spawnPlayer(source, x, y, z) fadeCamera(source, true) setCameraTarget(source, source) outputChatBox("Welcome to My Server", source) end addEventHandler("onPlayerJoin", getRootElement(), joinHandler) function ClientChat(text) if ( text == "pos" ) then outputConsole( "SUCCESS" ) outputChatBox( "SUCCESS" ) else outputConsole( "FAILURE" ) outputChatBox( "FAILURE" ) end end addEventHandler ("onClientChatMessage", getRootElement(), ClientChat) I test it by typing pos to ingame chat. Typing something else doesn't output "FAILURE" too. Link to comment
50p Posted August 29, 2009 Share Posted August 29, 2009 onClientChatMessage is triggerend whenever text is shown in the chat box (even with outputChatBox). So when you outputChatBox( "FAILURE" ) you this will trigger the event again and again and again.. It's like infinite loop. Besides the "text" that is shown in the chatbox is not only the text you typed in but also your nickname and colours. Eg.: "Me: hello" the "text" argument will be like: "Me: #COLOURhello" I'm just wondering why you need to use "pos" only in chatbox. Can't you use addCommandHandler()? Link to comment
Frugle Posted August 29, 2009 Author Share Posted August 29, 2009 Ok, thank you. I was testing some stuff. Link to comment
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