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

Personalização · origen_garages

A pasta custom/ permite-te integrar qualquer framework, sistema de notificações, sistema de combustível ou sincronização de meteorologia sem tocar no núcleo. Todos os ficheiros aqui são escrow_ignore: sobrevivem às atualizações.

text
custom/
├── client/
│   ├── framework.lua  — player identifier, job, gang, loaded state
│   ├── keys.lua       — give vehicle keys on retrieval
│   ├── fuel.lua       — get/set fuel level
│   ├── notify.lua     — notifications and text UI
│   └── weather.lua    — disable/enable weather sync inside interiors
└── server/
    └── framework.lua  — player identifier, job, money, permissions, name

custom/server/framework.lua

Framework.GetPlayerIdentifier(source) → string | nil

Devolve o identificador único (citizenid / identifier) de um jogador no servidor.

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

Framework.GetPlayerJob(source) → { name, grade }

Devolve o nome do trabalho e o grau de um jogador.

lua
Framework.GetPlayerJob = function(source)
    -- returns { name = 'police', grade = 2 }
end

Framework.GetMoney(source) → number

Devolve o saldo do jogador para Config.PaymentMethod.

lua
Framework.GetMoney = function(source)
    -- Config.PaymentMethod = 'bank' | 'cash'
end

Framework.RemoveMoney(source, account, amount) → boolean

Desconta dinheiro da conta do jogador. Devolve true se for bem-sucedido.

lua
Framework.RemoveMoney = function(source, account, amount)
end

Framework.HasPermission(source, group) → boolean

Verifica se um jogador pertence a um grupo de permissões. O painel de administração usa-o com Config.Permissions.

lua
Framework.HasPermission = function(source, group)
end

Framework.GetPlayerName(source) → string

Devolve o nome completo do jogador (nome + apelido).

lua
Framework.GetPlayerName = function(source)
end

custom/client/framework.lua

Framework.GetPlayerIdentifier() → string | nil

Devolve o identificador único do jogador local.

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

Framework.GetPlayerJob() → { name, grade }

Devolve o trabalho atual do jogador local.

lua
Framework.GetPlayerJob = function()
    return { name = 'unknown', grade = 0 }
end

Framework.GetPlayerGang() → { name, grade }

Devolve a gangue atual do jogador local. Por omissão devolve unknown.

lua
Framework.GetPlayerGang = function()
    return { name = 'unknown', grade = 0 }
end

Framework.isPlayerLoaded() → boolean

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

lua
Framework.isPlayerLoaded = function()
    return false -- replace with your check
end

custom/client/keys.lua

Custom.GiveVehicleKeys(vehicle, plate)

Dá as chaves do veículo ao jogador local depois de o retirar. Implementa aqui o teu sistema de chaves.

lua
Custom.GiveVehicleKeys = function(vehicle, plate)
    -- Example with qbx_vehiclekeys:
    -- exports['qbx_vehiclekeys']:GiveKeys(vehicle, true)
end

custom/client/fuel.lua

Custom.GetFuel / Custom.SetFuel

Por omissão ambas valem false (desativadas: usa-se o combustível nativo). Atribui-lhes funções para usares um sistema de combustível próprio:

lua
Custom.GetFuel = function(vehicle)
    return exports['fuel-system']:GetFuel(vehicle)
end
 
Custom.SetFuel = function(vehicle, fuelLevel)
    exports['fuel-system']:SetFuel(vehicle, fuelLevel)
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 dica de interação na interface de texto.

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

Custom.HideText()

Esconde a dica de interação.

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

custom/client/weather.lua

Custom.DisableWeatherSync() / Custom.EnableWeatherSync()

São chamadas quando o jogador entra ou sai de um interior de garagem. Usa-as para pausar ou retomar o teu recurso de sincronização de meteorologia, para que não substitua a meteorologia estática do interior.

lua
Custom.DisableWeatherSync = function()
    -- Example: TriggerEvent('your_weather:pause')
end
 
Custom.EnableWeatherSync = function()
    -- Example: TriggerEvent('your_weather:resume')
end