Kartik Scripts

mayWearItem

Whether one player is currently allowed to wear one garment, according to the item lock rules. Resolves the player's job, grade and citizen id server side, so the answer is authoritative.


๐Ÿ’ก Syntax

local allowed = exports['kartik-clothing']:mayWearItem(src, kind, itemId, drawable, texture, gender)

๐Ÿ“ฅ Parameters

ParameterTypeOptionalDescription
srcnumberNoThe player's server id.
kindstringNo'component' or 'prop'.
itemIdnumberNoThe component or prop slot id.
drawablenumberNoDrawable index.
texturenumberYesTexture index. Omit to ask about the drawable generally.
genderstringYes'male' or 'female'. Defaults to the ped the player is actually on, which is almost always what you mean.

๐Ÿ“ค Returns

TypeDescription
booleantrue if the player may wear it.

๐Ÿ’ป Example

RegisterNetEvent('my-jobs:issueUniform', function()
    local src = source

    if not exports['kartik-clothing']:mayWearItem(src, 'component', 11, 84) then
        return TriggerClientEvent('ox_lib:notify', src, {
            description = 'You are not cleared for that uniform.',
            type = 'error'
        })
    end

    -- issue it
end)

[!NOTE] A lock with no rules is wearable by nobody, so a half-finished lock returns false. Config.ItemLocksAdminBypass decides whether admins are exempt.

On this page