Tutorials

How to lock/unlock vehicle with third party script ?

How to implement fivecode_carkeys with your vehicleshop so your players receive vehicle keys upon purchase of a new vehicle ?

How to implement fivecode_carkeys with your garage system so that when you store your vehicle, the keys will be removed from you, and when you take it out, they will be given to you.

How to make your vehicle drivable after lockpicking it while Config.NeedKeysToStartVehicles is true

How to create vehicle_keys table in your database

1.

circle-info

Toggle vehicle lock/unlock export:

---@param vehicle integer
---@param status Optional[integer] (1 || 2)
exports.fivecode_carkeys:ToggleLock(vehicle, status)
circle-info

Toggle vehicle lock/unlock export - EXAMPLE:

-- For example in ox_target
exports.ox_target:addGlobalVehicle({
    {
        name = 'ox_target:driverF',
        icon = 'fa-solid fa-car-side',
        label = 'Toggle Lock Vehicle',
        bones = { 'bodyshell' },
        canInteract = function(entity, distance, coords, name)

            local boneId = GetEntityBoneIndexByName(entity, 'door_dside_f')

            if boneId ~= -1 then
                return #(coords - GetWorldPositionOfEntityBone(entity, boneId)) < 0.5 or #(coords - GetWorldPositionOfEntityBone(entity, GetEntityBoneIndexByName(entity, 'seat_dside_f'))) < 0.72
            end
        end,
        onSelect = function(data)
            exports.fivecode_carkeys:ToggleLock(data.entity)
        end
    }
})

2.

circle-info

Give car keys export:

Client side:

circle-info

Give car keys export - EXAMPLE:

3.

circle-info

Remove/give player keys when storing/taking out vehicle from garage:

4.

circle-info

Make vehicle drivable after lockpicking it:

5.

circle-info

Create vehicle_keys table in your database:

If you need help with anything, do not hesitate and open a support ticket in our discordarrow-up-right.

Last updated