Helper de config apply
O @bs_config/shared/apply.lua é o que faz as alterações do F1 chegarem ao teu recurso.
Incluí-lo
Seção intitulada “Incluí-lo”Último shared script, depois dos teus ficheiros de config:
shared_scripts { 'config/config.lua' }-- ...shared_script '@bs_config/shared/apply.lua'O que faz
Seção intitulada “O que faz”- No arranque e a cada alteração, o servidor envia um payload
{ _global = {...}, <resource> = { ['Path.To.key'] = value } }através debs_config:apply. - O helper pega na parte do teu recurso e altera as tuas tabelas globais no local:
MyRes.Settings.reward = 75. - Só toca em chaves que já existem com o mesmo tipo. Nunca inventa config.
- Quando um override é removido, repõe o valor original.
- Dispara
bs_config:changed:<resource>após cada aplicação, para poderes reagir:
AddEventHandler('bs_config:changed:' .. GetCurrentResourceName(), function() rebuildSomething()end)Ler valores
Seção intitulada “Ler valores”local mult = BSConfigGet('Global.xpMultiplier', 1.0) -- globals or your own paths, no export call-- or from anywhere:local size = exports.bs_config:Get('bs_factions:Factions.Squad.maxSize')Exports: Get(key, default), GetPayload(), GetActiveProfile(), em ambos os lados.
Em direto ou com restart
Seção intitulada “Em direto ou com restart”Alterar a tabela chega quando o teu código lê a tabela de cada vez:
-- live: sees the new value next calllocal function reward() return RadioTower.Settings.reward endNão chega quando a copias para um local no carregamento:
-- cached: F1 changes do nothing until restartlocal REWARD = RadioTower.Settings.rewardO bs_config deteta esse padrão (local x = Cfg.key no nível superior) e marca a definição como “restart”. Prefere ler a tabela.
Adicionar as tuas definições ao F1
Seção intitulada “Adicionar as tuas definições ao F1”Adiciona linhas a bs_config/shared/schema.lua. O id é <resource>:<path>, com tipo, min/max/step, categoria, descrição e a flag live. O valor por defeito é lido do teu ficheiro em runtime; o valor fb no schema é só um fallback. Só deves adicionar chaves que realmente existem na tua config.
bs19.org · Privacy · Terms · Cookie settings
Cookies and outside content
The site only needs two essential cookies to keep you logged in and protect forms. Videos and streams from YouTube and Twitch load from their servers, which can set their own cookies, so they stay off until you say yes. Nothing is pre-ticked and you can change your mind any time with "Cookie settings" at the bottom of every page. Details.
Questions about the server, the framework or the site? A real person reads this, usually within a day.