Jump to content

Bind key


Recommended Posts

Try this. As for disabling the other keys in the freeroam script I think youd have to do that manualy But here the toggles are I guess:)

function toggleEngine ( thePlayer ) 
local isOn = getVehicleEngineState ( getPlayerOccupiedVehicle(thePlayer) ) 
    if isPlayerInVehicle ( thePlayer ) then 
        if isOn == true then 
            setVehicleEngineState ( getPlayerOccupiedVehicle(thePlayer), false ) 
            outputChatBox ( "*Engine off*", thePlayer ) 
        elseif isOn == false then 
            setVehicleEngineState ( getPlayerOccupiedVehicle(thePlayer), true ) 
            outputChatBox ( "*Engine on*", thePlayer ) 
        end 
    end 
end 
  
function toggleJetpack ( thePlayer ) 
local hasJetpack = doesPlayerHaveJetpack ( thePlayer ) 
    if isPlayerInVehicle ( thePlayer ) then 
        --... 
    else 
        if hasJetpack == true then 
            removePlayerJetPack ( thePlayer ) 
            outputChatBox ( "*Jetpack removed*", thePlayer ) 
        elseif hasJetpack == false then 
            givePlayerJetPack ( thePlayer ) 
            outputChatBox ( "*Jetpack equip*", thePlayer ) 
        end 
    end 
end 
  
function bindControls ( ) 
    bindKey ( thePlayer, "o", "down", toggleEngine ) 
    bindKey ( thePlayer, "f", "down", toggleJetpack ) 
end 
  
addEventHandler ( "onPlayerSpawn", getRootElement(), bindControls ) 

Link to comment

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...