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
2 changes: 1 addition & 1 deletion 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,6 +85,7 @@ 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 = nil

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Try initialising it with our else data, and append content if tag is true (postData.content = '@everyone'). This means the else block wouldn't be needed.
local postData = { username = 'QB Logs', embeds = {} }

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks for your comment!!

if tag then
postData = { username = 'QB Logs', content = '@everyone', embeds = {} }
else
Expand Down
Loading