Exports

Vehicle entity id is passed to all of these exports. Here are a few examples of how to determine the vehicle entity in your function or event.

AddKey - Give the player keys to the specified vehicle

exports["mk_vehiclekeys"]:AddKey(vehicle)

HasKey - Check if the player has keys to the specified vehicle

--Returns true or false
exports["mk_vehiclekeys"]:HasKey(vehicle)

--Example
if exports["mk_vehiclekeys"]:HasKey(vehicle) then 
    print('player has keys')
else
    print('player does not have keys')
end

HasFlyingAuth - Check if the player is authorized to fly the specified vehicle. Only call this export on vehicles that are designated helicopters or planes (Vehicle class 15 or 16)

--Returns true or false
exports["mk_vehiclekeys"]:HasFlyingAuth(vehicle)

--Example
if GetVehicleClass(vehicle) == 15 or GetVehicleClass(vehicle) == 16 then --plane or helicopter
    if exports["mk_vehiclekeys"]:HasFlyingAuth(vehicle) then 
        print('player can fly this vehicle')
    else
        print('player cannot fly this vehicle')
    end
else
    print('not a plane or helicopter')
end

ToggleLocks - Toggle locks of the specified vehicle the player has keys for. Must be within 7.5 distance of the vehicle. Useful for targeting system or radial menu to toggle vehicle locks.

exports["mk_vehiclekeys"]:ToggleLocks(vehicle)

UnlockVehicle - Unlock a vehicle without requiring keys (useful for police or mechanic type jobs)

exports["mk_vehiclekeys"]:UnlockVehicle(vehicle)

ChangeOwner - Changes vehicle owner when selling between player. Only call for player owned vehicles. Call export on the player that is being made the new owner. If vehicle is not defined the script will check the closest vehicle to the player.

--Set player as owner of a specific vehicle
exports["mk_vehiclekeys"]:ChangeOwner(vehicle)

--Set player as owner of the closest vehicle
exports["mk_vehiclekeys"]:ChangeOwner()

UsingKeyFobs - Checks if key fobs are enabled by the script

--Returns true or false
exports["mk_vehiclekeys"]:UsingKeyfobs()

RemoveKey - Remove keys from a specified player to the specified vehicle

--This does not apply to keyfobs
exports["mk_vehiclekeys"]:RemoveKey(vehicle)

Last updated