Jump to content

need help on find message on client side


bandi94

Recommended Posts

Posted

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)

Posted

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 :?

Posted
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)

Posted

thx i read on wiki but i don't understand how its work xD but now i get it (addCommandHander start a function when you type whit "/...." ) thx again

Posted
( 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 :)

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...