ViRuZGamiing Posted November 6, 2013 Share 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 Link to comment
WASSIm. Posted November 6, 2013 Share 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 ) Link to comment
Moderators IIYAMA Posted November 6, 2013 Moderators Share 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 Link to comment
ViRuZGamiing Posted November 7, 2013 Author Share Posted November 7, 2013 doesn't work (server side right?) Link to comment
Moderators IIYAMA Posted November 7, 2013 Moderators Share Posted November 7, 2013 maybe you should debug it...... Link to comment
ViRuZGamiing Posted November 7, 2013 Author Share Posted November 7, 2013 I did no errors otherwise i've posted them Link to comment
Moderators IIYAMA Posted November 7, 2013 Moderators Share 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, Link to comment
ViRuZGamiing Posted November 8, 2013 Author Share Posted November 8, 2013 Thx IIYAMA nice strategy to use outputChatbox to see where's the problem. Script fixed! Link to comment
Moderators IIYAMA Posted November 8, 2013 Moderators Share Posted November 8, 2013 and what was the problem? Link to comment
ViRuZGamiing Posted November 8, 2013 Author Share 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 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