ViRuZGamiing Posted November 6, 2013 Posted November 6, 2013 Hi, root = getRootElement() function SwitchEngine( source ) local theVehicle = getPedOccupiedVehicle ( source ) if theVehicle and getVehicleController ( theVehicle ) == source then local state = getVehicleEngineState ( theVehicle ) setVehicleEngineState ( theVehicle, not state ) end end function BindKeys ( source ) if ( eventName == "onVehicleStartEnter" ) then bindKey ( source,"x","down",SwitchEngine ) else unbindKey ( source,"x","down",SwitchEngine ) end end addEventHandler ( "onVehicleStartEnter", root, BindKeys ) addEventHandler ( "onVehicleStartExit", root, BindKeys ) No errors only on bindKey "x" the car engine doesn't turn on/off "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
WASSIm. Posted November 6, 2013 Posted November 6, 2013 root = getRootElement() function SwitchEngine( source ) local theVehicle = getPedOccupiedVehicle ( source ) if theVehicle and getVehicleController ( theVehicle ) == source then local state = getVehicleEngineState ( theVehicle ) setVehicleEngineState ( theVehicle, not state ) end end function BindKeys ( source ) if ( eventName == "onVehicleStartEnter" ) then bindKey ( source,"x","down",SwitchEngine ) else unbindKey ( source,"x","down",SwitchEngine ) end end addEventHandler ( "onPlayerVehicleEnter", root, BindKeys ) addEventHandler ( "onPlayerVehicleExit", root, BindKeys )
Moderators IIYAMA Posted November 6, 2013 Moderators Posted November 6, 2013 -- root = getRootElement() -- don't redefine something that is already defined. local SwitchEngine SwitchEngine = function ( source ) local theVehicle = getPedOccupiedVehicle ( source ) if theVehicle and getVehicleController ( theVehicle ) == source then local state = getVehicleEngineState ( theVehicle ) setVehicleEngineState ( theVehicle, not state ) else unbindKey ( source,"x","down",SwitchEngine ) end end local BindKeyEnter = function (vehicle) bindKey ( source,"x","down",SwitchEngine ) end local BindKeyExit = function (vehicle) unbindKey ( source,"x","down",SwitchEngine ) end addEventHandler ( "onVehicleEnter", root, BindKeyEnter ) -- not onVehicleStartEnter addEventHandler ( "onVehicleExit", root, BindKeyExit ) -- not onVehicleStartExit Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
ViRuZGamiing Posted November 7, 2013 Author Posted November 7, 2013 doesn't work (server side right?) "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
Moderators IIYAMA Posted November 7, 2013 Moderators Posted November 7, 2013 maybe you should debug it...... Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
ViRuZGamiing Posted November 7, 2013 Author Posted November 7, 2013 I did no errors otherwise i've posted them "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
Moderators IIYAMA Posted November 7, 2013 Moderators Posted November 7, 2013 debuging doesn't mean you only have to watch the errors, you have to check how far the script goes and were it stops working. By using outputChatBox. I am not going to test it, Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
ViRuZGamiing Posted November 8, 2013 Author Posted November 8, 2013 Thx IIYAMA nice strategy to use outputChatbox to see where's the problem. Script fixed! "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
Moderators IIYAMA Posted November 8, 2013 Moderators Posted November 8, 2013 and what was the problem? Do you want to improve your Lua programming skills and make less mistakes? Start with Lua Language Server! Useful functions 3x Spoiler checkPassiveTimer getScreenStartPositionFromBox getPedGender Tutorials 4x Spoiler Scaling DX Events Attach an addEventHandler on a group of elements Debugging
ViRuZGamiing Posted November 8, 2013 Author Posted November 8, 2013 I didn't had any problems I've added the outputChatBox and everything worked (indeed weird) So I changed it to an outputConsole... problem solved "If debugging is the process of removing software bugs, then programming must be the process of putting them in."
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