Jump to content

need help on find message on client side


bandi94

Recommended Posts

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

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...