mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-08-29 01:08:57 +00:00
feat!: ace permission system
This commit is contained in:
@@ -64,7 +64,7 @@ function QBCore.Functions.CreateBlip(coords, sprite, display, scale, colour, sho
|
|||||||
print("Coords: " .. coords .. " Sprite: " .. sprite .. " Display: " .. display .. " scale: " .. scale .. " shortRange: " .. shortRange .. " Title: " .. title .. " if you're attempting to use a blip without a title, use an empty string.")
|
print("Coords: " .. coords .. " Sprite: " .. sprite .. " Display: " .. display .. " scale: " .. scale .. " shortRange: " .. shortRange .. " Title: " .. title .. " if you're attempting to use a blip without a title, use an empty string.")
|
||||||
return
|
return
|
||||||
end
|
end
|
||||||
|
|
||||||
coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords
|
coords = type(coords) == 'table' and vec3(coords.x, coords.y, coords.z) or coords
|
||||||
blip = AddBlipForCoord(coords)
|
blip = AddBlipForCoord(coords)
|
||||||
SetBlipSprite(blip, sprite)
|
SetBlipSprite(blip, sprite)
|
||||||
|
|||||||
+5
-3
@@ -27,8 +27,10 @@ QBConfig.Server.uptime = 0 -- Time the server has been up.
|
|||||||
QBConfig.Server.whitelist = false -- Enable or disable whitelist on the server
|
QBConfig.Server.whitelist = false -- Enable or disable whitelist on the server
|
||||||
QBConfig.Server.pvp = true -- Enable or disable pvp on the server (Ability to shoot other players)
|
QBConfig.Server.pvp = true -- Enable or disable pvp on the server (Ability to shoot other players)
|
||||||
QBConfig.Server.discord = "" -- Discord invite link
|
QBConfig.Server.discord = "" -- Discord invite link
|
||||||
QBConfig.Server.checkDuplicateLicense = true -- check for duplicate rockstar license on join
|
QBConfig.Server.checkDuplicateLicense = true -- Check for duplicate rockstar license on join
|
||||||
QBConfig.Server.PermissionList = {} -- permission list
|
QBConfig.Server.PermissionList = {} -- Permission list for old permission system
|
||||||
|
QBConfig.Server.UseOldPermissionSystem = true -- Use old permissions system from the database
|
||||||
|
QBConfig.Server.AllPermissions = {'god',} -- Table of permissions which have access to everything
|
||||||
|
|
||||||
QBConfig.Notify = {}
|
QBConfig.Notify = {}
|
||||||
|
|
||||||
@@ -62,4 +64,4 @@ QBConfig.Notify.VariantDefinitions = {
|
|||||||
classes = 'ambulance',
|
classes = 'ambulance',
|
||||||
icon = 'fas fa-ambulance'
|
icon = 'fas fa-ambulance'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+3
-4
@@ -5,10 +5,9 @@ description 'QB-Core'
|
|||||||
version '1.1.0'
|
version '1.1.0'
|
||||||
|
|
||||||
shared_scripts {
|
shared_scripts {
|
||||||
'shared/locale.lua',
|
'shared/*.lua',
|
||||||
'locale/en.lua', -- replace with desired language
|
|
||||||
'config.lua',
|
'config.lua',
|
||||||
'shared/*.lua'
|
'locale/en.lua' -- replace with desired language
|
||||||
}
|
}
|
||||||
|
|
||||||
client_scripts {
|
client_scripts {
|
||||||
@@ -45,4 +44,4 @@ dependencies {
|
|||||||
'connectqueue'
|
'connectqueue'
|
||||||
}
|
}
|
||||||
|
|
||||||
lua54 'yes'
|
lua54 'yes'
|
||||||
+1
-3
@@ -4,8 +4,6 @@ local Translations = {
|
|||||||
wrong_format = 'Formato incorrecto!',
|
wrong_format = 'Formato incorrecto!',
|
||||||
missing_args = 'No todos los argumentos estan presente! (x, y, z)',
|
missing_args = 'No todos los argumentos estan presente! (x, y, z)',
|
||||||
missing_args2 = 'Todos los argumentos tienen que estar presente!',
|
missing_args2 = 'Todos los argumentos tienen que estar presente!',
|
||||||
missing_args = 'No todos los argumentos estan presentes! (x, y, z)',
|
|
||||||
missing_args2 = 'Todos los argumentos deben estar presentes!',
|
|
||||||
no_access = 'No tienes acceso a este comando!',
|
no_access = 'No tienes acceso a este comando!',
|
||||||
company_too_poor = 'Tu empresa está en bancarrota. No hay dinero suficiente.',
|
company_too_poor = 'Tu empresa está en bancarrota. No hay dinero suficiente.',
|
||||||
item_not_exist = 'El objeto no existe en el sistema.',
|
item_not_exist = 'El objeto no existe en el sistema.',
|
||||||
@@ -24,4 +22,4 @@ local Translations = {
|
|||||||
Lang = Locale:new({
|
Lang = Locale:new({
|
||||||
phrases = Translations,
|
phrases = Translations,
|
||||||
warnOnMissing = true
|
warnOnMissing = true
|
||||||
})
|
})
|
||||||
+1
-3
@@ -24,10 +24,8 @@ function QBCore.Commands.Refresh(source)
|
|||||||
local suggestions = {}
|
local suggestions = {}
|
||||||
if not Player then return end
|
if not Player then return end
|
||||||
for command, info in pairs(QBCore.Commands.List) do
|
for command, info in pairs(QBCore.Commands.List) do
|
||||||
local isGod = QBCore.Functions.HasPermission(source, 'god')
|
|
||||||
local hasPerm = QBCore.Functions.HasPermission(source, QBCore.Commands.List[command].permission)
|
local hasPerm = QBCore.Functions.HasPermission(source, QBCore.Commands.List[command].permission)
|
||||||
local isPrincipal = IsPlayerAceAllowed(source, 'command')
|
if hasPerm then
|
||||||
if isGod or hasPerm or isPrincipal then
|
|
||||||
suggestions[#suggestions + 1] = {
|
suggestions[#suggestions + 1] = {
|
||||||
name = '/' .. command,
|
name = '/' .. command,
|
||||||
help = info.help,
|
help = info.help,
|
||||||
|
|||||||
+1
-1
@@ -42,4 +42,4 @@ end
|
|||||||
|
|
||||||
function QBCore.ShowSuccess(resource, msg)
|
function QBCore.ShowSuccess(resource, msg)
|
||||||
print('\x1b[32m['..resource..':LOG]\x1b[0m '..msg)
|
print('\x1b[32m['..resource..':LOG]\x1b[0m '..msg)
|
||||||
end
|
end
|
||||||
+3
-7
@@ -19,11 +19,9 @@ AddEventHandler('chatMessage', function(source, _, message)
|
|||||||
if not QBCore.Commands.List[command] then return end
|
if not QBCore.Commands.List[command] then return end
|
||||||
local Player = QBCore.Functions.GetPlayer(src)
|
local Player = QBCore.Functions.GetPlayer(src)
|
||||||
if not Player then return end
|
if not Player then return end
|
||||||
local isGod = QBCore.Functions.HasPermission(src, 'god')
|
|
||||||
local hasPerm = QBCore.Functions.HasPermission(src, QBCore.Commands.List[command].permission)
|
local hasPerm = QBCore.Functions.HasPermission(src, QBCore.Commands.List[command].permission)
|
||||||
local isPrincipal = IsPlayerAceAllowed(src, 'command')
|
|
||||||
table.remove(args, 1)
|
table.remove(args, 1)
|
||||||
if isGod or hasPerm or isPrincipal then
|
if hasPerm then
|
||||||
if QBCore.Commands.List[command].argsrequired and #QBCore.Commands.List[command].arguments ~= 0 and not args[#QBCore.Commands.List[command].arguments] then
|
if QBCore.Commands.List[command].argsrequired and #QBCore.Commands.List[command].arguments ~= 0 and not args[#QBCore.Commands.List[command].arguments] then
|
||||||
TriggerClientEvent('QBCore:Notify', src, Lang:t('error.missing_args2'), 'error')
|
TriggerClientEvent('QBCore:Notify', src, Lang:t('error.missing_args2'), 'error')
|
||||||
else
|
else
|
||||||
@@ -190,10 +188,8 @@ RegisterNetEvent('QBCore:CallCommand', function(command, args)
|
|||||||
if not QBCore.Commands.List[command] then return end
|
if not QBCore.Commands.List[command] then return end
|
||||||
local Player = QBCore.Functions.GetPlayer(src)
|
local Player = QBCore.Functions.GetPlayer(src)
|
||||||
if not Player then return end
|
if not Player then return end
|
||||||
local isGod = QBCore.Functions.HasPermission(src, 'god')
|
|
||||||
local hasPerm = QBCore.Functions.HasPermission(src, QBCore.Commands.List[command].permission)
|
local hasPerm = QBCore.Functions.HasPermission(src, QBCore.Commands.List[command].permission)
|
||||||
local isPrincipal = IsPlayerAceAllowed(src, 'command')
|
if (QBCore.Commands.List[command].permission == Player.PlayerData.job.name) or hasPerm then
|
||||||
if (QBCore.Commands.List[command].permission == Player.PlayerData.job.name) or isGod or hasPerm or isPrincipal then
|
|
||||||
if QBCore.Commands.List[command].argsrequired and #QBCore.Commands.List[command].arguments ~= 0 and not args[#QBCore.Commands.List[command].arguments] then
|
if QBCore.Commands.List[command].argsrequired and #QBCore.Commands.List[command].arguments ~= 0 and not args[#QBCore.Commands.List[command].arguments] then
|
||||||
TriggerClientEvent('QBCore:Notify', src, Lang:t('error.missing_args2'), 'error')
|
TriggerClientEvent('QBCore:Notify', src, Lang:t('error.missing_args2'), 'error')
|
||||||
else
|
else
|
||||||
@@ -258,4 +254,4 @@ QBCore.Functions.CreateCallback('QBCore:HasItem', function(source, cb, items, am
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
cb(retval)
|
cb(retval)
|
||||||
end)
|
end)
|
||||||
+2
-2
@@ -146,9 +146,9 @@ exports('AddGangs', AddGangs)
|
|||||||
local function GetCoreVersion(InvokingResource)
|
local function GetCoreVersion(InvokingResource)
|
||||||
local resourceVersion = GetResourceMetadata(GetCurrentResourceName(), 'version')
|
local resourceVersion = GetResourceMetadata(GetCurrentResourceName(), 'version')
|
||||||
if InvokingResource and InvokingResource ~= '' then
|
if InvokingResource and InvokingResource ~= '' then
|
||||||
print(("%s called qbcore version check: %s"):format(InvokingResource, resourceVersion))
|
print(("%s called qbcore version check: %s"):format(InvokingResource or 'Unknown Resource', resourceVersion))
|
||||||
end
|
end
|
||||||
return resourceVersion
|
return resourceVersion
|
||||||
end
|
end
|
||||||
QBCore.Functions.GetCoreVersion = GetCoreVersion
|
QBCore.Functions.GetCoreVersion = GetCoreVersion
|
||||||
exports('GetCoreVersion', GetCoreVersion)
|
exports('GetCoreVersion', GetCoreVersion)
|
||||||
+57
-24
@@ -275,28 +275,36 @@ function QBCore.Functions.AddPermission(source, permission)
|
|||||||
local Player = QBCore.Functions.GetPlayer(source)
|
local Player = QBCore.Functions.GetPlayer(source)
|
||||||
local plicense = Player.PlayerData.license
|
local plicense = Player.PlayerData.license
|
||||||
if not Player then return end
|
if not Player then return end
|
||||||
QBCore.Config.Server.PermissionList[plicense] = {
|
if QBCore.Config.Server.UseOldPermissionSystem then
|
||||||
license = plicense,
|
QBCore.Config.Server.PermissionList[plicense] = {
|
||||||
permission = permission:lower(),
|
license = plicense,
|
||||||
}
|
permission = permission:lower(),
|
||||||
MySQL.Async.execute('DELETE FROM permissions WHERE license = ?', { plicense })
|
}
|
||||||
MySQL.Async.insert('INSERT INTO permissions (name, license, permission) VALUES (?, ?, ?)', {
|
MySQL.Async.execute('DELETE FROM permissions WHERE license = ?', { plicense })
|
||||||
GetPlayerName(source),
|
MySQL.Async.insert('INSERT INTO permissions (name, license, permission) VALUES (?, ?, ?)', {
|
||||||
plicense,
|
GetPlayerName(source),
|
||||||
permission:lower()
|
plicense,
|
||||||
})
|
permission:lower()
|
||||||
Player.Functions.UpdatePlayerData()
|
})
|
||||||
TriggerClientEvent('QBCore:Client:OnPermissionUpdate', source, permission)
|
Player.Functions.UpdatePlayerData()
|
||||||
|
TriggerClientEvent('QBCore:Client:OnPermissionUpdate', source, permission)
|
||||||
|
else
|
||||||
|
Player.Functions.SetPermission(permission)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function QBCore.Functions.RemovePermission(source)
|
function QBCore.Functions.RemovePermission(source)
|
||||||
local Player = QBCore.Functions.GetPlayer(source)
|
local Player = QBCore.Functions.GetPlayer(source)
|
||||||
local license = Player.PlayerData.license
|
local license = Player.PlayerData.license
|
||||||
if not Player then return end
|
if not Player then return end
|
||||||
QBCore.Config.Server.PermissionList[license] = nil
|
if QBCore.Config.Server.UseOldPermissionSystem then
|
||||||
MySQL.Async.execute('DELETE FROM permissions WHERE license = ?', { license })
|
QBCore.Config.Server.PermissionList[license] = nil
|
||||||
Player.Functions.UpdatePlayerData()
|
MySQL.Async.execute('DELETE FROM permissions WHERE license = ?', { license })
|
||||||
TriggerClientEvent('QBCore:Client:OnPermissionUpdate', source, 'user')
|
Player.Functions.UpdatePlayerData()
|
||||||
|
TriggerClientEvent('QBCore:Client:OnPermissionUpdate', source, 'user')
|
||||||
|
else
|
||||||
|
Player.Functions.SetPermission('user')
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Checking for Permission Level
|
-- Checking for Permission Level
|
||||||
@@ -304,20 +312,34 @@ end
|
|||||||
function QBCore.Functions.HasPermission(source, permission)
|
function QBCore.Functions.HasPermission(source, permission)
|
||||||
permission = tostring(permission:lower())
|
permission = tostring(permission:lower())
|
||||||
local license = QBCore.Functions.GetIdentifier(source, 'license')
|
local license = QBCore.Functions.GetIdentifier(source, 'license')
|
||||||
if permission == 'user' then
|
if QBCore.Config.Server.UseOldPermissionSystem then
|
||||||
return true
|
if permission == 'user' then return true end
|
||||||
else
|
|
||||||
if not QBCore.Config.Server.PermissionList[license] or QBCore.Config.Server.PermissionList[license].license ~= license then return false end
|
if not QBCore.Config.Server.PermissionList[license] or QBCore.Config.Server.PermissionList[license].license ~= license then return false end
|
||||||
if QBCore.Config.Server.PermissionList[license].permission ~= permission or QBCore.Config.Server.PermissionList[license].permission ~= 'god' then return false end
|
if QBCore.Config.Server.PermissionList[license].permission ~= permission or QBCore.Config.Server.PermissionList[license].permission ~= 'god' then return false end
|
||||||
return true
|
return true
|
||||||
|
else
|
||||||
|
local Player = QBCore.Functions.GetPlayer(source)
|
||||||
|
if next(QBCore.Config.Server.AllPermissions) then
|
||||||
|
for i = 1, #QBCore.Config.Server.AllPermissions do
|
||||||
|
if QBCore.Config.Server.AllPermissions[i] == permission then
|
||||||
|
return true
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
return Player.PlayerData.permission == permission
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
|
|
||||||
function QBCore.Functions.GetPermission(source)
|
function QBCore.Functions.GetPermission(source)
|
||||||
local license = QBCore.Functions.GetIdentifier(source, 'license')
|
local license = QBCore.Functions.GetIdentifier(source, 'license')
|
||||||
if not license or not QBCore.Config.Server.PermissionList[license] or QBCore.Config.Server.PermissionList[license].license ~= license then return 'user' end
|
if QBCore.Config.Server.UseOldPermissionSystem then
|
||||||
return QBCore.Config.Server.PermissionList[license].permission
|
if not license or not QBCore.Config.Server.PermissionList[license] or QBCore.Config.Server.PermissionList[license].license ~= license then return 'user' end
|
||||||
|
return QBCore.Config.Server.PermissionList[license].permission
|
||||||
|
else
|
||||||
|
local Player = QBCore.Functions.GetPlayer(source)
|
||||||
|
return Player.PlayerData.permission
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Opt in or out of admin reports
|
-- Opt in or out of admin reports
|
||||||
@@ -325,13 +347,24 @@ end
|
|||||||
function QBCore.Functions.IsOptin(source)
|
function QBCore.Functions.IsOptin(source)
|
||||||
local license = QBCore.Functions.GetIdentifier(source, 'license')
|
local license = QBCore.Functions.GetIdentifier(source, 'license')
|
||||||
if not license or not QBCore.Functions.HasPermission(source, 'admin') then return false end
|
if not license or not QBCore.Functions.HasPermission(source, 'admin') then return false end
|
||||||
return QBCore.Config.Server.PermissionList[license].optin
|
if QBCore.Config.Server.UseOldPermissionSystem then
|
||||||
|
return QBCore.Config.Server.PermissionList[license].optin
|
||||||
|
else
|
||||||
|
local Player = QBCore.Functions.GetPlayer(source)
|
||||||
|
return Player.PlayerData.optin
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
function QBCore.Functions.ToggleOptin(source)
|
function QBCore.Functions.ToggleOptin(source)
|
||||||
local license = QBCore.Functions.GetIdentifier(source, 'license')
|
local license = QBCore.Functions.GetIdentifier(source, 'license')
|
||||||
if not license or not QBCore.Functions.HasPermission(source, 'admin') then return end
|
if not license or not QBCore.Functions.HasPermission(source, 'admin') then return end
|
||||||
QBCore.Config.Server.PermissionList[license].optin = not QBCore.Config.Server.PermissionList[license].optin
|
if QBCore.Config.Server.UseOldPermissionSystem then
|
||||||
|
QBCore.Config.Server.PermissionList[license].optin = not QBCore.Config.Server.PermissionList[license].optin
|
||||||
|
else
|
||||||
|
local Player = QBCore.Functions.GetPlayer(source)
|
||||||
|
Player.PlayerData.optin = not Player.PlayerData.optin
|
||||||
|
Player.Functions.SetMetaData('optin', Player.PlayerData.optin)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
-- Check if player is banned
|
-- Check if player is banned
|
||||||
@@ -364,4 +397,4 @@ function QBCore.Functions.IsLicenseInUse(license)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
return false
|
return false
|
||||||
end
|
end
|
||||||
+15
-9
@@ -15,13 +15,19 @@ end)
|
|||||||
-- Get permissions on server start
|
-- Get permissions on server start
|
||||||
|
|
||||||
CreateThread(function()
|
CreateThread(function()
|
||||||
local result = MySQL.Sync.fetchAll('SELECT * FROM permissions', {})
|
if QBCore.Config.Server.UseOldPermissionSystem then
|
||||||
if not result[1] then return end
|
local result = MySQL.Sync.fetchAll('SELECT * FROM permissions', {})
|
||||||
for k, v in pairs(result) do
|
if not result[1] then return end
|
||||||
QBCore.Config.Server.PermissionList[v.license] = {
|
for k, v in pairs(result) do
|
||||||
license = v.license,
|
QBCore.Config.Server.PermissionList[v.license] = {
|
||||||
permission = v.permission,
|
license = v.license,
|
||||||
optin = true,
|
permission = v.permission,
|
||||||
}
|
optin = true,
|
||||||
|
}
|
||||||
|
end
|
||||||
|
else
|
||||||
|
for i = 1, #QBCore.Config.Server.AllPermissions do
|
||||||
|
ExecuteCommand(('add_principal group.%s group.admin'):format(QBCore.Config.Server.AllPermissions[i]))
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end)
|
end)
|
||||||
+21
-3
@@ -43,6 +43,12 @@ function QBCore.Player.CheckPlayerData(source, PlayerData)
|
|||||||
PlayerData.license = PlayerData.license or QBCore.Functions.GetIdentifier(source, 'license')
|
PlayerData.license = PlayerData.license or QBCore.Functions.GetIdentifier(source, 'license')
|
||||||
PlayerData.name = GetPlayerName(source)
|
PlayerData.name = GetPlayerName(source)
|
||||||
PlayerData.cid = PlayerData.cid or 1
|
PlayerData.cid = PlayerData.cid or 1
|
||||||
|
if not QBCore.Config.Server.UseOldPermissionSystem then
|
||||||
|
if PlayerData.permission then ExecuteCommand(('remove_principal identifier.%s group.%s'):format(PlayerData.license, PlayerData.permission)) end
|
||||||
|
PlayerData.permission = PlayerData.permission or 'user'
|
||||||
|
ExecuteCommand(('add_principal identifier.%s group.%s'):format(PlayerData.license, PlayerData.permission))
|
||||||
|
PlayerData.optin = PlayerData.optin or true
|
||||||
|
end
|
||||||
PlayerData.money = PlayerData.money or {}
|
PlayerData.money = PlayerData.money or {}
|
||||||
for moneytype, startamount in pairs(QBCore.Config.Money.MoneyTypes) do
|
for moneytype, startamount in pairs(QBCore.Config.Money.MoneyTypes) do
|
||||||
PlayerData.money[moneytype] = PlayerData.money[moneytype] or startamount
|
PlayerData.money[moneytype] = PlayerData.money[moneytype] or startamount
|
||||||
@@ -152,11 +158,22 @@ function QBCore.Player.CreatePlayer(PlayerData)
|
|||||||
|
|
||||||
function self.Functions.UpdatePlayerData(dontUpdateChat)
|
function self.Functions.UpdatePlayerData(dontUpdateChat)
|
||||||
TriggerClientEvent('QBCore:Player:SetPlayerData', self.PlayerData.source, self.PlayerData)
|
TriggerClientEvent('QBCore:Player:SetPlayerData', self.PlayerData.source, self.PlayerData)
|
||||||
if dontUpdateChat == nil then
|
if not dontUpdateChat then
|
||||||
QBCore.Commands.Refresh(self.PlayerData.source)
|
QBCore.Commands.Refresh(self.PlayerData.source)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
if not QBCore.Config.Server.UseOldPermissionSystem then
|
||||||
|
function self.Functions.SetPermission(permission)
|
||||||
|
permission = permission:lower()
|
||||||
|
ExecuteCommand(('remove_principal identifier.%s group.%s'):format(self.PlayerData.license, self.PlayerData.permission))
|
||||||
|
ExecuteCommand(('add_principal identifier.%s group.%s'):format(self.PlayerData.license, permission))
|
||||||
|
self.PlayerData.permission = permission
|
||||||
|
self.Functions.UpdatePlayerData()
|
||||||
|
TriggerClientEvent('QBCore:Client:OnPermissionUpdate', self.PlayerData.source, permission)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function self.Functions.SetJob(job, grade)
|
function self.Functions.SetJob(job, grade)
|
||||||
job = job:lower()
|
job = job:lower()
|
||||||
grade = tostring(grade) or '0'
|
grade = tostring(grade) or '0'
|
||||||
@@ -215,13 +232,14 @@ function QBCore.Player.CreatePlayer(PlayerData)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function self.Functions.SetMetaData(meta, val)
|
function self.Functions.SetMetaData(meta, val)
|
||||||
meta = meta:lower()
|
|
||||||
if not meta then return end
|
if not meta then return end
|
||||||
|
meta = meta:lower()
|
||||||
self.PlayerData.metadata[meta] = val
|
self.PlayerData.metadata[meta] = val
|
||||||
self.Functions.UpdatePlayerData()
|
self.Functions.UpdatePlayerData()
|
||||||
end
|
end
|
||||||
|
|
||||||
function self.Functions.AddJobReputation(amount)
|
function self.Functions.AddJobReputation(amount)
|
||||||
|
if not amount then return end
|
||||||
amount = tonumber(amount)
|
amount = tonumber(amount)
|
||||||
self.PlayerData.metadata['jobrep'][self.PlayerData.job.name] = self.PlayerData.metadata['jobrep'][self.PlayerData.job.name] + amount
|
self.PlayerData.metadata['jobrep'][self.PlayerData.job.name] = self.PlayerData.metadata['jobrep'][self.PlayerData.job.name] + amount
|
||||||
self.Functions.UpdatePlayerData()
|
self.Functions.UpdatePlayerData()
|
||||||
@@ -657,4 +675,4 @@ function QBCore.Player.CreateSerialNumber()
|
|||||||
return SerialNumber
|
return SerialNumber
|
||||||
end
|
end
|
||||||
|
|
||||||
PaycheckInterval() -- This starts the paycheck system
|
PaycheckInterval() -- This starts the paycheck system
|
||||||
+1
-1
@@ -135,4 +135,4 @@ function Locale:delete(phraseTarget, prefix)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
+84
-11
@@ -7,17 +7,17 @@ for i = 48, 57 do NumberCharset[#NumberCharset+1] = string.char(i) end
|
|||||||
for i = 65, 90 do StringCharset[#StringCharset+1] = string.char(i) end
|
for i = 65, 90 do StringCharset[#StringCharset+1] = string.char(i) end
|
||||||
for i = 97, 122 do StringCharset[#StringCharset+1] = string.char(i) end
|
for i = 97, 122 do StringCharset[#StringCharset+1] = string.char(i) end
|
||||||
|
|
||||||
QBShared.RandomStr = function(length)
|
function QBShared.RandomStr(length)
|
||||||
if length <= 0 then return '' end
|
if length <= 0 then return '' end
|
||||||
return QBShared.RandomStr(length - 1) .. StringCharset[math.random(1, #StringCharset)]
|
return QBShared.RandomStr(length - 1) .. StringCharset[math.random(1, #StringCharset)]
|
||||||
end
|
end
|
||||||
|
|
||||||
QBShared.RandomInt = function(length)
|
function QBShared.RandomInt(length)
|
||||||
if length <= 0 then return '' end
|
if length <= 0 then return '' end
|
||||||
return QBShared.RandomInt(length - 1) .. NumberCharset[math.random(1, #NumberCharset)]
|
return QBShared.RandomInt(length - 1) .. NumberCharset[math.random(1, #NumberCharset)]
|
||||||
end
|
end
|
||||||
|
|
||||||
QBShared.SplitStr = function(str, delimiter)
|
function QBShared.SplitStr(str, delimiter)
|
||||||
local result = {}
|
local result = {}
|
||||||
local from = 1
|
local from = 1
|
||||||
local delim_from, delim_to = string.find(str, delimiter, from)
|
local delim_from, delim_to = string.find(str, delimiter, from)
|
||||||
@@ -30,18 +30,18 @@ QBShared.SplitStr = function(str, delimiter)
|
|||||||
return result
|
return result
|
||||||
end
|
end
|
||||||
|
|
||||||
QBShared.Trim = function(value)
|
function QBShared.Trim(value)
|
||||||
if not value then return nil end
|
if not value then return nil end
|
||||||
return (string.gsub(value, '^%s*(.-)%s*$', '%1'))
|
return (string.gsub(value, '^%s*(.-)%s*$', '%1'))
|
||||||
end
|
end
|
||||||
|
|
||||||
QBShared.Round = function(value, numDecimalPlaces)
|
function QBShared.Round(value, numDecimalPlaces)
|
||||||
if not numDecimalPlaces then return math.floor(value + 0.5) end
|
if not numDecimalPlaces then return math.floor(value + 0.5) end
|
||||||
local power = 10 ^ numDecimalPlaces
|
local power = 10 ^ numDecimalPlaces
|
||||||
return math.floor((value * power) + 0.5) / (power)
|
return math.floor((value * power) + 0.5) / (power)
|
||||||
end
|
end
|
||||||
|
|
||||||
QBShared.ChangeVehicleExtra = function (vehicle, extra, enable)
|
function QBShared.ChangeVehicleExtra(vehicle, extra, enable)
|
||||||
if DoesExtraExist(vehicle, extra) then
|
if DoesExtraExist(vehicle, extra) then
|
||||||
if enable then
|
if enable then
|
||||||
SetVehicleExtra(vehicle, extra, false)
|
SetVehicleExtra(vehicle, extra, false)
|
||||||
@@ -57,9 +57,9 @@ QBShared.ChangeVehicleExtra = function (vehicle, extra, enable)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
QBShared.SetDefaultVehicleExtras = function (vehicle, config)
|
function QBShared.SetDefaultVehicleExtras(vehicle, config)
|
||||||
-- Clear Extras
|
-- Clear Extras
|
||||||
for i=1,20 do
|
for i = 1,20 do
|
||||||
if DoesExtraExist(vehicle, i) then
|
if DoesExtraExist(vehicle, i) then
|
||||||
SetVehicleExtra(vehicle, i, 1)
|
SetVehicleExtra(vehicle, i, 1)
|
||||||
end
|
end
|
||||||
@@ -77,9 +77,82 @@ QBShared.StarterItems = {
|
|||||||
}
|
}
|
||||||
|
|
||||||
QBShared.MaleNoGloves = {
|
QBShared.MaleNoGloves = {
|
||||||
[0] = true, [1] = true, [2] = true, [3] = true, [4] = true, [5] = true, [6] = true, [7] = true, [8] = true, [9] = true, [10] = true, [11] = true, [12] = true, [13] = true, [14] = true, [15] = true, [18] = true, [26] = true, [52] = true, [53] = true, [54] = true, [55] = true, [56] = true, [57] = true, [58] = true, [59] = true, [60] = true, [61] = true, [62] = true, [112] = true, [113] = true, [114] = true, [118] = true, [125] = true, [132] = true
|
[0] = true,
|
||||||
|
[1] = true,
|
||||||
|
[2] = true,
|
||||||
|
[3] = true,
|
||||||
|
[4] = true,
|
||||||
|
[5] = true,
|
||||||
|
[6] = true,
|
||||||
|
[7] = true,
|
||||||
|
[8] = true,
|
||||||
|
[9] = true,
|
||||||
|
[10] = true,
|
||||||
|
[11] = true,
|
||||||
|
[12] = true,
|
||||||
|
[13] = true,
|
||||||
|
[14] = true,
|
||||||
|
[15] = true,
|
||||||
|
[18] = true,
|
||||||
|
[26] = true,
|
||||||
|
[52] = true,
|
||||||
|
[53] = true,
|
||||||
|
[54] = true,
|
||||||
|
[55] = true,
|
||||||
|
[56] = true,
|
||||||
|
[57] = true,
|
||||||
|
[58] = true,
|
||||||
|
[59] = true,
|
||||||
|
[60] = true,
|
||||||
|
[61] = true,
|
||||||
|
[62] = true,
|
||||||
|
[112] = true,
|
||||||
|
[113] = true,
|
||||||
|
[114] = true,
|
||||||
|
[118] = true,
|
||||||
|
[125] = true,
|
||||||
|
[132] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
QBShared.FemaleNoGloves = {
|
QBShared.FemaleNoGloves = {
|
||||||
[0] = true, [1] = true, [2] = true, [3] = true, [4] = true, [5] = true, [6] = true, [7] = true, [8] = true, [9] = true, [10] = true, [11] = true, [12] = true, [13] = true, [14] = true, [15] = true, [19] = true, [59] = true, [60] = true, [61] = true, [62] = true, [63] = true, [64] = true, [65] = true, [66] = true, [67] = true, [68] = true, [69] = true, [70] = true, [71] = true, [129] = true, [130] = true, [131] = true, [135] = true, [142] = true, [149] = true, [153] = true, [157] = true, [161] = true, [165] = true
|
[0] = true,
|
||||||
}
|
[1] = true,
|
||||||
|
[2] = true,
|
||||||
|
[3] = true,
|
||||||
|
[4] = true,
|
||||||
|
[5] = true,
|
||||||
|
[6] = true,
|
||||||
|
[7] = true,
|
||||||
|
[8] = true,
|
||||||
|
[9] = true,
|
||||||
|
[10] = true,
|
||||||
|
[11] = true,
|
||||||
|
[12] = true,
|
||||||
|
[13] = true,
|
||||||
|
[14] = true,
|
||||||
|
[15] = true,
|
||||||
|
[19] = true,
|
||||||
|
[59] = true,
|
||||||
|
[60] = true,
|
||||||
|
[61] = true,
|
||||||
|
[62] = true,
|
||||||
|
[63] = true,
|
||||||
|
[64] = true,
|
||||||
|
[65] = true,
|
||||||
|
[66] = true,
|
||||||
|
[67] = true,
|
||||||
|
[68] = true,
|
||||||
|
[69] = true,
|
||||||
|
[70] = true,
|
||||||
|
[71] = true,
|
||||||
|
[129] = true,
|
||||||
|
[130] = true,
|
||||||
|
[131] = true,
|
||||||
|
[135] = true,
|
||||||
|
[142] = true,
|
||||||
|
[149] = true,
|
||||||
|
[153] = true,
|
||||||
|
[157] = true,
|
||||||
|
[161] = true,
|
||||||
|
[165] = true
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user