Frameworks
Config.Framework = 'auto' -- auto, esx, qb-core, qbox, standalone
server/custom/framework/standalone.lua
if Config.Framework ~= 'standalone' then
return
end
Framework = {}
debugPrint('Successfully loaded standalone')
function Framework.GetPlayerIdentifier(source)
local identifiers, license = GetPlayerIdentifiers(source)
for key, value in pairs(identifiers) do
if string.match(value, 'license:') then
license = value
break
end
end
return license
end
function Framework.GetSourceFromIdentifier(identifier)
return 0
end
function Framework.GetCharacterName(source)
return 'firstName', 'lastName'
end
function Framework.GetPlayerJob(source)
return {
name = 'user',
label = 'Citizen',
grade = 0,
grade_label = 'Unemployed'
}
end
function Framework.SetPlayerJob(source, job, grade)
end
function Framework.GetJobPlayers(job)
return {}
end
function Framework.GetJobs()
return {
['police'] = {
label = 'Law Enforcement',
-- continous data
}
}
end
function Framework.GetJobData(job)
return {
name = 'Job name',
grades = {
{ name = 'Job grade', level = 0 }
}
}
end
function Framework.GetDefaultPoliceJob(online)
return { name = 'default_police_job', grade = 0 }
end
function Framework.GetUnemployedJob(online)
return { name = 'default_unemployed_job', grade = 0 }
end
function Framework.GetWeapons()
return {
{ name = 'WEAPON_NAME', label = 'Weapon Label' }
}
end
function Framework.RegisterCommand(name, description, callback)
RegisterCommand(name, function(source)
if source > 0 then
callback(source)
end
end, false)
TriggerEvent('chat:addSuggestion', string.format('/%s', name), description)
end
function Framework.Notify(source, message)
TriggerClientEvent('chat:addMessage', source, {
args = { '[Redutzu-MDT]', message },
color = { 255, 255, 255 },
multiline = true
})
end
function Framework.RegisterCallback(name, callback)
RegisterServerEvent('redutzu-mdt:server-callback:' .. name, function(...)
local player = source
callback(player, function(...)
TriggerClientEvent('redutzu-mdt:client-callback:' .. name, player, ...)
end, ...)
end)
end
local function Callback(name, source, callback, ...)
TriggerClientEvent('redutzu-mdt:server-client-callback:' .. name, source, ...)
return RegisterNetEvent('redutzu-mdt:client-server-callback:' .. name, function(...)
callback(...)
end)
end
function Framework.TriggerClientCallback(name, source, callback, ...)
local event = false
local cb = function(...)
if event ~= false then
RemoveEventHandler(event)
end
callback(...)
end
event = Callback(name, source, cb, ...)
return event
end
if Config.Command.Enabled then
Framework.RegisterCommand(Config.Command.Name, Config.Command.Description, function(source)
TriggerClientEvent('redutzu-mdt:client:openMDT', source)
end)
end
Last updated