# Wert Weapon Racks (Deployable, Advanced)

## <mark style="background-color:orange;">INSTALLATION</mark>

1 - Upload the script folder to the location of your resources

2 - Check config file for your own settings

3 - Please add the items to your list in the items section below

4 - Add the data inside the SQL extension file to your database.

5 - **Installation successful, have a good funs**

## ITEMS

```lua
-- Default items

["rack_1"] = {
		["name"] = "rack_1",
		["label"] = "Gun Rack",
		["weight"] = 0,
		["type"] = "item",
		["image"] = "rack_1.png",
		["unique"] = true,
		["useable"] = true,
		["shouldClose"] = true,
		["combinable"] = nil,
		["description"] = ""
},
["rack_2"] = {
		["name"] = "rack_2",
		["label"] = "Gun Rack",
		["weight"] = 0,
		["type"] = "item",
		["image"] = "rack_2.png",
		["unique"] = true,
		["useable"] = true,
		["shouldClose"] = true,
		["combinable"] = nil,
		["description"] = ""
},

```

{% file src="/files/98PF351Tz8238Gs2TZWs" %}

## <mark style="background-color:purple;">OX LIB OPTION</mark>

There are many ox settings available in the files, if you want, you can configure them.

<figure><img src="/files/vtw8pwOzOcBUeJ3hAywl" alt=""><figcaption></figcaption></figure>

If you want to use ox\_lib, please check if this link is enabled on fxmanifest.check it out from inside lua. this must be turned on before you can use ox\_lib. After opening it, it will be enough to use the refresh and ensure commands.

<figure><img src="/files/YlyrqOOgBsXa0VCQXNeb" alt=""><figcaption></figcaption></figure>

## <mark style="background-color:yellow;">EXPORTS</mark>&#x20;

Client side exports

```lua
-- # Current rack
local currentRack = exports['wert-gunrack']:GetCurrentRack()
-- Output : rack id like (default_rack_1, default_rack_2, default_rack_3 ... or others)

-- # Armed active
local isArmed = exports['wert-gunrack']:ArmedActive()
-- You can check whether the player is at the stage of placing the weapon on the rack
-- Output : isArmed = wep object (entity) | If you want control you can use like this if isArmed then print("Player armed") else print("Player not armed") end

-- # Placement Active
local inPlacement = exports['wert-gunrack']:PlacementActive()
-- You can check whether the player is at the stage of placing a rack
-- Output : boolean

-- # IN Rack ui
local inPlacement = exports['wert-gunrack']:InRackUI()
-- You can check whether the player is in the weapon rack interface.
-- Output : boolean
```

## <mark style="background-color:blue;">OPEN FILES</mark>

```lua
Config = {}

Config.OxInventory = false -- If you use ox inventory please set true
Config.OxLib = true
Config.UseTarget = true
Config.RackTargetDistance = 1.5
Config.DebugPoly = false
Config.PutWeaponDistance = 1.8
Config.EnableOutline = true
Config.OutlineColor = {255, 255, 255, 255}
Config.InRackOutlineColor = {69, 250, 61, 255}
Config.DefaultRotation = {0.0, -90.0, 0.0}
Config.WhenRemoveRackGiveBackItem = true

Config.ChangeSlotKeys = {
    left = 174,
    right = 175,
}
Config.PutRackkey = 38
Config.NoTargetInteractKey = 47 -- Default [G]

Config.DefaultIcon = 'fa-regular fa-hand'
Config.RemoveRackIcon = "fa-regular fa-trash-can"

Config.RackSettings = {
    [`prop_cs_gunrack`] = {
        slots = {
            {-0.572, 0.0, 0.06},
            {-0.445, 0.0, 0.06},
            {-0.317, 0.0, 0.06},
            {-0.190, 0.0, 0.06},
            {-0.063, 0.0, 0.06},
            {0.064, 0.0, 0.06},
            {0.195, 0.0, 0.06},
            {0.322, 0.0, 0.06},
            {0.449, 0.0, 0.06},
            {0.576, 0.0, 0.06}
        },
        special = {
            -- Through this table, you can provide visual completeness by editing the y and z offset values of weapons that do not fit perfectly on the shelf.
            groups = {
                -- Gun groups, You can set specific y and z offset value for each weapon group 
                -- Gun Groups : https://docs.fivem.net/natives/?_0xC3287EE3050FB74C
                -- Example :
                [`GROUP_PISTOL`] = {y = 0.0, z = -0.18},
            },
            models = {
                -- Gun hashes, You can set spesific y and z offset value for each weapon
                -- Note : Even if a pistol group is entered above, it will use it because a special value is specified for the model here.
                -- [`weapon_pistol`] = {y = 0.0, z = -0.18},
                [`weapon_stungun`] = {y = 0.0, z = -0.22},
            }
        },
    },
    [`xm_prop_xm_gunlocker_01a`] = {
        slots = {
            {-0.400, 0.0, 0.9},
            {-0.290, 0.0, 0.9},
            {-0.170, 0.0, 0.9},
            {-0.060, 0.0, 0.9},
            {0.055, 0.0, 0.9},
        },
        special = {
            -- Through this table, you can provide visual completeness by editing the y and z offset values of weapons that do not fit perfectly on the shelf.
            groups = {
                -- Gun groups, You can set specific y and z offset value for each weapon group 
                -- Gun Groups : https://docs.fivem.net/natives/?_0xC3287EE3050FB74C
                -- Example :
                [`GROUP_PISTOL`] = {y = 0.0, z = 0.7},
                [`GROUP_RIFLE`] = {y = 0.0, z = 0.78},
            },
            models = {
                -- Gun hashes, You can set spesific y and z offset value for each weapon
                -- Note : Even if a pistol group is entered above, it will use it because a special value is specified for the model here.
                -- [`weapon_pistol`] = {y = 0.0, z = -0.18},
                [`weapon_stungun`] = {y = 0.0, z = 0.65},
            }
        },
    },
}

Config.DefaultRacks = {
    -- If you want add default racks here like example template
    -- Polices
    {
        id = "default_rack_1", -- IMPORTANT = If you want save weapons for after restart (server or script) you need set correct this (Each rack must have different id)
        model = `prop_cs_gunrack`,
        coord = vector4(480.43, -996.76, 30.0, 91.0),
        job = "police", -- | If you want to make everyone remove this line or set nil
        label = "Police Station Gun Rack",
        icon = "fa-solid fa-shield"
    },
    {
        id = "default_rack_2",
        model = `xm_prop_xm_gunlocker_01a`,
        coord = vector4(487.66, -1015.29, 29.69, 181.0),
        job = "police", -- | If you want to make everyone remove this line or set nil
        label = "Police Station Polygon Rack",
        icon = "fa-solid fa-shield"
    },
    {
        id = "default_rack_3", -- IMPORTANT = If you want save weapons for after restart (server or script) you need set correct this (Each rack must have different id)
        model = `prop_cs_gunrack`,
        coord = vector4(439.67, -998.09, 34.28, 90.0),
        job = "police", -- | If you want to make everyone remove this line or set nil
        label = "Police Station Monitor Rack",
        icon = "fa-solid fa-shield"
    },
    {
        id = "default_rack_4", -- IMPORTANT = If you want save weapons for after restart (server or script) you need set correct this (Each rack must have different id)
        model = `prop_cs_gunrack`,
        coord = vector4(465.39, -982.4, 43.0, 0),
        job = "police", -- | If you want to make everyone remove this line or set nil
        label = "Police Station Helicopter Rack",
        icon = "fa-solid fa-shield"
    },
    -- Ambulances
    {
        id = "default_rack_5", -- IMPORTANT = If you want save weapons for after restart (server or script) you need set correct this (Each rack must have different id)
        model = `prop_cs_gunrack`,
        coord = vector4(309.94, -602.97, 42.60, 250),
        job = "ambulance", -- | If you want to make everyone remove this line or set nil
        label = "Hospital Rack",
        icon = "fa-regular fa-hand-back-fist"
    },
}

-- # Image Settings
Config.UseInventoryImages = true
Config.InventoryImageLocation = 'qb-inventory/html/images'
Config.CustomImages = {
    -- Hash = png
    [`weapon_pistol`] = "customurl.png",
}

-- # Items
Config.RackItems = {
    -- If you want create more placable item in config
    {item = "rack_1", model = `prop_cs_gunrack`},
    {item = "rack_2", model = `xm_prop_xm_gunlocker_01a`},
}

-- If you want add here more weapon
Config.WhitelistedWeapons = {
    -- PISTOLS
    `weapon_pistol`, 		
    `weapon_pistol_mk2`,
    `weapon_combatpistol`,
    `weapon_appistol`,
    `weapon_stungun`,
    `weapon_pistol50`,
    `weapon_snspistol`,
    `weapon_snspistol_mk2`,
    `weapon_heavypistol`,
    `weapon_vintagepistol`,
    `weapon_flaregun`,
    `weapon_marksmanpistol`,
    `weapon_revolver`,
    `weapon_revolver_mk2`,
    `weapon_doubleaction`,
    `weapon_raypistol`,
    `weapon_ceramicpistol`,
    `weapon_navyrevolver`,
    `weapon_gadgetpistol`,
    `weapon_stungun_mp`,

    -- SMG
    `weapon_microsmg`,
    `weapon_smg`,		
    `weapon_smg_mk2`, 		
    `weapon_assaultsmg`, 	
    `weapon_combatpdw`,	
    `weapon_machinepistol`, 
    `weapon_minismg`,
    `weapon_raycarbine`,
    
    -- RIFLE
    `weapon_assaultrifle`,
    `weapon_assaultrifle_mk2`, 
    `weapon_carbinerifle`,
    `weapon_carbinerifle_mk2`, 
    `weapon_advancedrifle`,	
    `weapon_specialcarbine`, 	
    `weapon_specialcarbine_mk2`,
    `weapon_bullpuprifle`,
    `weapon_bullpuprifle_mk2`,	
    `weapon_compactrifle`,
    `weapon_militaryrifle`,	
    `weapon_heavyrifle`,
    
    -- SHOTGUN
    `weapon_pumpshotgun`,
    `weapon_pumpshotgun_mk2`,	
    `weapon_sawnoffshotgun`,	
    `weapon_assaultshotgun`, 	
    `weapon_bullpupshotgun`, 	
    `weapon_musket`,	
    `weapon_heavyshotgun`, 	
    `weapon_dbshotgun`,		
    `weapon_autoshotgun`, 		
    `weapon_combatshotgun`,
    
    -- SNIPER
    `weapon_sniperrifle`,	
    `weapon_heavysniper`, 		
    `weapon_heavysniper_mk2`,	
    `weapon_marksmanrifle`,	
    `weapon_marksmanrifle_mk2`,
    `weapon_remotesniper`,
}
```

```lua
local QBCore = exports['qb-core']:GetCoreObject()

function CustomNotifVariation(text, style, time)
    QBCore.Functions.Notify(text, style, time)
end

function CustomTargetAddRackInteraction(data)
    local options = {}
    options[#options+1] = {
        event = data.event,
        icon = data.icon,
        label = data.label,
        rackid = data.id,
        job = data.job
    }
    if data.owner then
        options[#options+1] = {
            event = "wert-gunrack:client:remove-rack",
            icon = Config.RemoveRackIcon,
            label = LANG.remove_rack,
            rackid = data.id,
        }
    end
    exports["qb-target"]:AddTargetEntity(data.obj, {options = options, distance = Config.RackTargetDistance})
end

function ShowPlaceInput()
    if Config.OxLib then
        local dialog = lib.inputDialog(LANG.input.title, {
            {type = 'input', label = LANG.input.label, description = LANG.input.description, required = true},
        })
        return dialog
    else
        local dialog = exports['qb-input']:ShowInput({
            header = LANG.input.title,
            submitText = LANG.input.confirm,
            inputs = {
                {
                    text = LANG.input.label,
                    name = "label",
                    type = "text",
                    isRequired = true
                },
            },
        })
        return dialog
    end
end

function ShowTextUI(text, icon)
    if Config.OxLib then
        lib.showTextUI(text, {position = 'left-center', icon = icon})
    else
        exports['qb-core']:DrawText(text, 'left')
    end
end

function HideTextUI()
    if Config.OxLib then
        lib.hideTextUI()
    else
        exports['qb-core']:HideText()
    end
end

RegisterNetEvent('wert-gunrack:client:custom-notif', function(text, style, time)
    CustomNotifVariation(text, style, time)
end)
```

```lua
local QBCore = exports['qb-core']:GetCoreObject()

function GetWeaponComponentDescriptions(info)
    local result = ""
    if info and info.attachments then
        for k,v in pairs(info.attachments) do
            if v and v.label then
                print(v.label)
                if result == "" then
                    result = v.label
                else
                    result = result .. ", " .. v.label
                end
            end
        end
    end
    if result == "" then result = LANG.not_found_attachment end
    return result
end


-- # Items
for i=1, #Config.RackItems do
    local item = Config.RackItems[i]
    QBCore.Functions.CreateUseableItem(item.item, function(src, item)
        TriggerClientEvent("wert-gunrack:client:start-placament", src, i)
    end)
end
```

```lua
LANG = {
	error = {
        rack_full = "Rack Full!",
        rack_not_found = "Rack Not Found!",
        slot_not_found = "Slot Not Found!",
        slot_busy = "This slot busy!",
        labelerror = "Please Set Correct Label!",
    },
    left_arrow_icon = '<i class="fa-solid fa-arrow-left"></i>',
    right_arrow_icon = '<i class="fa-solid fa-arrow-right"></i>',
    put_rack_key = "E",
    change_place = "Change Place",
    putrack = "Put Rack",
    placement = {
        header = "Placement Keyboard",
        arrow_up = '<i class="fa-solid fa-arrow-up"></i>',
        arrow_left = '<i class="fa-solid fa-arrow-left"></i>',
        arrow_right = '<i class="fa-solid fa-arrow-right"></i>',
        arrow_desc = "MOVE",
        zkey = "Z",
        z_desc = "Reduce Height",
        qkey = "Q",
        ekey = "E",
        rotate = "Rotate",
        ctrl = "CTRL",
        shift = "SHIFT",
        right_dip = "Right Dip",
        left_dip = "Left Dip",
        fixground = "Fix Ground",
        finish = "Finish",
        cancel = "Cancel",
        space = "SPACE",
        enter = "ENTER",
        backspace = "BACKSPACE"
    },
    input = {
        title = "Complete Rack Placement",
        label = 'Rack Label',
        description = 'Set label here',
        confirm = "Confirm",
    },
    remove_rack = "Remove Rack",
    rack_removed = "Rack Succcesfuly Removed!",
    default_rack_label = "Gun Rack",
    no_target_interaction_preset = "[G]",
    take_weapon = "Take Weapon",
    not_found_attachment = 'Weapon not have any attachment!',
}
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wert-dev.gitbook.io/wert-dev-docs/products/qbcore/wert-weapon-racks-deployable-advanced.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
