cd_garage

Improve cd_garage's compatibility with our Chop Shop

If you are looking to improve the compatibility of our Chop Shop script with cd_garage, then you are in the right spot! Below we'll describe how you can disable the ability to lockpick a vehicle as normal ensuring that your Chop Shop vehicle's are only unlockable through the proper means!

Step 1 - Getting Started

This process is very simple, but let's try to explain what we're going to accomplish here so you understand. We're going to use an export from our Exports page to determine if the player is currently in a chopping mission. The export is:

exports.lation_chopshop:IsChopping()

What this does is when used in a line of code is returns true or false. It will return true if the player is currently in a chopping mission and if so, will verify the vehicle closest to them is the same model as the vehicle model assigned to them - otherwise it just returns false, allowing them to continue as normal. We can use this export to stop the players from completing certain actions, such as lockpicking a vehicle the normal method to ensure they use the proper method.

Since we're talking about cd_garage specifically here, let's show you how to implement this into cd_garage properly.

Step 2 - Open cd_garage

Navigate to your server resources folder, find your cd_garage folder and open client/other/keys.lua. We need to find the cd_garage:LockpickVehicle event, which currently is on line 389 and looks like this:

RegisterNetEvent('cd_garage:LockpickVehicle')
AddEventHandler('cd_garage:LockpickVehicle', function(used_usable_item)
    local vehicle = GetClosestVehicle(5)
    if vehicle then
        local plate = GetPlate(vehicle)
        CacheVehicle(plate, vehicle)
        if not KeysTable[plate].has_key then
            local lock = GetVehicleDoorLockStatus(vehicle)
            if lock > 1 then
                if used_usable_item then
                    TriggerServerEvent('cd_garage:LockpickVehicle:RemoveItem')
                end
                LockpickAnimation(vehicle)
                StartCarAlarm(vehicle)
                local hacking = exports['cd_keymaster']:StartKeyMaster()
                if hacking then
                    UnLockVehicle(vehicle, false)
                else
                    Notif(3, 'lockpicking_failed')
                end
                ClearPedTasks(PlayerPedId())
                doing_animation = false
            else
                Notif(3, 'vehicle_not_locked')
            end
        else
            Notif(3, 'cant_lockpick_have_keys')
        end
    else
        Notif(3, 'no_vehicle_found')
    end
end)

All we need to do is add our export here to the first line to stop them from lockpicking the vehicle the normal way when they are in a chopping mission. We can do that by simply editing this event to look like this:

RegisterNetEvent('cd_garage:LockpickVehicle')
AddEventHandler('cd_garage:LockpickVehicle', function(used_usable_item)
    if exports.lation_chopshop:IsChopping() then return end -- Add export here
    local vehicle = GetClosestVehicle(5)
    if vehicle then
        local plate = GetPlate(vehicle)
        CacheVehicle(plate, vehicle)
        if not KeysTable[plate].has_key then
            local lock = GetVehicleDoorLockStatus(vehicle)
            if lock > 1 then
                if used_usable_item then
                    TriggerServerEvent('cd_garage:LockpickVehicle:RemoveItem')
                end
                LockpickAnimation(vehicle)
                StartCarAlarm(vehicle)
                local hacking = exports['cd_keymaster']:StartKeyMaster()
                if hacking then
                    UnLockVehicle(vehicle, false)
                else
                    Notif(3, 'lockpicking_failed')
                end
                ClearPedTasks(PlayerPedId())
                doing_animation = false
            else
                Notif(3, 'vehicle_not_locked')
            end
        else
            Notif(3, 'cant_lockpick_have_keys')
        end
    else
        Notif(3, 'no_vehicle_found')
    end
end)

Step 3 - Done

After adding in our export we can save, restart our server & try again - you'll notice now you will not be able to lockpick this vehicle via the normal method while you are in a chopping mission. You will have to use the proper method! However, with recent improvements, this export will allow you to continue to lockpick vehicles that are not your assigned chop vehicle. Hope this helped!

Last updated