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
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
ViRuZGamiing Posted November 7, 2013 Author Posted November 7, 2013 doesn't work (server side right?)
Moderators IIYAMA Posted November 7, 2013 Moderators Posted November 7, 2013 maybe you should debug it......
ViRuZGamiing Posted November 7, 2013 Author Posted November 7, 2013 I did no errors otherwise i've posted them
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,
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!
Moderators IIYAMA Posted November 8, 2013 Moderators Posted November 8, 2013 and what was the problem?
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
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