bandi94 Posted July 10, 2011 Share Posted July 10, 2011 i finish the manual gearbox for rpm+gear meter now i get stuck on auto/manual gearbox swich local manual=0 addEventHandler ("onClientChatMessage",getRootElement(), function(message,type) if (type(string.find(message,"/manual"))) then manual=1 elseif (type(string.find(message,"/auto"))) then manual=0 end end) client side hm.. and its return 1 (on every render tested whit outputChatBox) Link to comment
BinSlayer1 Posted July 10, 2011 Share Posted July 10, 2011 onClientChatMessage won't return you a command why don't you use addCommandHandler() ? Link to comment
bandi94 Posted July 10, 2011 Author Share Posted July 10, 2011 hmm. can you give me and example whit addComantHandler() for my code ( if find that message then get atuo==0 or==1 ) i never used addComandHandler and on wiki i don't understand how its work Link to comment
Aibo Posted July 10, 2011 Share Posted July 10, 2011 local manual = 0 function switchManualAuto(command) if command == "manual" then manual = 1 elseif command == "auto" then manual = 0 end end addCommandHandler("auto", switchManualAuto) addCommandHandler("manual", switchManualAuto) also read about addCommandHandler on the wiki. ps: if your manual variable has only 2 states (1 and 0) imo it's better to use boolean (true/false) Link to comment
bandi94 Posted July 10, 2011 Author Share Posted July 10, 2011 thx i read on wiki but i don't understand how its work but now i get it (addCommandHander start a function when you type whit "/...." ) thx again Link to comment
BinSlayer1 Posted July 10, 2011 Share Posted July 10, 2011 ( if find that message then get atuo==0 or==1 ) That's where the problem is. The command is not a message so you can't find it like that. I hope you understood from Aibo's example. Post again otherwise 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