Início › Documentação › Personalização · origen_clothing

Personalização · origen_clothing

A pasta custom/ permite-te integrar qualquer framework, notificação ou lógica de acesso às lojas sem mexer no núcleo. Todos os ficheiros são escrow_ignore, por isso mantêm-se após as atualizações.

text
custom/
├── client/
│   ├── framework.lua  — player identifier, job, gender, loaded state
│   ├── notify.lua     — notifications and text UI
│   ├── store.lua      — gate who can open a store
│   └── visuals.lua    — hide/show HUD when clothing menu opens
└── server/
    ├── framework.lua  — player identifier, job, money, permissions, group, gender
    └── permissions.lua — admin check

custom/client/framework.lua

Custom.GetPlayerIdentifier() → string | nil

Devolve o identificador único do jogador local (citizenid / identifier).

lua
Custom.GetPlayerIdentifier = function()
    -- Config.Framework == 'custom': implement here
    return nil
end

Custom.GetJob() → { name, grade }

Devolve o nome do trabalho atual do jogador local e o respetivo nível de grau.

lua
Custom.GetJob = function()
    return { name = 'unemployed', grade = 0 }
end

Framework.GetGender() → number

Devolve o género do jogador local. 0 = masculino, 1 = feminino.

lua
Framework.GetGender = function()
    -- Config.Framework == 'custom': implement here
end

Framework.isPlayerLoaded() → boolean

Devolve true quando os dados do jogador estão prontos e carregados.

lua
Framework.isPlayerLoaded = function()
    return false
end

custom/client/notify.lua

Custom.Notify(text, type, length)

Mostra uma notificação ao jogador local.

lua
Custom.Notify = function(text, type, length)
    lib.notify({
        description = text,
        type        = type,     -- 'info' | 'success' | 'error'
        duration    = length,
    })
end

Custom.DrawText(text, key)

Mostra uma indicação de interação com text UI.

lua
Custom.DrawText = function(text, key)
    lib.showTextUI('[' .. key .. '] - ' .. text)
end

Custom.HideText()

Oculta a indicação de text UI.

lua
Custom.HideText = function()
    lib.hideTextUI()
end

custom/client/store.lua

Custom.CanOpenStore(storeId) → boolean

Controla se o jogador local pode abrir uma loja específica. É chamada antes de abrir a interface da loja.

lua
Custom.CanOpenStore = function(storeId)
    -- Example: only allow police job to open store ID 1
    -- if storeId == 1 then
    --     return Custom.GetJob().name == 'police'
    -- end
    return true
end

custom/client/visuals.lua

Custom.HideVisuals(state)

É chamada quando o menu de roupa abre (state = true) ou fecha (state = false). Usa-a para ocultar ou mostrar o teu HUD, radar, minimapa, etc.

lua
Custom.HideVisuals = function(state)
    -- Example:
    -- DisplayRadar(not state)
    -- SendNUIMessage({ type = 'hud', visible = not state })
end

custom/server/framework.lua

Custom.GetIdentifier(source) → string | nil

Devolve o identificador único de um jogador no servidor.

lua
Custom.GetIdentifier = function(source)
    -- Config.Framework == 'custom': implement here
    return nil
end

Custom.GetMoney(source, paymentMethod) → number

Devolve o saldo do jogador para o método de pagamento indicado. Se o método for inválido, usa Config.DefaultPaymentMethod.

lua
Custom.GetMoney = function(source, paymentMethod)
    return 0
end

Custom.RemoveMoney(source, amount, paymentMethod)

Desconta dinheiro da conta do jogador.

lua
Custom.RemoveMoney = function(source, amount, paymentMethod)
end

Custom.GetJob(source) → { name, grade }

Devolve o trabalho e o grau atuais do jogador no servidor.

lua
Custom.GetJob = function(source)
    return { name = 'unemployed', grade = 0 }
end

Custom.GetGroup(source) → string

Devolve o grupo de permissões do jogador (p. ex. 'admin', 'god').

lua
Custom.GetGroup = function(source)
    return 'user'
end

Custom.GetGender(source) → number | string

Devolve o género do jogador no servidor. 0 / 'm' = masculino, 1 / 'f' = feminino.

lua
Custom.GetGender = function(source)
    return 0
end

Custom.HasPermission(source, group) → boolean

Verifica se um jogador pertence a um grupo de permissões.

lua
Custom.HasPermission = function(source, group)
    return false
end

custom/server/permissions.lua

Custom.IsAdmin(source) → boolean

Verifica se um jogador é considerado administrador com base em Config.Permissions. Percorre a lista e chama Custom.HasPermission para cada grupo. Se Config.Permissions estiver vazio, todos os jogadores são considerados administradores.

lua
Custom.IsAdmin = function(src)
    -- Default logic: checks each group in Config.Permissions
    -- To override:
    return false
end