Ninja Posted May 13, 2012 Share Posted May 13, 2012 Hey all, can anyone help me? Why do the second boost not work? --Made by Ninja-- local root = getRootElement() boostTimer = false local currentlyBoosting = false function onCarDownResourceStart(resource) bindKey("lalt", "down", startBoost) bindKey("lalt", "up", stopBoost) bindkey("lshift", "down", startBoost2) bindkey("lshift", "up", stopBoost2) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), onCarDownResourceStart) function startBoost (key, keyState) local vehicle = getPlayerOccupiedVehicle ( getLocalPlayer () ) if ( vehicle ) then if ( getVehicleController ( vehicle ) == getLocalPlayer () ) then boostTimer = setTimer(startCarBoost, 50, 0, vehicle) --outputChatBox ( "boostTimer=" .. tostring(boostTimer) ) currentlyBoosting = true else outputChatBox( "You need to be the driver!", 255, 0, 0 ) end end end function startCarBoost(vehicle) local vehSpeedX, vehSpeedY, vehSpeedZ = getElementVelocity ( vehicle ) setElementVelocity ( vehicle, vehSpeedX*1.1, vehSpeedY*1.1, vehSpeedZ*1) end function startBoost2 (key, keyState) local vehicle = getPlayerOccupiedVehicle ( getLocalPlayer () ) if ( vehicle ) then if ( getVehicleController ( vehicle ) == getLocalPlayer () ) then boostTimer = setTimer(startCarBoost2, 50, 0, vehicle) --outputChatBox ( "boostTimer=" .. tostring(boostTimer) ) currentlyBoosting = true else outputChatBox( "You need to be the driver!", 255, 0, 0 ) end end end function startCarBoost2(vehicle) local vehSpeedX, vehSpeedY, vehSpeedZ = getElementVelocity ( vehicle ) setElementVelocity ( vehicle, vehSpeedX*1, vehSpeedY*1, vehSpeedZ*1.1) end function stopBoost( key, keystate ) if ( currentlyBoosting ) then --outputChatBox ( "boostTimer=" .. tostring(boostTimer) ) killTimer( boostTimer ) currentlyBoosting = false end end function stopBoost2( key, keystate ) if ( currentlyBoosting ) then --outputChatBox ( "boostTimer=" .. tostring(boostTimer) ) killTimer( boostTimer ) currentlyBoosting = false end end Link to comment
Guest Guest4401 Posted May 13, 2012 Share Posted May 13, 2012 Check line 9 and 10 There is bindkey instead of bindKey Link to comment
Ninja Posted May 13, 2012 Author Share Posted May 13, 2012 still doesn't work... The First one works, that you get faster in one way but the second one that you get higher not.. Link to comment
Jaysds1 Posted May 13, 2012 Share Posted May 13, 2012 (edited) try this: --Made by Ninja-- boostTimer = false local currentlyBoosting = false function onCarDownResourceStart(resource) bindKey("lalt", "down", startBoost) bindKey("lalt", "up", stopBoost) bindKey("lshift", "down", startBoost2) bindKey("lshift", "up", stopBoost2) end addEventHandler("onClientResourceStart", getResourceRootElement(getThisResource()), onCarDownResourceStart) function startBoost (key, keyState) local vehicle = getPedOccupiedVehicle (localPlayer) if ( vehicle ) then if ( getVehicleController ( vehicle ) == getLocalPlayer() ) then boostTimer = setTimer(startCarBoost, 50, 0, vehicle) --outputChatBox ( "boostTimer=" .. tostring(boostTimer) ) currentlyBoosting = true else outputChatBox( "You need to be the driver!", 255, 0, 0 ) end end end function startCarBoost(vehicle) local vehSpeedX, vehSpeedY, vehSpeedZ = getElementVelocity ( vehicle ) setElementVelocity ( vehicle, vehSpeedX*1.1, vehSpeedY*1.1, vehSpeedZ*1) end function startBoost2 (key, keyState) local vehicle = getPedOccupiedVehicle ( getLocalPlayer () ) if ( vehicle ) then if ( getVehicleController ( vehicle ) == getLocalPlayer () ) then boostTimer = setTimer(startCarBoost2, 50, 0, vehicle) --outputChatBox ( "boostTimer=" .. tostring(boostTimer) ) currentlyBoosting = true else outputChatBox( "You need to be the driver!", 255, 0, 0 ) end end end function startCarBoost2(vehicle) local vehSpeedX, vehSpeedY, vehSpeedZ = getElementVelocity ( vehicle ) setElementVelocity ( vehicle, vehSpeedX*1, vehSpeedY*1, vehSpeedZ*1.1) end function stopBoost( key, keystate ) if ( currentlyBoosting == true ) then --outputChatBox ( "boostTimer=" .. tostring(boostTimer) ) killTimer( boostTimer ) currentlyBoosting = false boostTimer = false end end function stopBoost2( key, keystate ) if ( currentlyBoosting == true) then --outputChatBox ( "boostTimer=" .. tostring(boostTimer) ) killTimer( boostTimer ) boostTimer = false currentlyBoosting = false end end Edited May 13, 2012 by Guest Link to comment
Kenix Posted May 13, 2012 Share Posted May 13, 2012 (edited) bindkey("lshift", "down", startBoost2) bindkey("lshift", "up", stopBoost2) karthik184 said about this. Lua is case sensitive! Edited May 13, 2012 by Guest Link to comment
Jaysds1 Posted May 13, 2012 Share Posted May 13, 2012 bindkey("lshift", "down", startBoost2) bindkey("lshift", "up", stopBoost2) karthik184 said about this. Lua is case sensitive! Thanks Kenix, never seen that, I'm still having problems with my Notepad++ : viewtopic.php?f=91&t=43141&hilit=+Notepad#p435435 Anyways, what are you trying to do Ninja? Are you trying enable both or are you trying to enable 1 each time? Link to comment
Kenix Posted May 13, 2012 Share Posted May 13, 2012 (edited) local bBoostState, pTimer addEventHandler( 'onClientKey', root, function( sButton, bPressed ) local pVehicle = getPedOccupiedVehicle ( localPlayer ) if getVehicleController ( pVehicle ) == localPlayer then if sButton == 'lshift' and not bBoostState then bBoostState = true pTimer = setTimer( function( pVehicle ) if pVehicle and isElement( pVehicle ) and getElementType( pVehicle ) == 'vehicle' then local fVehSpeedX, fVehSpeedY, fVehSpeedZ = getElementVelocity ( pVehicle ) setElementVelocity ( pVehicle, fVehSpeedX * 1.1, fVehSpeedY * 1.1, fVehSpeedZ * 1 ) end end, 50, 0, pVehicle ) elseif sButton == 'lalt' and bBoostState then if isTimer( pTimer ) then bBoostState = nil killTimer( pTimer ) pTimer = nil end end else outputChatBox( 'You need to be the driver!', 255, 0, 0 ) end end ) Edited May 13, 2012 by Guest Link to comment
Ninja Posted May 13, 2012 Author Share Posted May 13, 2012 I want that you press left alt to speed up forwards and press left shift to jump a bit... But whats that script kenix there is a part missing with the "lalt". Link to comment
Kenix Posted May 13, 2012 Share Posted May 13, 2012 I tested this script all working perfectly if you not like something just change. 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