Bridge-Funktionen
Was bridge.lua deinem Script auf der globalen Tabelle CsConfig gibt.
Ohne cs_config tun alle diese Funktionen nichts oder geben nil zurück. Du musst sie nie abfragen, bevor du sie aufrufst.
Beim Start
CsConfig.Boot
ServerCsConfig.Boot(version, check) Einmal, am Ende deiner Server-Datei. Meldet das Script mit Version und eigener Prüfung. Mit cs_config landet das im gemeinsamen Block und auf der Status-Seite, ohne auf einer eigenen Zeile. Die Prüfung läuft nach etwa fünf Sekunden und erneut, wenn cs_config eine Tabelle angelegt hat. Schreib sie also so, dass sie mehrmals laufen darf.
versionstring- deine Version, von Hand gleich der
fxmanifest.luagehalten. Weicht sie ab, sagt es der Report. checkfunction(fail, warn, note)failist kaputt,warnist seltsam,noteeine Zahl für die Zeile. Alle drei nehmen ein Format wiestring.format.
CsConfig.Boot('2.0.0', function(fail, warn, note)
if #Config.Shops == 0 then
return fail('Config.Shops is empty. There is nothing to open.')
end
warn('shop %d has no payment method enabled. It can only be looked at.', 3)
note('%d shops', #Config.Shops)
note('%s', Framework.Name)
end)CsConfig.Database
ServerCsConfig.Database(plan) Beschreibt, was dein Script von der Datenbank braucht, statt SQL mitzuliefern. cs_config vergleicht und zeigt den Unterschied auf der Seite Datenbank. Statt einer Tabelle darf eine Funktion kommen, sie wird einmal aufgerufen, etwa wenn der Tabellenname selbst eine Einstellung ist.
plan.notestring- ein Satz, wofür
plan.tables[].namestring- Tabellenname
plan.tables[].createtable{ what, sql }für eine eigene Tabelle, oder{ owner }für eine, die das Framework anlegtplan.tables[].columns[]tablename,ddl,what, dazuneed = 'feature'für eine Spalte, ohne die das Script startet undleastals kleinste varchar-Breiteplan.tables[].indexes[]tablename,columns,what
CsConfig.Database({
note = 'What each shop has on the shelf.',
tables = { {
name = 'cs_shops_stock',
create = { what = 'the stock table', sql = 'CREATE TABLE `cs_shops_stock` (...)' },
columns = {
{ name = 'shop', ddl = 'varchar(64) NOT NULL', what = 'which shop', least = 32 },
{ name = 'count', ddl = 'int(11) NOT NULL DEFAULT 0', what = 'how many are left' },
{ name = 'restocked', ddl = 'timestamp NULL', what = 'when it last filled up',
need = 'feature' },
},
indexes = {
{ name = 'cs_shops_shop', columns = { 'shop' }, what = 'opening a shop' },
},
} },
})Wenn sich etwas ändert
Fragen an die Einstellungen
CsConfig.Allows
ServerCsConfig.Allows(rules, source) Ob ein Spieler eine rules-Liste erfüllt. Nimmt die Liste oder die Tabelle, in der sie als who steht.
rulestablesourcenumber- die Server-ID
Gibt zurückboolean | nil nil heißt: keine Liste. Dann entscheidet deine eigene Logik weiter.
function Config.HasFeature(source, feature)
local said = CsConfig and CsConfig.Allows(Config.Features[feature], source)
if said ~= nil then return said end
return false
endCsConfig.Notifier
ClientCsConfig.Notifier(at) Ob eine Meldung noch die mitgelieferte Funktion ist. Nur nötig, wenn dein Script eine Meldung selbst gestaltet, sonst ignoriert genau diese Meldung die Einstellung.
atstring'Notify.player','Notify.help'/'Notify.all'
Gibt zurückfunction | nil die gebaute Meldung, wenn eine andere Resource eingestellt ist
if not (CsConfig and CsConfig.Notifier('Notify.player')) then
-- the fancy one of your own
endFertige Seiten
function L(key, ...)
local text = LocalePack()[key]
if not text then return key end
if select('#', ...) == 0 then return text end
local held, said = pcall(string.format, text, ...)
if held then return said end
return text
end