Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(server/consumables): remove unused Player variable #480

Merged
merged 8 commits into from
Jan 6, 2025
6 changes: 0 additions & 6 deletions server/consumables.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ end

for k, _ in pairs(Config.Consumables.eat) do
QBCore.Functions.CreateUseableItem(k, function(source, item)
local Player = QBCore.Functions.GetPlayer(source)
if not exports['qb-inventory']:RemoveItem(source, item.name, 1, item.slot, 'qb-smallresources:consumables:eat') then return end
TriggerClientEvent('consumables:client:Eat', source, item.name)
end)
Expand All @@ -20,7 +19,6 @@ end
----------- / Drink
for k, _ in pairs(Config.Consumables.drink) do
QBCore.Functions.CreateUseableItem(k, function(source, item)
local Player = QBCore.Functions.GetPlayer(source)
if not exports['qb-inventory']:RemoveItem(source, item.name, 1, item.slot, 'qb-smallresources:consumables:drink') then return end
TriggerClientEvent('consumables:client:Drink', source, item.name)
end)
Expand All @@ -29,23 +27,20 @@ end
----------- / Custom
for k, _ in pairs(Config.Consumables.custom) do
QBCore.Functions.CreateUseableItem(k, function(source, item)
local Player = QBCore.Functions.GetPlayer(source)
if not exports['qb-inventory']:RemoveItem(source, item.name, 1, item.slot, 'qb-smallresources:consumables:custom') then return end
TriggerClientEvent('consumables:client:Custom', source, item.name)
end)
end

local function createItem(name, type)
QBCore.Functions.CreateUseableItem(name, function(source, item)
local Player = QBCore.Functions.GetPlayer(source)
if not exports['qb-inventory']:RemoveItem(source, item.name, 1, item.slot, 'qb-smallresources:consumables:createItem') then return end
TriggerClientEvent('consumables:client:' .. type, source, item.name)
end)
end
----------- / Drug

QBCore.Functions.CreateUseableItem('joint', function(source, item)
local Player = QBCore.Functions.GetPlayer(source)
if not exports['qb-inventory']:RemoveItem(source, item.name, 1, item.slot, 'qb-smallresources:joint') then return end
TriggerClientEvent('consumables:client:UseJoint', source)
end)
Expand Down Expand Up @@ -94,7 +89,6 @@ QBCore.Functions.CreateUseableItem('binoculars', function(source)
end)

QBCore.Functions.CreateUseableItem('parachute', function(source, item)
local Player = QBCore.Functions.GetPlayer(source)
if not exports['qb-inventory']:RemoveItem(source, item.name, 1, item.slot, 'qb-smallresources:parachute') then return end
TriggerClientEvent('consumables:client:UseParachute', source)
end)
Expand Down
8 changes: 4 additions & 4 deletions server/logs.lua
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,6 @@ local colors = { -- https://www.spycolor.com/
local logQueue = {}

RegisterNetEvent('qb-log:server:CreateLog', function(name, title, color, message, tagEveryone, imageUrl)
local postData = {}
local tag = tagEveryone or false

if Config.Logging == 'discord' then
Expand Down Expand Up @@ -86,11 +85,12 @@ RegisterNetEvent('qb-log:server:CreateLog', function(name, title, color, message
logQueue[name][#logQueue[name] + 1] = { webhook = webHook, data = embedData }

if #logQueue[name] >= 10 then
local postData = { username = 'QB Logs', embeds = {} }

if tag then
postData = { username = 'QB Logs', content = '@everyone', embeds = {} }
else
postData = { username = 'QB Logs', embeds = {} }
postData.content = '@everyone'
end

for i = 1, #logQueue[name] do postData.embeds[#postData.embeds + 1] = logQueue[name][i].data[1] end
PerformHttpRequest(logQueue[name][1].webhook, function() end, 'POST', json.encode(postData), { ['Content-Type'] = 'application/json' })
logQueue[name] = {}
Expand Down
Loading