Code Snippets
This purpose of this page is to automate as much as possible so customers can solve problems their self without needing to open discord support tickets.

Note: Not all of these code snippets are guaranteed to work for your server. They are code snippets provided by the Codesign Development Team that were requested by the community for their specific use case or provided to us by the community for their specific use case. We post them here in the event that you may find them useful.

If you currently use esx version 1.1 and you are wanting to switch to esx version 1.final, you can use this chat command to migrate your players bank/cash from the money and bank column to the accounts column (assuming you have already added the accounts column inside the users database table).
RegisterCommand('esx_1final', function(source)
if source == 0 then
local database_result = DatabaseQuery('SELECT identifier, money, bank FROM users')
for cd = 1, #database_result do
SQL('UPDATE users SET [email protected] WHERE [email protected]', {['@accounts'] = json.encode({black_money = 0, money = database_result[cd].money or 0, bank = database_result[cd].bank or 0}), ['@identifier'] = database_result[cd].identifier})
print(string.format('^1%s^0/^1%s^0 ^3Identifier:^0 %s ^3Money:^0 %s ^3Bank:^0 %s^0', cd, #database_result, database_result[cd].identifier, database_result[cd].money or 0, database_result[cd].bank or 0))
end
end
end)

We have permission from each resource developer to post these code snippets below.

Allhousing compatibility with the Codesign Garage.
Inside the menus_esx.lua replace the existing 2 functions with the ones provided below.
ESXGarageOwnerMenu
ESXGarageOwnedMenu
ESXGarageOwnerMenu = function(d)
local ped = GetPlayerPed(-1)
if IsPedInAnyVehicle(ped,false) then
local veh = GetVehiclePedIsUsing(ped)
local props = GetVehicleProperties(veh)
local ownerInfo = Callback("Allhousing:GetVehicleOwner",props.plate)
local canStore = false
local identifier = GetPlayerIdentifier()
if d.Owner == identifier then
canStore = true
else
for k,v in pairs(d.HouseKeys) do
if v.identifier == identifier then
canStore = true
break
end
end
end
if canStore then
local doStore = false
if ownerInfo.owned and ownerInfo.owner then
doStore = true
elseif ownerInfo.owned and Config.StoreStolenPlayerVehicles then
doStore = true
end
if doStore then
TriggerEvent('cd_garage:StoreVehicle_Main', 1, false)
TriggerServerEvent("Allhousing:VehicleStored",d.Id,props.plate,props)
ShowNotification(Labels["VehicleStored"])
else
ShowNotification(Labels["CantStoreVehicle"])
end
else
ShowNotification(Labels["CantStoreVehicle"])
end
FreezeEntityPosition(GetPlayerPed(-1),false)
else
ESX.UI.Menu.Open( 'default', GetCurrentResourceName(), 'choosegarage', -- Replace the menu name
{
title = ('Garage'),
align = 'center', -- Menu position--top-left
elements = { -- Contains menu elements
{label = ('Inside Garage'), value = 'ingarage'},
{label = ('Outside Garage'), value = 'outgarage'}
}
},
function(data, menu) -- This part contains the code that executes when you press enter
if data.current.value == 'ingarage' then
TriggerEvent('cd_garage:PropertyGarage', 'inside')
menu.close()
FreezeEntityPosition(GetPlayerPed(-1),false)
elseif data.current.value == 'outgarage' then
TriggerEvent('cd_garage:PropertyGarage', 'quick')
menu.close()
FreezeEntityPosition(GetPlayerPed(-1),false)
end
end,
function(data, menu) -- This part contains the code that executes when the return key is pressed.
menu.close() -- Close the menu
FreezeEntityPosition(GetPlayerPed(-1),false)
end
)
end
end
ESXGarageOwnedMenu = function(d)
local plyPed = GetPlayerPed(-1)
if IsPedInAnyVehicle(plyPed,false) then
local veh = GetVehiclePedIsUsing(plyPed)
local props = GetVehicleProperties(veh)
local ownerInfo = Callback("Allhousing:GetVehicleOwner",props.plate)
local canStore = false
local identifier = GetPlayerIdentifier()
if d.Owner == identifier then
canStore = true
else
for k,v in pairs(d.HouseKeys) do
if v.identifier == identifier then
canStore = true
break
end
end
end
if canStore then
local doStore = false
if ownerInfo.owned and ownerInfo.owner then
doStore = true
elseif ownerInfo.owned and Config.StoreStolenPlayerVehicles then
doStore = true
end
if doStore then
TriggerEvent('cd_garage:StoreVehicle_Main', 1, false)
TriggerServerEvent("Allhousing:VehicleStored",d.Id,props.plate,props)
ShowNotification(Labels["VehicleStored"])
else
ShowNotification(Labels["CantStoreVehicle"])
end
else
ShowNotification(Labels["CantStoreVehicle"])
end
FreezeEntityPosition(GetPlayerPed(-1),false)
else
local myId = GetPlayerIdentifier()
for k,v in pairs(d.HouseKeys) do
if v.identifier == myId then
DoOpenESXGarage(d)
return
end
end
if not Config.GarageTheft then
FreezeEntityPosition(GetPlayerPed(-1),false)
return
end
if Config.LockpickRequired then
local hasItem = CheckForLockpick()
if not hasItem then
ShowNotification(Labels['NoLockpick'])
FreezeEntityPosition(GetPlayerPed(-1),false)
return
end
end
while not HasAnimDictLoaded("[email protected]_cracking") do RequestAnimDict("[email protected]_cracking"); Citizen.Wait(0); end
TaskPlayAnim(plyPed, "[email protected]_cracking", "idle_base", 1.0, 1.0, -1, 1, 0, 0, 0, 0 )
Wait(2000)
if Config.UsingLockpickV1 then
TriggerEvent("lockpicking:StartMinigame",4,function(didWin)
if didWin then
ClearPedTasksImmediately(plyPed)
DoOpenESXGarage(d)
else
ClearPedTasksImmediately(plyPed)
TriggerServerEvent("Allhousing:BreakLockpick")
end
FreezeEntityPosition(GetPlayerPed(-1),false)
end)
elseif Config.UsingLockpickV2 then
exports["lockpick"]:Lockpick(function(didWin)
if didWin then
ClearPedTasksImmediately(plyPed)
DoOpenESXGarage(d)
ShowNotification(Labels["LockpickSuccess"])
else
ClearPedTasksImmediately(plyPed)
TriggerServerEvent("Allhousing:BreakLockpick")
ShowNotification(Labels["LockpickFailed"])
end
FreezeEntityPosition(GetPlayerPed(-1),false)
end)
else
if Config.UsingProgressBars then
exports["progressBars"]:startUI(Config.LockpickTime * 1000,Labels["ProgressLockpicking"])
end
Wait(Config.LockpickTime * 1000)
if math.random(100) < Config.LockpickFailChance then
local plyPos = GetEntityCoords(GetPlayerPed(-1))
local zoneName = GetNameOfZone(plyPos.x,plyPos.y,plyPos.z)
if Config.LockpickBreakOnFail then
TriggerServerEvent("Allhousing:BreakLockpick")
end
ShowNotification(Labels["LockpickFailed"])
for k,v in pairs(Config.PoliceJobs) do
TriggerServerEvent("Allhousing:NotifyJobs",k,"Someone is attempting to break into a garage at "..zoneName)
end
ClearPedTasksImmediately(plyPed)
else
ShowNotification(Labels["LockpickSuccess"])
ClearPedTasksImmediately(plyPed)
DoOpenESXGarage(d)
end
FreezeEntityPosition(GetPlayerPed(-1),false)
end
end
end

SSComplete Housing compatibility with the Codesign Garage.
Inside the config.lua replace the existing Config.Parking table with the one provided below.
Config.Parking = {
ScriptParking = true, -- SET TRUE TO USE SCRIPT PARKING FOR EACH HOME(SELECT PARKING TYPE PER HOUSE IN GAME), SET FALSE TO USE A PRIVATE PARKING SYSTEM(FUNCTION CHOSEN IN CONFIG.CREATION TABLE)
AllowAll = true, -- SET TRUE TO ALLOW ANYONE TO PARK IN ANY OWNED PARKING SPOT, FALSE TO ALLOW ONLY THE OWNER OR KEY HOLDER
AllowNil = true, -- SET TRUE TO ALLOW PLAYERS TO USE NON-OWNED HOME PARKING SPOTS
GarageStoreEvent = function(ped, veh)
TriggerEvent('cd_garage:StoreVehicle_Main', 1, false)
end,
GarageOpenEvent = function(location)
TriggerEvent('cd_garage:PropertyGarage', 'quick')
end
}

Loaf Housing compatibility with the Codesign Garage.
In the latest version of Loaf Housing compatibility has been added by default.
Copy link
On this page
Snippets
ESX v1.1 to v1.final (accounts)
Housing Scripts & CD Garage
Allhousing v2
SSComplete Housing
Loaf Housing