mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-09-04 17:23:31 +00:00
Weapon attachment rework
This commit is contained in:
+49
-46
@@ -1,13 +1,13 @@
|
||||
QBCore.Commands = {}
|
||||
QBCore.Commands.List = {}
|
||||
QBCore.Commands.IgnoreList = { -- Ignore old perm levels while keeping backwards compatibility
|
||||
['god'] = true, -- We don't need to create an ace because god is allowed all commands
|
||||
['user'] = true -- We don't need to create an ace because builtin.everyone
|
||||
['god'] = true, -- We don't need to create an ace because god is allowed all commands
|
||||
['user'] = true -- We don't need to create an ace because builtin.everyone
|
||||
}
|
||||
|
||||
CreateThread(function() -- Add ace to node for perm checking
|
||||
local permissions = QBConfig.Server.Permissions
|
||||
for i=1, #permissions do
|
||||
for i = 1, #permissions do
|
||||
local permission = permissions[i]
|
||||
ExecuteCommand(('add_ace qbcore.%s %s allow'):format(permission, permission))
|
||||
end
|
||||
@@ -16,16 +16,16 @@ end)
|
||||
-- Register & Refresh Commands
|
||||
|
||||
function QBCore.Commands.Add(name, help, arguments, argsrequired, callback, permission, ...)
|
||||
local restricted = true -- Default to restricted for all commands
|
||||
if not permission then permission = 'user' end -- some commands don't pass permission level
|
||||
if permission == 'user' then restricted = false end -- allow all users to use command
|
||||
local restricted = true -- Default to restricted for all commands
|
||||
if not permission then permission = 'user' end -- some commands don't pass permission level
|
||||
if permission == 'user' then restricted = false end -- allow all users to use command
|
||||
|
||||
RegisterCommand(name, function(source, args, rawCommand) -- Register command within fivem
|
||||
if argsrequired and #args < #arguments then
|
||||
return TriggerClientEvent('chat:addMessage', source, {
|
||||
color = {255, 0, 0},
|
||||
color = { 255, 0, 0 },
|
||||
multiline = true,
|
||||
args = {"System", Lang:t("error.missing_args2")}
|
||||
args = { 'System', Lang:t('error.missing_args2') }
|
||||
})
|
||||
end
|
||||
callback(source, args, rawCommand)
|
||||
@@ -65,7 +65,7 @@ function QBCore.Commands.Refresh(source)
|
||||
local suggestions = {}
|
||||
if Player then
|
||||
for command, info in pairs(QBCore.Commands.List) do
|
||||
local hasPerm = IsPlayerAceAllowed(tostring(src), 'command.'..command)
|
||||
local hasPerm = IsPlayerAceAllowed(tostring(src), 'command.' .. command)
|
||||
if hasPerm then
|
||||
suggestions[#suggestions + 1] = {
|
||||
name = '/' .. command,
|
||||
@@ -73,7 +73,7 @@ function QBCore.Commands.Refresh(source)
|
||||
params = info.arguments
|
||||
}
|
||||
else
|
||||
TriggerClientEvent('chat:removeSuggestion', src, '/'..command)
|
||||
TriggerClientEvent('chat:removeSuggestion', src, '/' .. command)
|
||||
end
|
||||
end
|
||||
TriggerClientEvent('chat:addSuggestions', src, suggestions)
|
||||
@@ -81,17 +81,17 @@ function QBCore.Commands.Refresh(source)
|
||||
end
|
||||
|
||||
-- Teleport
|
||||
QBCore.Commands.Add('tp', Lang:t("command.tp.help"), { { name = Lang:t("command.tp.params.x.name"), help = Lang:t("command.tp.params.x.help") }, { name = Lang:t("command.tp.params.y.name"), help = Lang:t("command.tp.params.y.help") }, { name = Lang:t("command.tp.params.z.name"), help = Lang:t("command.tp.params.z.help") } }, false, function(source, args)
|
||||
QBCore.Commands.Add('tp', Lang:t('command.tp.help'), { { name = Lang:t('command.tp.params.x.name'), help = Lang:t('command.tp.params.x.help') }, { name = Lang:t('command.tp.params.y.name'), help = Lang:t('command.tp.params.y.help') }, { name = Lang:t('command.tp.params.z.name'), help = Lang:t('command.tp.params.z.help') } }, false, function(source, args)
|
||||
if args[1] and not args[2] and not args[3] then
|
||||
if tonumber(args[1]) then
|
||||
local target = GetPlayerPed(tonumber(args[1]))
|
||||
if target ~= 0 then
|
||||
local coords = GetEntityCoords(target)
|
||||
TriggerClientEvent('QBCore:Command:TeleportToPlayer', source, coords)
|
||||
local target = GetPlayerPed(tonumber(args[1]))
|
||||
if target ~= 0 then
|
||||
local coords = GetEntityCoords(target)
|
||||
TriggerClientEvent('QBCore:Command:TeleportToPlayer', source, coords)
|
||||
else
|
||||
TriggerClientEvent('QBCore:Notify', source, Lang:t('error.not_online'), 'error')
|
||||
end
|
||||
else
|
||||
TriggerClientEvent('QBCore:Notify', source, Lang:t('error.not_online'), 'error')
|
||||
end
|
||||
else
|
||||
local location = QBShared.Locations[args[1]]
|
||||
if location then
|
||||
TriggerClientEvent('QBCore:Command:TeleportToCoords', source, location.x, location.y, location.z, location.w)
|
||||
@@ -101,9 +101,9 @@ QBCore.Commands.Add('tp', Lang:t("command.tp.help"), { { name = Lang:t("command.
|
||||
end
|
||||
else
|
||||
if args[1] and args[2] and args[3] then
|
||||
local x = tonumber((args[1]:gsub(",",""))) + .0
|
||||
local y = tonumber((args[2]:gsub(",",""))) + .0
|
||||
local z = tonumber((args[3]:gsub(",",""))) + .0
|
||||
local x = tonumber((args[1]:gsub(',', ''))) + .0
|
||||
local y = tonumber((args[2]:gsub(',', ''))) + .0
|
||||
local z = tonumber((args[3]:gsub(',', ''))) + .0
|
||||
if x ~= 0 and y ~= 0 and z ~= 0 then
|
||||
TriggerClientEvent('QBCore:Command:TeleportToCoords', source, x, y, z)
|
||||
else
|
||||
@@ -115,18 +115,18 @@ QBCore.Commands.Add('tp', Lang:t("command.tp.help"), { { name = Lang:t("command.
|
||||
end
|
||||
end, 'admin')
|
||||
|
||||
QBCore.Commands.Add('tpm', Lang:t("command.tpm.help"), {}, false, function(source)
|
||||
QBCore.Commands.Add('tpm', Lang:t('command.tpm.help'), {}, false, function(source)
|
||||
TriggerClientEvent('QBCore:Command:GoToMarker', source)
|
||||
end, 'admin')
|
||||
|
||||
QBCore.Commands.Add('togglepvp', Lang:t("command.togglepvp.help"), {}, false, function()
|
||||
QBCore.Commands.Add('togglepvp', Lang:t('command.togglepvp.help'), {}, false, function()
|
||||
QBConfig.Server.PVP = not QBConfig.Server.PVP
|
||||
TriggerClientEvent('QBCore:Client:PvpHasToggled', -1, QBConfig.Server.PVP)
|
||||
end, 'admin')
|
||||
|
||||
-- Permissions
|
||||
|
||||
QBCore.Commands.Add('addpermission', Lang:t("command.addpermission.help"), { { name = Lang:t("command.addpermission.params.id.name"), help = Lang:t("command.addpermission.params.id.help") }, { name = Lang:t("command.addpermission.params.permission.name"), help = Lang:t("command.addpermission.params.permission.help") } }, true, function(source, args)
|
||||
QBCore.Commands.Add('addpermission', Lang:t('command.addpermission.help'), { { name = Lang:t('command.addpermission.params.id.name'), help = Lang:t('command.addpermission.params.id.help') }, { name = Lang:t('command.addpermission.params.permission.name'), help = Lang:t('command.addpermission.params.permission.help') } }, true, function(source, args)
|
||||
local Player = QBCore.Functions.GetPlayer(tonumber(args[1]))
|
||||
local permission = tostring(args[2]):lower()
|
||||
if Player then
|
||||
@@ -136,7 +136,7 @@ QBCore.Commands.Add('addpermission', Lang:t("command.addpermission.help"), { { n
|
||||
end
|
||||
end, 'god')
|
||||
|
||||
QBCore.Commands.Add('removepermission', Lang:t("command.removepermission.help"), { { name = Lang:t("command.removepermission.params.id.name"), help = Lang:t("command.removepermission.params.id.help") }, { name = Lang:t("command.removepermission.params.permission.name"), help = Lang:t("command.removepermission.params.permission.help") } }, true, function(source, args)
|
||||
QBCore.Commands.Add('removepermission', Lang:t('command.removepermission.help'), { { name = Lang:t('command.removepermission.params.id.name'), help = Lang:t('command.removepermission.params.id.help') }, { name = Lang:t('command.removepermission.params.permission.name'), help = Lang:t('command.removepermission.params.permission.help') } }, true, function(source, args)
|
||||
local Player = QBCore.Functions.GetPlayer(tonumber(args[1]))
|
||||
local permission = tostring(args[2]):lower()
|
||||
if Player then
|
||||
@@ -148,7 +148,7 @@ end, 'god')
|
||||
|
||||
-- Open & Close Server
|
||||
|
||||
QBCore.Commands.Add('openserver', Lang:t("command.openserver.help"), {}, false, function(source)
|
||||
QBCore.Commands.Add('openserver', Lang:t('command.openserver.help'), {}, false, function(source)
|
||||
if not QBCore.Config.Server.Closed then
|
||||
TriggerClientEvent('QBCore:Notify', source, Lang:t('error.server_already_open'), 'error')
|
||||
return
|
||||
@@ -157,11 +157,11 @@ QBCore.Commands.Add('openserver', Lang:t("command.openserver.help"), {}, false,
|
||||
QBCore.Config.Server.Closed = false
|
||||
TriggerClientEvent('QBCore:Notify', source, Lang:t('success.server_opened'), 'success')
|
||||
else
|
||||
QBCore.Functions.Kick(source, Lang:t("error.no_permission"), nil, nil)
|
||||
QBCore.Functions.Kick(source, Lang:t('error.no_permission'), nil, nil)
|
||||
end
|
||||
end, 'admin')
|
||||
|
||||
QBCore.Commands.Add('closeserver', Lang:t("command.closeserver.help"), {{ name = Lang:t("command.closeserver.params.reason.name"), help = Lang:t("command.closeserver.params.reason.help")}}, false, function(source, args)
|
||||
QBCore.Commands.Add('closeserver', Lang:t('command.closeserver.help'), { { name = Lang:t('command.closeserver.params.reason.name'), help = Lang:t('command.closeserver.params.reason.help') } }, false, function(source, args)
|
||||
if QBCore.Config.Server.Closed then
|
||||
TriggerClientEvent('QBCore:Notify', source, Lang:t('error.server_already_closed'), 'error')
|
||||
return
|
||||
@@ -177,23 +177,23 @@ QBCore.Commands.Add('closeserver', Lang:t("command.closeserver.help"), {{ name =
|
||||
end
|
||||
TriggerClientEvent('QBCore:Notify', source, Lang:t('success.server_closed'), 'success')
|
||||
else
|
||||
QBCore.Functions.Kick(source, Lang:t("error.no_permission"), nil, nil)
|
||||
QBCore.Functions.Kick(source, Lang:t('error.no_permission'), nil, nil)
|
||||
end
|
||||
end, 'admin')
|
||||
|
||||
-- Vehicle
|
||||
|
||||
QBCore.Commands.Add('car', Lang:t("command.car.help"), {{ name = Lang:t("command.car.params.model.name"), help = Lang:t("command.car.params.model.help") }}, true, function(source, args)
|
||||
QBCore.Commands.Add('car', Lang:t('command.car.help'), { { name = Lang:t('command.car.params.model.name'), help = Lang:t('command.car.params.model.help') } }, true, function(source, args)
|
||||
TriggerClientEvent('QBCore:Command:SpawnVehicle', source, args[1])
|
||||
end, 'admin')
|
||||
|
||||
QBCore.Commands.Add('dv', Lang:t("command.dv.help"), {}, false, function(source)
|
||||
QBCore.Commands.Add('dv', Lang:t('command.dv.help'), {}, false, function(source)
|
||||
TriggerClientEvent('QBCore:Command:DeleteVehicle', source)
|
||||
end, 'admin')
|
||||
|
||||
-- Money
|
||||
|
||||
QBCore.Commands.Add('givemoney', Lang:t("command.givemoney.help"), { { name = Lang:t("command.givemoney.params.id.name"), help = Lang:t("command.givemoney.params.id.help") }, { name = Lang:t("command.givemoney.params.moneytype.name"), help = Lang:t("command.givemoney.params.moneytype.help") }, { name = Lang:t("command.givemoney.params.amount.name"), help = Lang:t("command.givemoney.params.amount.help") } }, true, function(source, args)
|
||||
QBCore.Commands.Add('givemoney', Lang:t('command.givemoney.help'), { { name = Lang:t('command.givemoney.params.id.name'), help = Lang:t('command.givemoney.params.id.help') }, { name = Lang:t('command.givemoney.params.moneytype.name'), help = Lang:t('command.givemoney.params.moneytype.help') }, { name = Lang:t('command.givemoney.params.amount.name'), help = Lang:t('command.givemoney.params.amount.help') } }, true, function(source, args)
|
||||
local Player = QBCore.Functions.GetPlayer(tonumber(args[1]))
|
||||
if Player then
|
||||
Player.Functions.AddMoney(tostring(args[2]), tonumber(args[3]))
|
||||
@@ -202,7 +202,7 @@ QBCore.Commands.Add('givemoney', Lang:t("command.givemoney.help"), { { name = La
|
||||
end
|
||||
end, 'admin')
|
||||
|
||||
QBCore.Commands.Add('setmoney', Lang:t("command.setmoney.help"), { { name = Lang:t("command.setmoney.params.id.name"), help = Lang:t("command.setmoney.params.id.help") }, { name = Lang:t("command.setmoney.params.moneytype.name"), help = Lang:t("command.setmoney.params.moneytype.help") }, { name = Lang:t("command.setmoney.params.amount.name"), help = Lang:t("command.setmoney.params.amount.help") } }, true, function(source, args)
|
||||
QBCore.Commands.Add('setmoney', Lang:t('command.setmoney.help'), { { name = Lang:t('command.setmoney.params.id.name'), help = Lang:t('command.setmoney.params.id.help') }, { name = Lang:t('command.setmoney.params.moneytype.name'), help = Lang:t('command.setmoney.params.moneytype.help') }, { name = Lang:t('command.setmoney.params.amount.name'), help = Lang:t('command.setmoney.params.amount.help') } }, true, function(source, args)
|
||||
local Player = QBCore.Functions.GetPlayer(tonumber(args[1]))
|
||||
if Player then
|
||||
Player.Functions.SetMoney(tostring(args[2]), tonumber(args[3]))
|
||||
@@ -213,12 +213,12 @@ end, 'admin')
|
||||
|
||||
-- Job
|
||||
|
||||
QBCore.Commands.Add('job', Lang:t("command.job.help"), {}, false, function(source)
|
||||
QBCore.Commands.Add('job', Lang:t('command.job.help'), {}, false, function(source)
|
||||
local PlayerJob = QBCore.Functions.GetPlayer(source).PlayerData.job
|
||||
TriggerClientEvent('QBCore:Notify', source, Lang:t('info.job_info', {value = PlayerJob.label, value2 = PlayerJob.grade.name, value3 = PlayerJob.onduty}))
|
||||
TriggerClientEvent('QBCore:Notify', source, Lang:t('info.job_info', { value = PlayerJob.label, value2 = PlayerJob.grade.name, value3 = PlayerJob.onduty }))
|
||||
end, 'user')
|
||||
|
||||
QBCore.Commands.Add('setjob', Lang:t("command.setjob.help"), { { name = Lang:t("command.setjob.params.id.name"), help = Lang:t("command.setjob.params.id.help") }, { name = Lang:t("command.setjob.params.job.name"), help = Lang:t("command.setjob.params.job.help") }, { name = Lang:t("command.setjob.params.grade.name"), help = Lang:t("command.setjob.params.grade.help") } }, true, function(source, args)
|
||||
QBCore.Commands.Add('setjob', Lang:t('command.setjob.help'), { { name = Lang:t('command.setjob.params.id.name'), help = Lang:t('command.setjob.params.id.help') }, { name = Lang:t('command.setjob.params.job.name'), help = Lang:t('command.setjob.params.job.help') }, { name = Lang:t('command.setjob.params.grade.name'), help = Lang:t('command.setjob.params.grade.help') } }, true, function(source, args)
|
||||
local Player = QBCore.Functions.GetPlayer(tonumber(args[1]))
|
||||
if Player then
|
||||
Player.Functions.SetJob(tostring(args[2]), tonumber(args[3]))
|
||||
@@ -229,12 +229,12 @@ end, 'admin')
|
||||
|
||||
-- Gang
|
||||
|
||||
QBCore.Commands.Add('gang', Lang:t("command.gang.help"), {}, false, function(source)
|
||||
QBCore.Commands.Add('gang', Lang:t('command.gang.help'), {}, false, function(source)
|
||||
local PlayerGang = QBCore.Functions.GetPlayer(source).PlayerData.gang
|
||||
TriggerClientEvent('QBCore:Notify', source, Lang:t('info.gang_info', {value = PlayerGang.label, value2 = PlayerGang.grade.name}))
|
||||
TriggerClientEvent('QBCore:Notify', source, Lang:t('info.gang_info', { value = PlayerGang.label, value2 = PlayerGang.grade.name }))
|
||||
end, 'user')
|
||||
|
||||
QBCore.Commands.Add('setgang', Lang:t("command.setgang.help"), { { name = Lang:t("command.setgang.params.id.name"), help = Lang:t("command.setgang.params.id.help") }, { name = Lang:t("command.setgang.params.gang.name"), help = Lang:t("command.setgang.params.gang.help") }, { name = Lang:t("command.setgang.params.grade.name"), help = Lang:t("command.setgang.params.grade.help") } }, true, function(source, args)
|
||||
QBCore.Commands.Add('setgang', Lang:t('command.setgang.help'), { { name = Lang:t('command.setgang.params.id.name'), help = Lang:t('command.setgang.params.id.help') }, { name = Lang:t('command.setgang.params.gang.name'), help = Lang:t('command.setgang.params.gang.help') }, { name = Lang:t('command.setgang.params.grade.name'), help = Lang:t('command.setgang.params.grade.help') } }, true, function(source, args)
|
||||
local Player = QBCore.Functions.GetPlayer(tonumber(args[1]))
|
||||
if Player then
|
||||
Player.Functions.SetGang(tostring(args[2]), tonumber(args[3]))
|
||||
@@ -244,7 +244,7 @@ QBCore.Commands.Add('setgang', Lang:t("command.setgang.help"), { { name = Lang:t
|
||||
end, 'admin')
|
||||
|
||||
-- Out of Character Chat
|
||||
QBCore.Commands.Add('ooc', Lang:t("command.ooc.help"), {}, false, function(source, args)
|
||||
QBCore.Commands.Add('ooc', Lang:t('command.ooc.help'), {}, false, function(source, args)
|
||||
local message = table.concat(args, ' ')
|
||||
local Players = QBCore.Functions.GetPlayers()
|
||||
local Player = QBCore.Functions.GetPlayer(source)
|
||||
@@ -254,20 +254,20 @@ QBCore.Commands.Add('ooc', Lang:t("command.ooc.help"), {}, false, function(sourc
|
||||
TriggerClientEvent('chat:addMessage', v, {
|
||||
color = QBConfig.Commands.OOCColor,
|
||||
multiline = true,
|
||||
args = {'OOC | '.. GetPlayerName(source), message}
|
||||
args = { 'OOC | ' .. GetPlayerName(source), message }
|
||||
})
|
||||
elseif #(playerCoords - GetEntityCoords(GetPlayerPed(v))) < 20.0 then
|
||||
TriggerClientEvent('chat:addMessage', v, {
|
||||
color = QBConfig.Commands.OOCColor,
|
||||
multiline = true,
|
||||
args = {'OOC | '.. GetPlayerName(source), message}
|
||||
args = { 'OOC | ' .. GetPlayerName(source), message }
|
||||
})
|
||||
elseif QBCore.Functions.HasPermission(v, 'admin') then
|
||||
if QBCore.Functions.IsOptin(v) then
|
||||
TriggerClientEvent('chat:addMessage', v, {
|
||||
color = QBConfig.Commands.OOCColor,
|
||||
multiline = true,
|
||||
args = {'Proximity OOC | '.. GetPlayerName(source), message}
|
||||
args = { 'Proximity OOC | ' .. GetPlayerName(source), message }
|
||||
})
|
||||
TriggerEvent('qb-log:server:CreateLog', 'ooc', 'OOC', 'white', '**' .. GetPlayerName(source) .. '** (CitizenID: ' .. Player.PlayerData.citizenid .. ' | ID: ' .. source .. ') **Message:** ' .. message, false)
|
||||
end
|
||||
@@ -277,13 +277,16 @@ end, 'user')
|
||||
|
||||
-- Me command
|
||||
|
||||
QBCore.Commands.Add('me', Lang:t("command.me.help"), {{name = Lang:t("command.me.params.message.name"), help = Lang:t("command.me.params.message.help")}}, false, function(source, args)
|
||||
if #args < 1 then TriggerClientEvent('QBCore:Notify', source, Lang:t('error.missing_args2'), 'error') return end
|
||||
QBCore.Commands.Add('me', Lang:t('command.me.help'), { { name = Lang:t('command.me.params.message.name'), help = Lang:t('command.me.params.message.help') } }, false, function(source, args)
|
||||
if #args < 1 then
|
||||
TriggerClientEvent('QBCore:Notify', source, Lang:t('error.missing_args2'), 'error')
|
||||
return
|
||||
end
|
||||
local ped = GetPlayerPed(source)
|
||||
local pCoords = GetEntityCoords(ped)
|
||||
local msg = table.concat(args, ' '):gsub('[~<].-[>~]', '')
|
||||
local Players = QBCore.Functions.GetPlayers()
|
||||
for i=1, #Players do
|
||||
for i = 1, #Players do
|
||||
local Player = Players[i]
|
||||
local target = GetPlayerPed(Player)
|
||||
local tCoords = GetEntityCoords(target)
|
||||
|
||||
+9
-9
@@ -3,25 +3,25 @@ local function tPrint(tbl, indent)
|
||||
if type(tbl) == 'table' then
|
||||
for k, v in pairs(tbl) do
|
||||
local tblType = type(v)
|
||||
local formatting = ("%s ^3%s:^0"):format(string.rep(" ", indent), k)
|
||||
local formatting = ('%s ^3%s:^0'):format(string.rep(' ', indent), k)
|
||||
|
||||
if tblType == "table" then
|
||||
if tblType == 'table' then
|
||||
print(formatting)
|
||||
tPrint(v, indent + 1)
|
||||
elseif tblType == 'boolean' then
|
||||
print(("%s^1 %s ^0"):format(formatting, v))
|
||||
elseif tblType == "function" then
|
||||
print(("%s^9 %s ^0"):format(formatting, v))
|
||||
print(('%s^1 %s ^0'):format(formatting, v))
|
||||
elseif tblType == 'function' then
|
||||
print(('%s^9 %s ^0'):format(formatting, v))
|
||||
elseif tblType == 'number' then
|
||||
print(("%s^5 %s ^0"):format(formatting, v))
|
||||
print(('%s^5 %s ^0'):format(formatting, v))
|
||||
elseif tblType == 'string' then
|
||||
print(("%s ^2'%s' ^0"):format(formatting, v))
|
||||
else
|
||||
print(("%s^2 %s ^0"):format(formatting, v))
|
||||
print(('%s^2 %s ^0'):format(formatting, v))
|
||||
end
|
||||
end
|
||||
else
|
||||
print(("%s ^0%s"):format(string.rep(" ", indent), tbl))
|
||||
print(('%s ^0%s'):format(string.rep(' ', indent), tbl))
|
||||
end
|
||||
end
|
||||
|
||||
@@ -32,7 +32,7 @@ RegisterServerEvent('QBCore:DebugSomething', function(tbl, indent, resource)
|
||||
end)
|
||||
|
||||
function QBCore.Debug(tbl, indent)
|
||||
TriggerEvent('QBCore:DebugSomething', tbl, indent, GetInvokingResource() or "qb-core")
|
||||
TriggerEvent('QBCore:DebugSomething', tbl, indent, GetInvokingResource() or 'qb-core')
|
||||
end
|
||||
|
||||
function QBCore.ShowError(resource, msg)
|
||||
|
||||
+14
-14
@@ -11,7 +11,7 @@ AddEventHandler('playerDropped', function(reason)
|
||||
local src = source
|
||||
if not QBCore.Players[src] then return end
|
||||
local Player = QBCore.Players[src]
|
||||
TriggerEvent('qb-log:server:CreateLog', 'joinleave', 'Dropped', 'red', '**' .. GetPlayerName(src) .. '** (' .. Player.PlayerData.license .. ') left..' ..'\n **Reason:** ' .. reason)
|
||||
TriggerEvent('qb-log:server:CreateLog', 'joinleave', 'Dropped', 'red', '**' .. GetPlayerName(src) .. '** (' .. Player.PlayerData.license .. ') left..' .. '\n **Reason:** ' .. reason)
|
||||
Player.Functions.Save()
|
||||
QBCore.Player_Buckets[Player.PlayerData.license] = nil
|
||||
QBCore.Players[src] = nil
|
||||
@@ -41,7 +41,7 @@ local function onPlayerConnecting(name, _, deferrals)
|
||||
end
|
||||
end
|
||||
|
||||
if GetConvarInt("sv_fxdkMode", false) then
|
||||
if GetConvarInt('sv_fxdkMode', false) then
|
||||
license = 'license:AAAAAAAAAAAAAAAA' -- Dummy License
|
||||
end
|
||||
|
||||
@@ -83,7 +83,7 @@ local function onPlayerConnecting(name, _, deferrals)
|
||||
databasePromise:next(function()
|
||||
deferrals.update(string.format(Lang:t('info.join_server'), name))
|
||||
deferrals.done()
|
||||
end, function (databaseError)
|
||||
end, function(databaseError)
|
||||
deferrals.done(Lang:t('error.connecting_database_error'))
|
||||
print('^1' .. databaseError)
|
||||
end)
|
||||
@@ -99,7 +99,7 @@ local function onPlayerConnecting(name, _, deferrals)
|
||||
end
|
||||
|
||||
-- Add any additional defferals you may need!
|
||||
TriggerClientEvent('QBCore:Client:SharedUpdate',src, QBCore.Shared)
|
||||
TriggerClientEvent('QBCore:Client:SharedUpdate', src, QBCore.Shared)
|
||||
end
|
||||
|
||||
AddEventHandler('playerConnecting', onPlayerConnecting)
|
||||
@@ -118,7 +118,7 @@ RegisterNetEvent('QBCore:Server:CloseServer', function(reason)
|
||||
end
|
||||
end
|
||||
else
|
||||
QBCore.Functions.Kick(src, Lang:t("error.no_permission"), nil, nil)
|
||||
QBCore.Functions.Kick(src, Lang:t('error.no_permission'), nil, nil)
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -127,7 +127,7 @@ RegisterNetEvent('QBCore:Server:OpenServer', function()
|
||||
if QBCore.Functions.HasPermission(src, 'admin') then
|
||||
QBCore.Config.Server.Closed = false
|
||||
else
|
||||
QBCore.Functions.Kick(src, Lang:t("error.no_permission"), nil, nil)
|
||||
QBCore.Functions.Kick(src, Lang:t('error.no_permission'), nil, nil)
|
||||
end
|
||||
end)
|
||||
|
||||
@@ -180,7 +180,7 @@ RegisterNetEvent('QBCore:ToggleDuty', function()
|
||||
Player.Functions.SetJobDuty(true)
|
||||
TriggerClientEvent('QBCore:Notify', src, Lang:t('info.on_duty'))
|
||||
end
|
||||
|
||||
|
||||
TriggerEvent('QBCore:Server:SetDuty', src, Player.PlayerData.job.onduty)
|
||||
TriggerClientEvent('QBCore:Client:SetDuty', src, Player.PlayerData.job.onduty)
|
||||
end)
|
||||
@@ -188,7 +188,7 @@ end)
|
||||
-- BaseEvents
|
||||
|
||||
-- Vehicles
|
||||
RegisterServerEvent('baseevents:enteringVehicle', function(veh,seat,modelName)
|
||||
RegisterServerEvent('baseevents:enteringVehicle', function(veh, seat, modelName)
|
||||
local src = source
|
||||
local data = {
|
||||
vehicle = veh,
|
||||
@@ -199,7 +199,7 @@ RegisterServerEvent('baseevents:enteringVehicle', function(veh,seat,modelName)
|
||||
TriggerClientEvent('QBCore:Client:VehicleInfo', src, data)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('baseevents:enteredVehicle', function(veh,seat,modelName)
|
||||
RegisterServerEvent('baseevents:enteredVehicle', function(veh, seat, modelName)
|
||||
local src = source
|
||||
local data = {
|
||||
vehicle = veh,
|
||||
@@ -215,7 +215,7 @@ RegisterServerEvent('baseevents:enteringAborted', function()
|
||||
TriggerClientEvent('QBCore:Client:AbortVehicleEntering', src)
|
||||
end)
|
||||
|
||||
RegisterServerEvent('baseevents:leftVehicle', function(veh,seat,modelName)
|
||||
RegisterServerEvent('baseevents:leftVehicle', function(veh, seat, modelName)
|
||||
local src = source
|
||||
local data = {
|
||||
vehicle = veh,
|
||||
@@ -230,20 +230,20 @@ end)
|
||||
|
||||
-- This event is exploitable and should not be used. It has been deprecated, and will be removed soon.
|
||||
RegisterNetEvent('QBCore:Server:UseItem', function(item)
|
||||
print(string.format("%s triggered QBCore:Server:UseItem by ID %s with the following data. This event is deprecated due to exploitation, and will be removed soon. Check qb-inventory for the right use on this event.", GetInvokingResource(), source))
|
||||
print(string.format('%s triggered QBCore:Server:UseItem by ID %s with the following data. This event is deprecated due to exploitation, and will be removed soon. Check qb-inventory for the right use on this event.', GetInvokingResource(), source))
|
||||
QBCore.Debug(item)
|
||||
end)
|
||||
|
||||
-- This event is exploitable and should not be used. It has been deprecated, and will be removed soon. function(itemName, amount, slot)
|
||||
RegisterNetEvent('QBCore:Server:RemoveItem', function(itemName, amount)
|
||||
local src = source
|
||||
print(string.format("%s triggered QBCore:Server:RemoveItem by ID %s for %s %s. This event is deprecated due to exploitation, and will be removed soon. Adjust your events accordingly to do this server side with player functions.", GetInvokingResource(), src, amount, itemName))
|
||||
print(string.format('%s triggered QBCore:Server:RemoveItem by ID %s for %s %s. This event is deprecated due to exploitation, and will be removed soon. Adjust your events accordingly to do this server side with player functions.', GetInvokingResource(), src, amount, itemName))
|
||||
end)
|
||||
|
||||
-- This event is exploitable and should not be used. It has been deprecated, and will be removed soon. function(itemName, amount, slot, info)
|
||||
RegisterNetEvent('QBCore:Server:AddItem', function(itemName, amount)
|
||||
local src = source
|
||||
print(string.format("%s triggered QBCore:Server:AddItem by ID %s for %s %s. This event is deprecated due to exploitation, and will be removed soon. Adjust your events accordingly to do this server side with player functions.", GetInvokingResource(), src, amount, itemName))
|
||||
print(string.format('%s triggered QBCore:Server:AddItem by ID %s for %s %s. This event is deprecated due to exploitation, and will be removed soon. Adjust your events accordingly to do this server side with player functions.', GetInvokingResource(), src, amount, itemName))
|
||||
end)
|
||||
|
||||
-- Non-Chat Command Calling (ex: qb-adminmenu)
|
||||
@@ -253,7 +253,7 @@ RegisterNetEvent('QBCore:CallCommand', function(command, args)
|
||||
if not QBCore.Commands.List[command] then return end
|
||||
local Player = QBCore.Functions.GetPlayer(src)
|
||||
if not Player then return end
|
||||
local hasPerm = QBCore.Functions.HasPermission(src, "command."..QBCore.Commands.List[command].name)
|
||||
local hasPerm = QBCore.Functions.HasPermission(src, 'command.' .. QBCore.Commands.List[command].name)
|
||||
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
|
||||
TriggerClientEvent('QBCore:Notify', src, Lang:t('error.missing_args2'), 'error')
|
||||
|
||||
+57
-57
@@ -1,50 +1,50 @@
|
||||
-- Add or change (a) method(s) in the QBCore.Functions table
|
||||
local function SetMethod(methodName, handler)
|
||||
if type(methodName) ~= "string" then
|
||||
return false, "invalid_method_name"
|
||||
if type(methodName) ~= 'string' then
|
||||
return false, 'invalid_method_name'
|
||||
end
|
||||
|
||||
QBCore.Functions[methodName] = handler
|
||||
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
|
||||
return true, "success"
|
||||
return true, 'success'
|
||||
end
|
||||
|
||||
QBCore.Functions.SetMethod = SetMethod
|
||||
exports("SetMethod", SetMethod)
|
||||
exports('SetMethod', SetMethod)
|
||||
|
||||
-- Add or change (a) field(s) in the QBCore table
|
||||
local function SetField(fieldName, data)
|
||||
if type(fieldName) ~= "string" then
|
||||
return false, "invalid_field_name"
|
||||
if type(fieldName) ~= 'string' then
|
||||
return false, 'invalid_field_name'
|
||||
end
|
||||
|
||||
QBCore[fieldName] = data
|
||||
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
|
||||
return true, "success"
|
||||
return true, 'success'
|
||||
end
|
||||
|
||||
QBCore.Functions.SetField = SetField
|
||||
exports("SetField", SetField)
|
||||
exports('SetField', SetField)
|
||||
|
||||
-- Single add job function which should only be used if you planning on adding a single job
|
||||
local function AddJob(jobName, job)
|
||||
if type(jobName) ~= "string" then
|
||||
return false, "invalid_job_name"
|
||||
if type(jobName) ~= 'string' then
|
||||
return false, 'invalid_job_name'
|
||||
end
|
||||
|
||||
if QBCore.Shared.Jobs[jobName] then
|
||||
return false, "job_exists"
|
||||
return false, 'job_exists'
|
||||
end
|
||||
|
||||
QBCore.Shared.Jobs[jobName] = job
|
||||
|
||||
TriggerClientEvent('QBCore:Client:OnSharedUpdate', -1, 'Jobs', jobName, job)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, "success"
|
||||
return true, 'success'
|
||||
end
|
||||
|
||||
QBCore.Functions.AddJob = AddJob
|
||||
@@ -53,11 +53,11 @@ exports('AddJob', AddJob)
|
||||
-- Multiple Add Jobs
|
||||
local function AddJobs(jobs)
|
||||
local shouldContinue = true
|
||||
local message = "success"
|
||||
local message = 'success'
|
||||
local errorItem = nil
|
||||
|
||||
for key, value in pairs(jobs) do
|
||||
if type(key) ~= "string" then
|
||||
if type(key) ~= 'string' then
|
||||
message = 'invalid_job_name'
|
||||
shouldContinue = false
|
||||
errorItem = jobs[key]
|
||||
@@ -85,19 +85,19 @@ exports('AddJobs', AddJobs)
|
||||
|
||||
-- Single Remove Job
|
||||
local function RemoveJob(jobName)
|
||||
if type(jobName) ~= "string" then
|
||||
return false, "invalid_job_name"
|
||||
if type(jobName) ~= 'string' then
|
||||
return false, 'invalid_job_name'
|
||||
end
|
||||
|
||||
if not QBCore.Shared.Jobs[jobName] then
|
||||
return false, "job_not_exists"
|
||||
return false, 'job_not_exists'
|
||||
end
|
||||
|
||||
QBCore.Shared.Jobs[jobName] = nil
|
||||
|
||||
TriggerClientEvent('QBCore:Client:OnSharedUpdate', -1, 'Jobs', jobName, nil)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, "success"
|
||||
return true, 'success'
|
||||
end
|
||||
|
||||
QBCore.Functions.RemoveJob = RemoveJob
|
||||
@@ -105,19 +105,19 @@ exports('RemoveJob', RemoveJob)
|
||||
|
||||
-- Single Update Job
|
||||
local function UpdateJob(jobName, job)
|
||||
if type(jobName) ~= "string" then
|
||||
return false, "invalid_job_name"
|
||||
if type(jobName) ~= 'string' then
|
||||
return false, 'invalid_job_name'
|
||||
end
|
||||
|
||||
if not QBCore.Shared.Jobs[jobName] then
|
||||
return false, "job_not_exists"
|
||||
return false, 'job_not_exists'
|
||||
end
|
||||
|
||||
QBCore.Shared.Jobs[jobName] = job
|
||||
|
||||
TriggerClientEvent('QBCore:Client:OnSharedUpdate', -1, 'Jobs', jobName, job)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, "success"
|
||||
return true, 'success'
|
||||
end
|
||||
|
||||
QBCore.Functions.UpdateJob = UpdateJob
|
||||
@@ -125,19 +125,19 @@ exports('UpdateJob', UpdateJob)
|
||||
|
||||
-- Single add item
|
||||
local function AddItem(itemName, item)
|
||||
if type(itemName) ~= "string" then
|
||||
return false, "invalid_item_name"
|
||||
if type(itemName) ~= 'string' then
|
||||
return false, 'invalid_item_name'
|
||||
end
|
||||
|
||||
if QBCore.Shared.Items[itemName] then
|
||||
return false, "item_exists"
|
||||
return false, 'item_exists'
|
||||
end
|
||||
|
||||
QBCore.Shared.Items[itemName] = item
|
||||
|
||||
TriggerClientEvent('QBCore:Client:OnSharedUpdate', -1, 'Items', itemName, item)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, "success"
|
||||
return true, 'success'
|
||||
end
|
||||
|
||||
QBCore.Functions.AddItem = AddItem
|
||||
@@ -145,16 +145,16 @@ exports('AddItem', AddItem)
|
||||
|
||||
-- Single update item
|
||||
local function UpdateItem(itemName, item)
|
||||
if type(itemName) ~= "string" then
|
||||
return false, "invalid_item_name"
|
||||
if type(itemName) ~= 'string' then
|
||||
return false, 'invalid_item_name'
|
||||
end
|
||||
if not QBCore.Shared.Items[itemName] then
|
||||
return false, "item_not_exists"
|
||||
return false, 'item_not_exists'
|
||||
end
|
||||
QBCore.Shared.Items[itemName] = item
|
||||
TriggerClientEvent('QBCore:Client:OnSharedUpdate', -1, 'Items', itemName, item)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, "success"
|
||||
return true, 'success'
|
||||
end
|
||||
|
||||
QBCore.Functions.UpdateItem = UpdateItem
|
||||
@@ -163,19 +163,19 @@ exports('UpdateItem', UpdateItem)
|
||||
-- Multiple Add Items
|
||||
local function AddItems(items)
|
||||
local shouldContinue = true
|
||||
local message = "success"
|
||||
local message = 'success'
|
||||
local errorItem = nil
|
||||
|
||||
for key, value in pairs(items) do
|
||||
if type(key) ~= "string" then
|
||||
message = "invalid_item_name"
|
||||
if type(key) ~= 'string' then
|
||||
message = 'invalid_item_name'
|
||||
shouldContinue = false
|
||||
errorItem = items[key]
|
||||
break
|
||||
end
|
||||
|
||||
if QBCore.Shared.Items[key] then
|
||||
message = "item_exists"
|
||||
message = 'item_exists'
|
||||
shouldContinue = false
|
||||
errorItem = items[key]
|
||||
break
|
||||
@@ -195,19 +195,19 @@ exports('AddItems', AddItems)
|
||||
|
||||
-- Single Remove Item
|
||||
local function RemoveItem(itemName)
|
||||
if type(itemName) ~= "string" then
|
||||
return false, "invalid_item_name"
|
||||
if type(itemName) ~= 'string' then
|
||||
return false, 'invalid_item_name'
|
||||
end
|
||||
|
||||
if not QBCore.Shared.Items[itemName] then
|
||||
return false, "item_not_exists"
|
||||
return false, 'item_not_exists'
|
||||
end
|
||||
|
||||
QBCore.Shared.Items[itemName] = nil
|
||||
|
||||
TriggerClientEvent('QBCore:Client:OnSharedUpdate', -1, 'Items', itemName, nil)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, "success"
|
||||
return true, 'success'
|
||||
end
|
||||
|
||||
QBCore.Functions.RemoveItem = RemoveItem
|
||||
@@ -215,19 +215,19 @@ exports('RemoveItem', RemoveItem)
|
||||
|
||||
-- Single Add Gang
|
||||
local function AddGang(gangName, gang)
|
||||
if type(gangName) ~= "string" then
|
||||
return false, "invalid_gang_name"
|
||||
if type(gangName) ~= 'string' then
|
||||
return false, 'invalid_gang_name'
|
||||
end
|
||||
|
||||
if QBCore.Shared.Gangs[gangName] then
|
||||
return false, "gang_exists"
|
||||
return false, 'gang_exists'
|
||||
end
|
||||
|
||||
QBCore.Shared.Gangs[gangName] = gang
|
||||
|
||||
TriggerClientEvent('QBCore:Client:OnSharedUpdate', -1, 'Gangs', gangName, gang)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, "success"
|
||||
return true, 'success'
|
||||
end
|
||||
|
||||
QBCore.Functions.AddGang = AddGang
|
||||
@@ -236,19 +236,19 @@ exports('AddGang', AddGang)
|
||||
-- Multiple Add Gangs
|
||||
local function AddGangs(gangs)
|
||||
local shouldContinue = true
|
||||
local message = "success"
|
||||
local message = 'success'
|
||||
local errorItem = nil
|
||||
|
||||
for key, value in pairs(gangs) do
|
||||
if type(key) ~= "string" then
|
||||
message = "invalid_gang_name"
|
||||
if type(key) ~= 'string' then
|
||||
message = 'invalid_gang_name'
|
||||
shouldContinue = false
|
||||
errorItem = gangs[key]
|
||||
break
|
||||
end
|
||||
|
||||
if QBCore.Shared.Gangs[key] then
|
||||
message = "gang_exists"
|
||||
message = 'gang_exists'
|
||||
shouldContinue = false
|
||||
errorItem = gangs[key]
|
||||
break
|
||||
@@ -268,19 +268,19 @@ exports('AddGangs', AddGangs)
|
||||
|
||||
-- Single Remove Gang
|
||||
local function RemoveGang(gangName)
|
||||
if type(gangName) ~= "string" then
|
||||
return false, "invalid_gang_name"
|
||||
if type(gangName) ~= 'string' then
|
||||
return false, 'invalid_gang_name'
|
||||
end
|
||||
|
||||
if not QBCore.Shared.Gangs[gangName] then
|
||||
return false, "gang_not_exists"
|
||||
return false, 'gang_not_exists'
|
||||
end
|
||||
|
||||
QBCore.Shared.Gangs[gangName] = nil
|
||||
|
||||
TriggerClientEvent('QBCore:Client:OnSharedUpdate', -1, 'Gangs', gangName, nil)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, "success"
|
||||
return true, 'success'
|
||||
end
|
||||
|
||||
QBCore.Functions.RemoveGang = RemoveGang
|
||||
@@ -288,19 +288,19 @@ exports('RemoveGang', RemoveGang)
|
||||
|
||||
-- Single Update Gang
|
||||
local function UpdateGang(gangName, gang)
|
||||
if type(gangName) ~= "string" then
|
||||
return false, "invalid_gang_name"
|
||||
if type(gangName) ~= 'string' then
|
||||
return false, 'invalid_gang_name'
|
||||
end
|
||||
|
||||
if not QBCore.Shared.Gangs[gangName] then
|
||||
return false, "gang_not_exists"
|
||||
return false, 'gang_not_exists'
|
||||
end
|
||||
|
||||
QBCore.Shared.Gangs[gangName] = gang
|
||||
|
||||
TriggerClientEvent('QBCore:Client:OnSharedUpdate', -1, 'Gangs', gangName, gang)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, "success"
|
||||
return true, 'success'
|
||||
end
|
||||
|
||||
QBCore.Functions.UpdateGang = UpdateGang
|
||||
@@ -309,7 +309,7 @@ exports('UpdateGang', UpdateGang)
|
||||
local function GetCoreVersion(InvokingResource)
|
||||
local resourceVersion = GetResourceMetadata(GetCurrentResourceName(), 'version')
|
||||
if InvokingResource and InvokingResource ~= '' then
|
||||
print(("%s called qbcore version check: %s"):format(InvokingResource or 'Unknown Resource', resourceVersion))
|
||||
print(('%s called qbcore version check: %s'):format(InvokingResource or 'Unknown Resource', resourceVersion))
|
||||
end
|
||||
return resourceVersion
|
||||
end
|
||||
@@ -328,8 +328,8 @@ local function ExploitBan(playerId, origin)
|
||||
2147483647,
|
||||
'Anti Cheat'
|
||||
})
|
||||
DropPlayer(playerId, Lang:t('info.exploit_banned', {discord = QBCore.Config.Server.Discord}))
|
||||
TriggerEvent("qb-log:server:CreateLog", "anticheat", "Anti-Cheat", "red", name .. " has been banned for exploiting " .. origin, true)
|
||||
DropPlayer(playerId, Lang:t('info.exploit_banned', { discord = QBCore.Config.Server.Discord }))
|
||||
TriggerEvent('qb-log:server:CreateLog', 'anticheat', 'Anti-Cheat', 'red', name .. ' has been banned for exploiting ' .. origin, true)
|
||||
end
|
||||
|
||||
exports('ExploitBan', ExploitBan)
|
||||
|
||||
+12
-13
@@ -109,7 +109,7 @@ end
|
||||
|
||||
---Get player passing property and value to check exists
|
||||
---@param property string
|
||||
---@param value string
|
||||
---@param value string
|
||||
---@return table?
|
||||
function QBCore.Functions.GetPlayerByCharInfo(property, value)
|
||||
for src in pairs(QBCore.Players) do
|
||||
@@ -121,13 +121,12 @@ function QBCore.Functions.GetPlayerByCharInfo(property, value)
|
||||
return nil
|
||||
end
|
||||
|
||||
|
||||
---Get all players. Returns the server ids of all players.
|
||||
---@return table
|
||||
function QBCore.Functions.GetPlayers()
|
||||
local sources = {}
|
||||
for k in pairs(QBCore.Players) do
|
||||
sources[#sources+1] = k
|
||||
sources[#sources + 1] = k
|
||||
end
|
||||
return sources
|
||||
end
|
||||
@@ -187,7 +186,7 @@ function QBCore.Functions.SetPlayerBucket(source, bucket)
|
||||
if source and bucket then
|
||||
local plicense = QBCore.Functions.GetIdentifier(source, 'license')
|
||||
SetPlayerRoutingBucket(source, bucket)
|
||||
QBCore.Player_Buckets[plicense] = {id = source, bucket = bucket}
|
||||
QBCore.Player_Buckets[plicense] = { id = source, bucket = bucket }
|
||||
return true
|
||||
else
|
||||
return false
|
||||
@@ -201,7 +200,7 @@ end
|
||||
function QBCore.Functions.SetEntityBucket(entity, bucket)
|
||||
if entity and bucket then
|
||||
SetEntityRoutingBucket(entity, bucket)
|
||||
QBCore.Entity_Buckets[entity] = {id = entity, bucket = bucket}
|
||||
QBCore.Entity_Buckets[entity] = { id = entity, bucket = bucket }
|
||||
return true
|
||||
else
|
||||
return false
|
||||
@@ -319,21 +318,21 @@ function PaycheckInterval()
|
||||
if Player.PlayerData.job and payment > 0 and (QBShared.Jobs[Player.PlayerData.job.name].offDutyPay or Player.PlayerData.job.onduty) then
|
||||
if QBCore.Config.Money.PayCheckSociety then
|
||||
local account = exports['qb-management']:GetAccount(Player.PlayerData.job.name)
|
||||
if account ~= 0 then -- Checks if player is employed by a society
|
||||
if account ~= 0 then -- Checks if player is employed by a society
|
||||
if account < payment then -- Checks if company has enough money to pay society
|
||||
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('error.company_too_poor'), 'error')
|
||||
else
|
||||
Player.Functions.AddMoney('bank', payment, 'paycheck')
|
||||
exports['qb-management']:RemoveMoney(Player.PlayerData.job.name, payment)
|
||||
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', {value = payment}))
|
||||
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', { value = payment }))
|
||||
end
|
||||
else
|
||||
Player.Functions.AddMoney('bank', payment, 'paycheck')
|
||||
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', {value = payment}))
|
||||
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', { value = payment }))
|
||||
end
|
||||
else
|
||||
Player.Functions.AddMoney('bank', payment, 'paycheck')
|
||||
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', {value = payment}))
|
||||
TriggerClientEvent('QBCore:Notify', Player.PlayerData.source, Lang:t('info.received_paycheck', { value = payment }))
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -477,9 +476,9 @@ end
|
||||
---@param permission string
|
||||
---@return boolean
|
||||
function QBCore.Functions.HasPermission(source, permission)
|
||||
if type(permission) == "string" then
|
||||
if type(permission) == 'string' then
|
||||
if IsPlayerAceAllowed(source, permission) then return true end
|
||||
elseif type(permission) == "table" then
|
||||
elseif type(permission) == 'table' then
|
||||
for _, permLevel in pairs(permission) do
|
||||
if IsPlayerAceAllowed(source, permLevel) then return true end
|
||||
end
|
||||
@@ -494,7 +493,7 @@ end
|
||||
function QBCore.Functions.GetPermission(source)
|
||||
local src = source
|
||||
local perms = {}
|
||||
for _, v in pairs (QBCore.Config.Server.Permissions) do
|
||||
for _, v in pairs(QBCore.Config.Server.Permissions) do
|
||||
if IsPlayerAceAllowed(src, v) then
|
||||
perms[v] = true
|
||||
end
|
||||
@@ -587,7 +586,7 @@ function QBCore.Functions.PrepForSQL(source, data, pattern)
|
||||
local src = source
|
||||
local player = QBCore.Functions.GetPlayer(src)
|
||||
local result = string.match(data, pattern)
|
||||
if not result or string.len(result) ~= string.len(data) then
|
||||
if not result or string.len(result) ~= string.len(data) then
|
||||
TriggerEvent('qb-log:server:CreateLog', 'anticheat', 'SQL Exploit Attempted', 'red', string.format('%s attempted to exploit SQL!', player.PlayerData.license))
|
||||
return false
|
||||
end
|
||||
|
||||
+20
-20
@@ -23,7 +23,7 @@ function QBCore.Player.Login(source, citizenid, newData)
|
||||
end
|
||||
QBCore.Player.CheckPlayerData(source, PlayerData)
|
||||
else
|
||||
DropPlayer(source, Lang:t("info.exploit_dropped"))
|
||||
DropPlayer(source, Lang:t('info.exploit_dropped'))
|
||||
TriggerEvent('qb-log:server:CreateLog', 'anticheat', 'Anti-Cheat', 'white', GetPlayerName(source) .. ' Has Been Dropped For Character Joining Exploit', false)
|
||||
end
|
||||
else
|
||||
@@ -38,7 +38,7 @@ end
|
||||
|
||||
function QBCore.Player.GetOfflinePlayer(citizenid)
|
||||
if citizenid then
|
||||
local PlayerData = MySQL.prepare.await('SELECT * FROM players where citizenid = ?', {citizenid})
|
||||
local PlayerData = MySQL.prepare.await('SELECT * FROM players where citizenid = ?', { citizenid })
|
||||
if PlayerData then
|
||||
PlayerData.money = json.decode(PlayerData.money)
|
||||
PlayerData.job = json.decode(PlayerData.job)
|
||||
@@ -59,7 +59,7 @@ end
|
||||
|
||||
function QBCore.Player.GetPlayerByLicense(license)
|
||||
if license then
|
||||
local PlayerData = MySQL.prepare.await('SELECT * FROM players where license = ?', {license})
|
||||
local PlayerData = MySQL.prepare.await('SELECT * FROM players where license = ?', { license })
|
||||
if PlayerData then
|
||||
PlayerData.money = json.decode(PlayerData.money)
|
||||
PlayerData.job = json.decode(PlayerData.job)
|
||||
@@ -328,8 +328,8 @@ function QBCore.Player.CreatePlayer(PlayerData, Offline)
|
||||
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'AddMoney', 'lightgreen', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') added, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason)
|
||||
end
|
||||
TriggerClientEvent('hud:client:OnMoneyChange', self.PlayerData.source, moneytype, amount, false)
|
||||
TriggerClientEvent('QBCore:Client:OnMoneyChange', self.PlayerData.source, moneytype, amount, "add", reason)
|
||||
TriggerEvent('QBCore:Server:OnMoneyChange', self.PlayerData.source, moneytype, amount, "add", reason)
|
||||
TriggerClientEvent('QBCore:Client:OnMoneyChange', self.PlayerData.source, moneytype, amount, 'add', reason)
|
||||
TriggerEvent('QBCore:Server:OnMoneyChange', self.PlayerData.source, moneytype, amount, 'add', reason)
|
||||
end
|
||||
|
||||
return true
|
||||
@@ -361,8 +361,8 @@ function QBCore.Player.CreatePlayer(PlayerData, Offline)
|
||||
if moneytype == 'bank' then
|
||||
TriggerClientEvent('qb-phone:client:RemoveBankMoney', self.PlayerData.source, amount)
|
||||
end
|
||||
TriggerClientEvent('QBCore:Client:OnMoneyChange', self.PlayerData.source, moneytype, amount, "remove", reason)
|
||||
TriggerEvent('QBCore:Server:OnMoneyChange', self.PlayerData.source, moneytype, amount, "remove", reason)
|
||||
TriggerClientEvent('QBCore:Client:OnMoneyChange', self.PlayerData.source, moneytype, amount, 'remove', reason)
|
||||
TriggerEvent('QBCore:Server:OnMoneyChange', self.PlayerData.source, moneytype, amount, 'remove', reason)
|
||||
end
|
||||
|
||||
return true
|
||||
@@ -381,8 +381,8 @@ function QBCore.Player.CreatePlayer(PlayerData, Offline)
|
||||
self.Functions.UpdatePlayerData()
|
||||
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'SetMoney', 'green', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') set, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason)
|
||||
TriggerClientEvent('hud:client:OnMoneyChange', self.PlayerData.source, moneytype, math.abs(difference), difference < 0)
|
||||
TriggerClientEvent('QBCore:Client:OnMoneyChange', self.PlayerData.source, moneytype, amount, "set", reason)
|
||||
TriggerEvent('QBCore:Server:OnMoneyChange', self.PlayerData.source, moneytype, amount, "set", reason)
|
||||
TriggerClientEvent('QBCore:Client:OnMoneyChange', self.PlayerData.source, moneytype, amount, 'set', reason)
|
||||
TriggerEvent('QBCore:Server:OnMoneyChange', self.PlayerData.source, moneytype, amount, 'set', reason)
|
||||
end
|
||||
|
||||
return true
|
||||
@@ -457,7 +457,7 @@ end
|
||||
|
||||
function QBCore.Functions.AddPlayerMethod(ids, methodName, handler)
|
||||
local idType = type(ids)
|
||||
if idType == "number" then
|
||||
if idType == 'number' then
|
||||
if ids == -1 then
|
||||
for _, v in pairs(QBCore.Players) do
|
||||
v.Functions.AddMethod(methodName, handler)
|
||||
@@ -467,7 +467,7 @@ function QBCore.Functions.AddPlayerMethod(ids, methodName, handler)
|
||||
|
||||
QBCore.Players[ids].Functions.AddMethod(methodName, handler)
|
||||
end
|
||||
elseif idType == "table" and table.type(ids) == "array" then
|
||||
elseif idType == 'table' and table.type(ids) == 'array' then
|
||||
for i = 1, #ids do
|
||||
QBCore.Functions.AddPlayerMethod(ids[i], methodName, handler)
|
||||
end
|
||||
@@ -484,7 +484,7 @@ end
|
||||
|
||||
function QBCore.Functions.AddPlayerField(ids, fieldName, data)
|
||||
local idType = type(ids)
|
||||
if idType == "number" then
|
||||
if idType == 'number' then
|
||||
if ids == -1 then
|
||||
for _, v in pairs(QBCore.Players) do
|
||||
v.Functions.AddField(fieldName, data)
|
||||
@@ -494,7 +494,7 @@ function QBCore.Functions.AddPlayerField(ids, fieldName, data)
|
||||
|
||||
QBCore.Players[ids].Functions.AddField(fieldName, data)
|
||||
end
|
||||
elseif idType == "table" and table.type(ids) == "array" then
|
||||
elseif idType == 'table' and table.type(ids) == 'array' then
|
||||
for i = 1, #ids do
|
||||
QBCore.Functions.AddPlayerField(ids[i], fieldName, data)
|
||||
end
|
||||
@@ -569,13 +569,13 @@ function QBCore.Player.DeleteCharacter(source, citizenid)
|
||||
local license = QBCore.Functions.GetIdentifier(source, 'license')
|
||||
local result = MySQL.scalar.await('SELECT license FROM players where citizenid = ?', { citizenid })
|
||||
if license == result then
|
||||
local query = "DELETE FROM %s WHERE citizenid = ?"
|
||||
local query = 'DELETE FROM %s WHERE citizenid = ?'
|
||||
local tableCount = #playertables
|
||||
local queries = table.create(tableCount, 0)
|
||||
|
||||
for i = 1, tableCount do
|
||||
local v = playertables[i]
|
||||
queries[i] = {query = query:format(v.table), values = { citizenid }}
|
||||
queries[i] = { query = query:format(v.table), values = { citizenid } }
|
||||
end
|
||||
|
||||
MySQL.transaction(queries, function(result2)
|
||||
@@ -584,7 +584,7 @@ function QBCore.Player.DeleteCharacter(source, citizenid)
|
||||
end
|
||||
end)
|
||||
else
|
||||
DropPlayer(source, Lang:t("info.exploit_dropped"))
|
||||
DropPlayer(source, Lang:t('info.exploit_dropped'))
|
||||
TriggerEvent('qb-log:server:CreateLog', 'anticheat', 'Anti-Cheat', 'white', GetPlayerName(source) .. ' Has Been Dropped For Character Deletion Exploit', true)
|
||||
end
|
||||
end
|
||||
@@ -592,17 +592,17 @@ end
|
||||
function QBCore.Player.ForceDeleteCharacter(citizenid)
|
||||
local result = MySQL.scalar.await('SELECT license FROM players where citizenid = ?', { citizenid })
|
||||
if result then
|
||||
local query = "DELETE FROM %s WHERE citizenid = ?"
|
||||
local query = 'DELETE FROM %s WHERE citizenid = ?'
|
||||
local tableCount = #playertables
|
||||
local queries = table.create(tableCount, 0)
|
||||
local Player = QBCore.Functions.GetPlayerByCitizenId(citizenid)
|
||||
|
||||
if Player then
|
||||
DropPlayer(Player.PlayerData.source, "An admin deleted the character which you are currently using")
|
||||
DropPlayer(Player.PlayerData.source, 'An admin deleted the character which you are currently using')
|
||||
end
|
||||
for i = 1, tableCount do
|
||||
local v = playertables[i]
|
||||
queries[i] = {query = query:format(v.table), values = { citizenid }}
|
||||
queries[i] = { query = query:format(v.table), values = { citizenid } }
|
||||
end
|
||||
|
||||
MySQL.transaction(queries, function(result2)
|
||||
@@ -673,7 +673,7 @@ function QBCore.Functions.CreatePhoneNumber()
|
||||
local UniqueFound = false
|
||||
local PhoneNumber = nil
|
||||
while not UniqueFound do
|
||||
PhoneNumber = math.random(100,999) .. math.random(1000000,9999999)
|
||||
PhoneNumber = math.random(100, 999) .. math.random(1000000, 9999999)
|
||||
local query = '%' .. PhoneNumber .. '%'
|
||||
local result = MySQL.prepare.await('SELECT COUNT(*) as count FROM players WHERE charinfo LIKE ?', { query })
|
||||
if result == 0 then
|
||||
|
||||
Reference in New Issue
Block a user