mirror of
https://github.com/qbcore-fivem/qb-core.git
synced 2026-09-01 10:48:56 +00:00
Fix Styling (#758)
* style: ensure consistent indentation * style: add spacing * style: add newlines * style: simplify html * fix: update javascript indent size in contribution guidelines
This commit is contained in:
+2
-2
@@ -37,9 +37,9 @@ function QBCore.Debug(tbl, indent)
|
||||
end
|
||||
|
||||
function QBCore.ShowError(resource, msg)
|
||||
print('\x1b[31m['..resource..':ERROR]\x1b[0m '..msg)
|
||||
print('\x1b[31m[' .. resource .. ':ERROR]\x1b[0m ' .. msg)
|
||||
end
|
||||
|
||||
function QBCore.ShowSuccess(resource, msg)
|
||||
print('\x1b[32m['..resource..':LOG]\x1b[0m '..msg)
|
||||
print('\x1b[32m[' .. resource .. ':LOG]\x1b[0m ' .. msg)
|
||||
end
|
||||
|
||||
+14
-14
@@ -216,31 +216,31 @@ QBCore.Functions.CreateCallback('QBCore:HasItem', function(source, cb, items, am
|
||||
local Player = QBCore.Functions.GetPlayer(source)
|
||||
if not Player then return cb(false) end
|
||||
local isTable = type(items) == 'table'
|
||||
local isArray = isTable and table.type(items) == 'array' or false
|
||||
local totalItems = #items
|
||||
local count = 0
|
||||
local isArray = isTable and table.type(items) == 'array' or false
|
||||
local totalItems = #items
|
||||
local count = 0
|
||||
local kvIndex = 2
|
||||
if isTable and not isArray then
|
||||
if isTable and not isArray then
|
||||
totalItems = 0
|
||||
for _ in pairs(items) do totalItems += 1 end
|
||||
kvIndex = 1
|
||||
end
|
||||
if isTable then
|
||||
for k, v in pairs(items) do
|
||||
local itemKV = {k, v}
|
||||
local item = Player.Functions.GetItemByName(itemKV[kvIndex])
|
||||
for k, v in pairs(items) do
|
||||
local itemKV = {k, v}
|
||||
local item = Player.Functions.GetItemByName(itemKV[kvIndex])
|
||||
if item and ((amount and item.amount >= amount) or (not amount and not isArray and item.amount >= v) or (not amount and isArray)) then
|
||||
count += 1
|
||||
end
|
||||
end
|
||||
if count == totalItems then
|
||||
retval = true
|
||||
end
|
||||
else -- Single item as string
|
||||
local item = Player.Functions.GetItemByName(items)
|
||||
end
|
||||
if count == totalItems then
|
||||
retval = true
|
||||
end
|
||||
else -- Single item as string
|
||||
local item = Player.Functions.GetItemByName(items)
|
||||
if item and not amount or (item and amount and item.amount >= amount) then
|
||||
retval = true
|
||||
end
|
||||
end
|
||||
end
|
||||
cb(retval)
|
||||
end)
|
||||
|
||||
+16
-2
@@ -10,10 +10,11 @@ local function AddJob(jobName, job)
|
||||
|
||||
QBCore.Shared.Jobs[jobName] = job
|
||||
|
||||
TriggerClientEvent('QBCore:Client:OnSharedUpdate', -1,'Jobs', jobName, job)
|
||||
TriggerClientEvent('QBCore:Client:OnSharedUpdate', -1, 'Jobs', jobName, job)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, "success"
|
||||
end
|
||||
|
||||
QBCore.Functions.AddJob = AddJob
|
||||
exports('AddJob', AddJob)
|
||||
|
||||
@@ -46,6 +47,7 @@ local function AddJobs(jobs)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, message, nil
|
||||
end
|
||||
|
||||
QBCore.Functions.AddJobs = AddJobs
|
||||
exports('AddJobs', AddJobs)
|
||||
|
||||
@@ -65,6 +67,7 @@ local function RemoveJob(jobName)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, "success"
|
||||
end
|
||||
|
||||
QBCore.Functions.RemoveJob = RemoveJob
|
||||
exports('RemoveJob', RemoveJob)
|
||||
|
||||
@@ -84,6 +87,7 @@ local function UpdateJob(jobName, job)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, "success"
|
||||
end
|
||||
|
||||
QBCore.Functions.UpdateJob = UpdateJob
|
||||
exports('UpdateJob', UpdateJob)
|
||||
|
||||
@@ -103,6 +107,7 @@ local function AddItem(itemName, item)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, "success"
|
||||
end
|
||||
|
||||
QBCore.Functions.AddItem = AddItem
|
||||
exports('AddItem', AddItem)
|
||||
|
||||
@@ -119,6 +124,7 @@ local function UpdateItem(itemName, item)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, "success"
|
||||
end
|
||||
|
||||
QBCore.Functions.UpdateItem = UpdateItem
|
||||
exports('UpdateItem', UpdateItem)
|
||||
|
||||
@@ -151,6 +157,7 @@ local function AddItems(items)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, message, nil
|
||||
end
|
||||
|
||||
QBCore.Functions.AddItems = AddItems
|
||||
exports('AddItems', AddItems)
|
||||
|
||||
@@ -170,6 +177,7 @@ local function RemoveItem(itemName)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, "success"
|
||||
end
|
||||
|
||||
QBCore.Functions.RemoveItem = RemoveItem
|
||||
exports('RemoveItem', RemoveItem)
|
||||
|
||||
@@ -189,6 +197,7 @@ local function AddGang(gangName, gang)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, "success"
|
||||
end
|
||||
|
||||
QBCore.Functions.AddGang = AddGang
|
||||
exports('AddGang', AddGang)
|
||||
|
||||
@@ -221,6 +230,7 @@ local function AddGangs(gangs)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, message, nil
|
||||
end
|
||||
|
||||
QBCore.Functions.AddGangs = AddGangs
|
||||
exports('AddGangs', AddGangs)
|
||||
|
||||
@@ -240,6 +250,7 @@ local function RemoveGang(gangName)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, "success"
|
||||
end
|
||||
|
||||
QBCore.Functions.RemoveGang = RemoveGang
|
||||
exports('RemoveGang', RemoveGang)
|
||||
|
||||
@@ -259,6 +270,7 @@ local function UpdateGang(gangName, gang)
|
||||
TriggerEvent('QBCore:Server:UpdateObject')
|
||||
return true, "success"
|
||||
end
|
||||
|
||||
QBCore.Functions.UpdateGang = UpdateGang
|
||||
exports('UpdateGang', UpdateGang)
|
||||
|
||||
@@ -269,6 +281,7 @@ local function GetCoreVersion(InvokingResource)
|
||||
end
|
||||
return resourceVersion
|
||||
end
|
||||
|
||||
QBCore.Functions.GetCoreVersion = GetCoreVersion
|
||||
exports('GetCoreVersion', GetCoreVersion)
|
||||
|
||||
@@ -284,6 +297,7 @@ local function ExploitBan(playerId, origin)
|
||||
'Anti Cheat'
|
||||
})
|
||||
DropPlayer(playerId, "You have been banned for cheating. Check our Discord for more information: " .. QBCore.Config.Server.Discord)
|
||||
TriggerEvent("qb-log:server:CreateLog", "anticheat", "Anti-Cheat", "red", name.." has been banned for exploiting "..origin, true)
|
||||
TriggerEvent("qb-log:server:CreateLog", "anticheat", "Anti-Cheat", "red", name .. " has been banned for exploiting " .. origin, true)
|
||||
end
|
||||
|
||||
exports('ExploitBan', ExploitBan)
|
||||
|
||||
@@ -374,11 +374,11 @@ function QBCore.Functions.HasItem(source, items, amount)
|
||||
local Player = QBCore.Functions.GetPlayer(source)
|
||||
if not Player then return false end
|
||||
local isTable = type(items) == 'table'
|
||||
local isArray = isTable and table.type(items) == 'array' or false
|
||||
local totalItems = #items
|
||||
local isArray = isTable and table.type(items) == 'array' or false
|
||||
local totalItems = #items
|
||||
local count = 0
|
||||
local kvIndex = 2
|
||||
if isTable and not isArray then
|
||||
if isTable and not isArray then
|
||||
totalItems = 0
|
||||
for _ in pairs(items) do totalItems += 1 end
|
||||
kvIndex = 1
|
||||
|
||||
+9
-9
@@ -600,19 +600,19 @@ function QBCore.Player.DeleteCharacter(source, citizenid)
|
||||
local result = MySQL.scalar.await('SELECT license FROM players where citizenid = ?', { citizenid })
|
||||
if license == result then
|
||||
local query = "DELETE FROM %s WHERE citizenid = ?"
|
||||
local tableCount = #playertables
|
||||
local queries = table.create(tableCount, 0)
|
||||
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 }}
|
||||
end
|
||||
for i = 1, tableCount do
|
||||
local v = playertables[i]
|
||||
queries[i] = {query = query:format(v.table), values = { citizenid }}
|
||||
end
|
||||
|
||||
MySQL.transaction(queries, function(result2)
|
||||
if result2 then
|
||||
TriggerEvent('qb-log:server:CreateLog', 'joinleave', 'Character Deleted', 'red', '**' .. GetPlayerName(source) .. '** ' .. license .. ' deleted **' .. citizenid .. '**..')
|
||||
if result2 then
|
||||
TriggerEvent('qb-log:server:CreateLog', 'joinleave', 'Character Deleted', 'red', '**' .. GetPlayerName(source) .. '** ' .. license .. ' deleted **' .. citizenid .. '**..')
|
||||
end
|
||||
end)
|
||||
end)
|
||||
else
|
||||
DropPlayer(source, 'You Have Been Kicked For Exploitation')
|
||||
TriggerEvent('qb-log:server:CreateLog', 'anticheat', 'Anti-Cheat', 'white', GetPlayerName(source) .. ' Has Been Dropped For Character Deletion Exploit', true)
|
||||
|
||||
Reference in New Issue
Block a user