Hell-Mate Posted March 10, 2014 Share Posted March 10, 2014 Hello community ,, i have a problem, the probles is i want to make when the veh turn left it turn right and when right its turn left. i tried getControlState and setControl state but not working perfectly.. i hope someone can help me. Thanks Link to comment
Hell-Mate Posted March 10, 2014 Author Share Posted March 10, 2014 Post your current code... addEvent ( "accelerate", true ) function accelerate ( theVehicle, seat, jacked ) local data = getElementData ( source, "drunk", true ) if data then toggleControl ( source, "brake_reverse", false ) toggleControl ( source, "handbrake", false ) local left = getControlState ( source, "vehicle_left", true ) if data and left then setControlState ( source, "vehicle_right", true ) setControlState ( source, "vehicle_left", false ) setTimer (setControlState, 1500, 1, source, "vehicle_right", false) end local right = getControlState ( source, "vehicle_right", true ) if data and right then setControlState ( source, "vehicle_left", true ) setControlState ( source, "vehicle_right", false ) setTimer (setControlState, 1500, 1, source, "vehicle_left", false) end elseif not data then toggleControl ( source, "brake_reverse", true ) toggleControl ( source, "handbrake", true ) setControlState ( source, "vehicle_left", false ) setControlState ( source, "vehicle_right", false ) end end addEventHandler ( "accelerate", getRootElement(), accelerate ) i added an event to trigger it to a client event ( onClientRender ) to check the ElementData every frame change Link to comment
Mr_Moose Posted March 10, 2014 Share Posted March 10, 2014 i added an event to trigger it to a client event ( onClientRender ) to check the ElementData every frame change And there's the problem, the function actually seems to work but if it's checked every frame change then you won't be able to notice the change at all, first of all the script will notice the your are turning right and change it to left but when the next frame comes it will notice that the vehicle is driving left and change it back to right. Try calling this with a timer and set the interval to 5 or 10 seconds maybe or by using a command. Link to comment
Hell-Mate Posted March 10, 2014 Author Share Posted March 10, 2014 i think it can work with onClientRender, anyone more can help please ? Link to comment
Castillo Posted March 10, 2014 Share Posted March 10, 2014 https://community.multitheftauto.com/in ... ils&id=963 That script has that, you could see how it's done. Link to comment
Hell-Mate Posted March 12, 2014 Author Share Posted March 12, 2014 https://community.multitheftauto.com/index.php?p=resources&s=details&id=963That script has that, you could see how it's done. i used the same code in this script but there is a problem, left is now = right and right is now = left but there is problem with accelerate and brake. when i press up the car not going back but it still stop and steering and the same when i press down. and here is what i used > function wineveh() left=false right=false up=false down=false local keys = getBoundKeys ('vehicle_left') local data = getElementData ( localPlayer, "drunk", true ) if keys and data then tmpLeft = false for keyName, state in pairs(keys) do if (getKeyState(keyName)) and data then tmpLeft=true end end if tmpLeft and data then left=true right=false end end local keys = getBoundKeys ('vehicle_right') if keys and data then tmpRight = false for keyName, state in pairs(keys) do if (getKeyState(keyName)) and data then tmpRight=true end end if tmpRight and data then left=false right=true end end if (left) and data then setControlState('vehicle_left', false) setControlState('vehicle_right', true) elseif (right) and data then setControlState('vehicle_right', false) setControlState('vehicle_left', true) else setControlState('vehicle_right', false) setControlState('vehicle_left', false) end local keys = getBoundKeys ('accelerate') if keys and data then tmpUp = false for keyName, state in pairs(keys) do if (getKeyState(keyName)) and data then tmpUp=true end end if tmpUp and data then down=false up=true end end local keys = getBoundKeys ('brake_reverse') if keys and data then tmpDown = false for keyName, state in pairs(keys) do if (getKeyState(keyName)) and data then tmpDown=true end end if tmpDown and data then down=true up=false end end if (up) and data then setControlState('accelerate', false) setControlState('brake_reverse', true) elseif (down) and data then setControlState('brake_reverse', false) setControlState('accelerate', true) else setControlState('brake_reverse', false) setControlState('accelerate', false) end end addEventHandler ( "onClientRender", root, wineveh ) 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