Vehicle Keys & Security

Vehicle Keys & Security is a single solution to all vehicle access control possibilities in your server.

Info

With this resource, all vehicle keys are items with metadata, capable of being traded, crafted, and stolen. Configurable jobs have access to a trandponderencoder item, opening a UI on use. The UI can wipe the existing key memory of any vehicle- making all current keys for that vehicle become useless. The encoder UI is also capable of turning a blankvehiclekey into a working vehiclekey for the current vehicle. Security upgrade items can be applied to any player-owned vehicle, either automated through shop purchase (coming with TebIT: Vehicle Customs), or using an item while inside a vehicle. Security upgrades add an extra layer of protection (stackable), to deter/prevent improperly equipped thieves from stealing your vehicle.

Setup

Config

All of the config vars found below are stored within the config.lua file.

config = {
    -- % chance that you can enter a parked civ vehicle
    parkedVehUnlockChance = 0,  

    -- Lockpick configuration
    lockpickItem = "lockpick",
    loseLockpickFailChance = 100.0,
    loseLockpickSuccessChance = 0.0,

    -- Hotwire configuration
    hotwireTimeMin = 3000,
    hotwireTimeMax = 5000,
    hotwireCooldown = 5000,
    hotwireChance = 30,
    hotwireKeybind = "H",

    -- Chance of alarm on hotwire
    alarmTimeMin = 3000,
    alarmTimeMax = 5000,
    alarmCooldown = 30000,
    alarmChance = 100,

    -- Car jacking configuration
    jackTimeMin = 4000,
    jackTimeMax = 4000,
    jackCooldown = 10000, 

    -- security categories for vehicles, and corresponding security items and hacking/removal items.
    -- note: category names are arbitrary, you can add as many as you like.
    -- note: you can stack categories, you can't stack items from the same category.
    securityCategories = {
        immobilizer = { 
            upgradeItems = {
                -- upgrade item names also arbitrary, aslong as they don't conflict with another resource, add as many as you like.
                ["immobilizer1"] = {
                    label = "Tier 1 Immobilizer",                                           -- item label
                    description = "A mechanic can upgrade your vehicle with this item.",    -- item description (OPTIONAL)
                    image = "electronickit.png",                                            -- item image       (OPTIONAL)
                    weight = 0,                                                             -- item weight      (OPTIONAL)

                    removalTimeMin = 4000,                                                  -- time to remove (min)
                    removalTimeMax = 7000,                                                  -- time to remove (min)
                    removalChance = 50.0,                                                   -- percentage chance of removal (0-100)
                    cooldown = 5000,                                                        -- time between removal attempts
                    alarmOnFail = false                                                     -- trigger car alarm on fail
                },
                ["immobilizer2"] = {
                    label = "Tier 2 Immobilizer",

                    removalTimeMin = 4000,
                    removalTimeMax = 7000,
                    removalChance = 10.0,
                    cooldown = 10000,
                    alarmOnFail = true
                }
            },

            hackingItems = {
                -- hacking item names also arbitrary, aslong as they don't conflict with another resource, add as many as you like.
                ["thefttoolkit"] = {
                    label = "Theft Toolkit",
                    description = "Used for naughty things.",
                    image = "electronckit.png",
                    weight = 0,

                    timeMultiplier = 1.0,           -- multiply item removal time * this value on item use
                    chanceMultiplier = 1.0          -- multiply item chance * this value on item use
                },

                ["hackinglaptop"] = {
                    label = "Hacking Laptop",

                    timeMultiplier = 2.0,
                    chanceMultiplier = 10.0               
                },
            }
        }
    },

    -- Chance for vehicle theft to succeed based on weapon used
    jackChance = {
        [2685387236]  = 0,   -- melee
        [416676503]   = 50,  -- handguns
        [337201093]   = 75,  -- SMG
        [860033945]   = 90,  -- shotgun
        [970310034]   = 90,  -- assault
        [1159398588]  = 99,  -- LMG
        [3082541095]  = 99,  -- sniper
        [2725924767]  = 99,  -- heavy
        [1548507267]  = 0,   -- throwable
        [4257178988]  = 0,   -- misc
    },

    -- These weapons can't be used to jack a vehicle.
    noJackWeapons = {
        "WEAPON_UNARMED",
        "WEAPON_Knife",
        "WEAPON_Nightstick",
        "WEAPON_HAMMER",
        "WEAPON_Bat",
        "WEAPON_Crowbar",
        "WEAPON_Golfclub",
        "WEAPON_Bottle",
        "WEAPON_Dagger",
        "WEAPON_Hatchet",
        "WEAPON_KnuckleDuster",
        "WEAPON_Machete",
        "WEAPON_Flashlight",
        "WEAPON_SwitchBlade",
        "WEAPON_Poolcue",
        "WEAPON_Wrench",
        "WEAPON_Battleaxe",
        "WEAPON_Grenade",
        "WEAPON_StickyBomb",
        "WEAPON_ProximityMine",
        "WEAPON_BZGas",
        "WEAPON_Molotov",
        "WEAPON_FireExtinguisher",
        "WEAPON_PetrolCan",
        "WEAPON_Flare",
        "WEAPON_Ball",
        "WEAPON_Snowball",
        "WEAPON_SmokeGrenade",
    },

    -- vehicles that wont be automatically locked
    autoLockBlacklist = {
        'BUFFALO',
    },

    -- vehicles that can't be jacked
    jackBlacklist = {
        'BUFFALO',
    },

    -- jobs capable of encoding new (and removing or wiping) keys with a transponder encoder
    encodingJobs = {
        mechanic = 2,
        police = 0,
    },

    -- jobs that auto-vehicle locking won't necessarily apply to.
    -- note: this isn't guaranteed to work 100% of time.
    commandeerJobs = {
        police = 2,
    },
}

Labels

All labels and translations can be found within the labels.lua file.

labels = {
    invalidInterior = "Invalid interior.",
    notEnoughMoney = "Not enough money.",
    ...
}

Usage

  • Check the comments in config.lua for a working example of this system. Any further questions should be taken to our discord.

  • All translations are handled in the labels.lua file.

  • The database is contained within the db/vehicles.json file. Consider creating a backup file before making any changes.

  • Inventory items will be added automatically for mf-inventory and qb-inventory as required.

  • If you're using ox_inventory, add the following to ox_inventory/data/items.lua:

  -- ti_vehicleKeys
  ['vehiclekey'] = {  
    label = 'Vehicle Key',
    weight = 50,
    stack = false
  },

  ['blankvehiclekey'] = {       
    label = 'Blank Vehicle Key',    
    weight = 50,
    stack = true
  },

  ['transponderencoder'] = {   
    label = 'Transponder Encoder',  
    weight = 500,
    stack = false
  },

  ['immobilizer1'] = {          
    label = 'Immobilizer Tier 1',     
    weight = 1500,
    stack = false 
  },

  ['immobilizer2'] = {         
    label = 'Immobilizer Tier 2',   
    weight = 1500,
    stack = false  
  },

  ['thefttoolkit'] = {          
    label = 'Basic Toolkit',   
    weight = 1500,
    stack = false      
  },

  ['hackinglaptop'] = {       
    label = 'Hacking Laptop',     
    weight = 1500,
    stack = false 
  },

Dependencies

         qb-core with qb-inventory
  OR es_extended with ox_inventory
  OR es_extended with mf-inventory

Conflicting Resources

  • Any other keys resource.

  • Any other "vehicle security" resource.

  • Basically anything that effects the locked status of the vehicle.

Example

All events are prefixed with "ti_vehicleKeys:", and exports are registered under the same namespace without the prefix.

RegisterCommand("createKeys",function(source,args)    
    local targetPlayer = source
    local vehiclePlate = args[1] or "ABC 123"

    exports["ti_vehicleKeys"]:createKey(targetPlayer,vehiclePlate)
    -- Or
    TriggerEvent("ti_vehicleKeys:createKey",targetPlayer,vehiclePlate)
end)

Video

Last updated