> For the complete documentation index, see [llms.txt](https://usin.gitbook.io/usin/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://usin.gitbook.io/usin/paid/usin-or-advanced-carlock-system.md).

# USIN | Advanced Carlock System 🔐

USIN Advanced Carlock System is a comprehensive car locking system that is highly customizable!

## Installation

* Buy the script from my [Tebex](https://usin.tebex.io/category/2971708).
* Download it from [Keymasters](https://keymaster.fivem.net/asset-grants).
* Extract it and drag it to you resources folder.
* Add "ensure usin\_carlock" to you server.cfg file.
* Add the [sql](#sql) file into your database.
* Configure the script to your likings in the "config.lua" file.

## Features

* Locking/unlocking vehicle via ox\_target, button or command. (configurable)
* Sharing/unsharing personal vehicle keys via ox\_target or command. (configurable)
* Checking keys shared with you via command.
* Locking/unlocking job owned vehiles. (configurable)
* Lock/unlock sound and animation. (configurable)
* Discord logging via webhook.
* Different notification options.

## Config

<details>

<summary>Showcase of the config.lua file</summary>

```lua
Config = {}

-- --- Notification System Selection ---
-- Choose your preferred notification system.
-- Options: 'ox_lib', 'esx', 'okok', 'wasabi', 'custom'
Config.NotifySystem = 'ox_lib' -- Default is ox_lib

-- Placeholder for your custom notification logic if Config.NotifySystem = 'custom'
--[[
    Parameters passed:
    data = {
        key = string,         -- The internal key for this notification (e.g., 'no_keys')
        prefix = string,      -- The Config.NotifyPrefix
        message = string,     -- The fully formatted message text
        type = string,        -- The type ('error', 'success', 'warning', 'inform')
        duration = number,    -- The configured duration
        dynamicData = table   -- Any extra data passed for formatting (e.g., {playerName, vehicleName})
    },
    isServer = boolean,       -- True if called from server.lua, false if client.lua
    targetSource = number     -- Player source ID (only provided if isServer is true)
--]]
Config.CustomNotifyFunction = function(data, isServer, targetSource)
    if isServer then
        print(string.format("[Custom Notify - Server -> Client %d] Key: %s, Msg: %s", targetSource, data.key, data.message))
        -- Example: Trigger your custom client event
        -- TriggerClientEvent('my_custom_notify:show', targetSource, data.message, data.type)
    else
        print(string.format("[Custom Notify - Client] Key: %s, Msg: %s", data.key, data.message))
        -- Example: Call your custom client export
        -- exports['my_custom_notify']:Show(data.message, data.type)
    end
end

-- --- Notification Messages & Settings ---
Config.NotifyPrefix = "Vehicle Keys" -- Default title/prefix for most systems
Config.Notifications = {
    -- Client-Side Triggers
    no_veh_cmd_lock =   { enabled = true, message = "No vehicle nearby to lock.", type = 'error', duration = 4000 },
    no_veh_cmd_unlock = { enabled = true, message = "No vehicle nearby to unlock.", type = 'error', duration = 4000 },
    usage_share =       { enabled = true, message = "Usage: /%s [Player ID]", type = 'error', duration = 5000 }, -- {Config.ShareKeyCommand}
    usage_unshare =     { enabled = true, message = "Usage: /%s [Player ID]", type = 'error', duration = 5000 }, -- {Config.UnshareKeyCommand}
    no_owned_share =    { enabled = true, message = "You don’t own any vehicles to share.", type = 'error', duration = 5000 },
    no_keys_to_revoke = { enabled = true, message = "No keys shared to this player.", type = 'error', duration = 5000 },
    no_shared_keys =    { enabled = true, message = "You don’t have any shared keys.", type = 'inform', duration = 4000 },
    locked =            { enabled = true, message = "Locked your %s 🔒", type = 'warning', duration = 2500 }, -- {vehicleName}
    unlocked =          { enabled = true, message = "Unlocked your %s 🔓", type = 'success', duration = 2500 }, -- {vehicleName}

    -- Server-Side Triggers (sent to specific client)
    no_plate =          { enabled = true, message = "Could not identify vehicle plate.", type = 'error', duration = 5000 },
    no_record =         { enabled = true, message = "No record of this vehicle.", type = 'error', duration = 5000 },
    no_keys =           { enabled = true, message = "You don’t have keys for this vehicle.", type = 'error', duration = 4000 },
    player_not_found =  { enabled = true, message = "Target player not found.", type = 'error', duration = 5000 },
    not_owner_share =   { enabled = true, message = "You do not own this vehicle.", type = 'error', duration = 5000 },
    key_shared_sender = { enabled = true, message = "Key for [%s] shared with %s.", type = 'success', duration = 5000 }, -- {plate, targetName}
    key_shared_receiver={ enabled = true, message = "%s shared a vehicle key [%s] with you!", type = 'inform', duration = 6000 }, -- {senderName, plate}
    key_already_shared= { enabled = true, message = "Key for [%s] is already shared with %s.", type = 'warning', duration = 5000 }, -- {plate, targetName}
    key_revoked_sender= { enabled = true, message = "Key for [%s] revoked from %s.", type = 'warning', duration = 5000 }, -- {plate, targetName}
    key_revoked_receiver={ enabled = true, message = "%s revoked your vehicle key for [%s].", type = 'error', duration = 6000 }, -- {senderName, plate}
    key_not_shared_revoke={enabled = true, message = "Key for [%s] was not shared with %s by you.", type = 'error', duration = 5000 } -- {plate, targetName}
}


-- --- Feature Toggles ---
Config.EnableLockUnlockCommands = true
Config.EnableShareKeyCommands = true
Config.EnableVehicleTarget = true
Config.EnablePlayerTarget = true
Config.EnableKeybind = true

-- --- Keybinds ---

Config.LockKeybind = "L"

-- --- Command Names ---
Config.LockCommand = "lockveh"
Config.UnlockCommand = "unlockveh"
Config.ShareKeyCommand = "sharekey"
Config.UnshareKeyCommand = "unsharekey"

-- --- Command/Target Settings ---
Config.CommandLockDistance = 10.0
Config.KeybindActionName = "UsinCarlock:ToggleKeybindAction" -- (no need to modify this)

-- --- ox_target Vehicle Settings ---
Config.VehicleTarget = {
    Lock = { 
        label = "Lock Vehicle", 
        icon = "fas fa-lock", 
        iconColor = "orange", 
        distance = 7.0 
    },

    Unlock = { 
        label = "Unlock Vehicle", 
        icon = "fas fa-unlock", 
        iconColor = "green", 
        distance = 7.0 
    }
}

-- --- ox_target Player Settings ---
Config.PlayerTarget = {
    ShareKey = { 
        label = "Share Vehicle Key", 
        icon = "fas fa-share-alt", 
        iconColor = "green", 
        distance = 2.0 
    },

    UnshareKey = { 
        label = "Unshare Vehicle Key", 
        icon = "fas fa-user-minus", 
        iconColor = "red", 
        distance = 2.0 
    }
}

-- --- Job Vehicle Ownership Style ---
--[[ Set this to how your 'owned_vehicles' table stores job/society ownership in the 'owner' column.
    Options:
    'society_colon_job':  Checks for "society:jobname" (e.g., owner = "society:police")
    'job_direct':         Checks for "jobname" directly (e.g., owner = "police") 
--]]
Config.JobVehicleOwnerStyle = 'job_direct'

-- Discord Webhook for logging
Config.DiscordWebhook = 'YOUR_DISCORD_WEBHOOK_HERE'
Config.EnableDiscordLogs = false -- Set to true if you want discord logs.
```

</details>

## SQL

<details>

<summary>Install this into your database!</summary>

```sql
CREATE TABLE IF NOT EXISTS `shared_keys` (
  `owner` VARCHAR(64) NOT NULL,
  `receiver` VARCHAR(64) NOT NULL,
  `plate` VARCHAR(12) NOT NULL,
  PRIMARY KEY (`owner`, `receiver`, `plate`)
);
```

</details>

## Pictures

<details>

<summary>Showcasing the script!</summary>

![](https://3313543074-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv35OSwS15FeJ53pmKPmN%2Fuploads%2FeEPUbs3DcZ12zEmShmTk%2Foxlock.png?alt=media\&token=522ae794-6208-41ec-b3e9-d11fb34936dd)![](https://3313543074-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv35OSwS15FeJ53pmKPmN%2Fuploads%2FbozBRLL6DVZGYKbu4AV5%2Foxunlock.png?alt=media\&token=d4e53e2a-6661-429a-a5ba-a35850ee9de6)![](https://3313543074-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv35OSwS15FeJ53pmKPmN%2Fuploads%2Ffno2x2K0e0PadhvMJrAy%2Fun-lock_commands.png?alt=media\&token=e8ceab2a-8a5d-4d49-b1fd-387fe7915d04)![](https://3313543074-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv35OSwS15FeJ53pmKPmN%2Fuploads%2FtS79mPkQ45K0pRpLiKL4%2Fkeybind.png?alt=media\&token=22b45bab-5a93-4c7b-b098-78c8b826e86a)![](https://3313543074-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv35OSwS15FeJ53pmKPmN%2Fuploads%2FpyKLYYifkV7a6qiMjInX%2Fsharemenu.png?alt=media\&token=20c74b33-ed81-474d-9744-bb75b5e5c671)![](https://3313543074-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv35OSwS15FeJ53pmKPmN%2Fuploads%2FKXDjjOkx7iHXT0tgbIBM%2Fox_un-share.png?alt=media\&token=eb074684-f8a3-44a3-b9be-7557c479d765)![](https://3313543074-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv35OSwS15FeJ53pmKPmN%2Fuploads%2FUB1zaKB0OX9K9vuvpOeW%2Fmykeys.png?alt=media\&token=ddb1354d-ae5f-4e86-9f74-18c8d4c4c8ce)![](https://3313543074-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2Fv35OSwS15FeJ53pmKPmN%2Fuploads%2FwqqLUMmlo01ulRYhz9AR%2Funsharemenu.png?alt=media\&token=9f10079c-492f-4cad-8e79-ffe9731355e4)

</details>

## Video

{% embed url="<https://www.youtube.com/watch?ab_channel=USINScripts&v=1CRy0tGoE_8>" %}
