
İtem Money
This document explains the required modifications in `qb-core` and `qb-inventory` for money functions and inventory events. Code blocks are copy-paste ready.
RemoveMoney Function
Description: qb-core/server/player.lua Replace self.Functions.RemoveMoney with the following:
function self.Functions.RemoveMoney(moneytype, amount, reason)
source = self.PlayerData.source
reason = reason or 'unknown'
moneytype = moneytype:lower()
amount = tonumber(amount)
if amount < 0 then return end
if not self.PlayerData.money[moneytype] then return false end
for _, mtype in pairs(QBCore.Config.Money.DontAllowMinus) do
if mtype == moneytype and moneytype == not 'cash' then
if (self.PlayerData.money[moneytype] - amount) < 0 then
return false
end
end
end
if moneytype == 'cash' then
if exports['qb-inventory']:HasItem(source,'cash') then
local totalmoney = self.Functions.GetMoney('cash')
if totalmoney >= amount then
self.PlayerData.money[moneytype] = self.PlayerData.money[moneytype] - amount
local slots = exports['qb-inventory']:GetSlotsByItem(self.PlayerData.items,'cash')
for k,v in pairs(slots) do
local toRemove = math.min(exports['qb-inventory']:GetItemBySlot(source,slots[k]).amount,amount)
exports['qb-inventory']:RemoveItem(source,'cash',toRemove,slots[k],nil,"qb-core:addmoney")
TriggerClientEvent('inventory:client:ItemBox',source, QBCore.Shared.Items['cash'], "remove",toRemove)
end
else
return false
end
else
return false
end
else
self.PlayerData.money[moneytype] = self.PlayerData.money[moneytype] - amount
end
if not self.Offline then
self.Functions.UpdatePlayerData()
if amount > 100000 then
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'RemoveMoney', 'red', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') removed, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason, true)
else
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'RemoveMoney', 'red', '**' .. GetPlayerName(self.PlayerData.source) .. ' (citizenid: ' .. self.PlayerData.citizenid .. ' | id: ' .. self.PlayerData.source .. ')** $' .. amount .. ' (' .. moneytype .. ') removed, new ' .. moneytype .. ' balance: ' .. self.PlayerData.money[moneytype] .. ' reason: ' .. reason)
end
TriggerClientEvent('hud:client:OnMoneyChange', self.PlayerData.source, moneytype, amount, true)
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)
end
return true
endAddMoney Function
Description: qb-core/server/player.lua Replace self.Functions.AddMoney with the following:
function self.Functions.AddMoney(moneytype, amount, reason)
source = self.PlayerData.source
reason = reason or 'unknown'
moneytype = moneytype:lower()
amount = tonumber(amount)
if amount < 0 then return end
if not self.PlayerData.money[moneytype] then return false end
self.PlayerData.money[moneytype] = self.PlayerData.money[moneytype] + amount
if moneytype == 'cash' then
if exports['qb-inventory']:HasItem(source,'cash') then
local slots = exports['qb-inventory']:GetSlotsByItem(self.PlayerData.items,'cash')
exports['qb-inventory']:AddItem(source,'cash',amount,slots[1],nil,"qb-core:addmoney")
TriggerClientEvent('inventory:client:ItemBox',source, QBCore.Shared.Items['cash'], "add",amount)
else
exports['qb-inventory']:AddItem(source,'cash',amount,nil,nil,"qb-core:addmoney")
TriggerClientEvent('inventory:client:ItemBox',source, QBCore.Shared.Items['cash'], "add",amount)
end
end
if not self.Offline then
self.Functions.UpdatePlayerData()
if amount > 100000 then
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, true)
else
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)
end
return true
endSetMoney Function
Description: qb-core/server/player.lua Replace self.Functions.SetMoney with the following:
function self.Functions.SetMoney(moneytype, amount, reason)
source = self.PlayerData.source
reason = reason or 'unknown'
moneytype = moneytype:lower()
amount = tonumber(amount)
if amount < 0 then return false end
if not self.PlayerData.money[moneytype] then return false end
self.PlayerData.money[moneytype] = amount
local difference = 0
if moneytype == 'cash' then
if exports['qb-inventory']:HasItem(source,'cash') then
local item = exports['qb-inventory']:GetItemByName(source,'cash')
local slot = exports['qb-inventory']:GetItemBySlot(self.PlayerData.items,item)
exports['qb-inventory']:RemoveItem(source,'cash',item.amount,slot,nil,"qb-core:addmoney")
exports['qb-inventory']:AddItem(source,'cash',amount,slot,nil,"qb-core:addmoney")
difference = amount - item.amount
else
exports['qb-inventory']:AddItem(source,'cash',amount)
difference = amount
end
else
difference = amount - self.PlayerData.money[moneytype]
self.PlayerData.money[moneytype] = amount
end
if not self.Offline then
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)
end
return true
end🔍 GetMoney Function
Description: qb-core/server/player.lua Replace self.Functions.GetMoney with the following:
function self.Functions.GetMoney(moneytype, set)
source = self.PlayerData.source
if not moneytype then return false end
moneytype = moneytype:lower()
if moneytype == 'cash' then
if exports['qb-inventory']:HasItem(source,'cash') then
local slots = exports['qb-inventory']:GetSlotsByItem(self.PlayerData.items,'cash')
local totalmoney = 0
for k,v in pairs(slots) do
totalmoney = totalmoney + exports['qb-inventory']:GetItemBySlot(source,slots[k]).amount
end
if set then
self.PlayerData.money["cash"] = totalmoney
self.Functions.UpdatePlayerData()
TriggerClientEvent('QBCore:Client:OnMoneyChange', self.PlayerData.source, "cash", totalmoney, "set", "getmoney")
TriggerEvent('QBCore:Server:OnMoneyChange', self.PlayerData.source, "cash", totalmoney, "set", "getmoney")
end
return totalmoney
else
if set then
self.PlayerData.money["cash"] = 0
self.Functions.UpdatePlayerData()
TriggerClientEvent('QBCore:Client:OnMoneyChange', self.PlayerData.source, "cash", 0, "set", "getmoney")
TriggerEvent('QBCore:Server:OnMoneyChange', self.PlayerData.source, "cash", 0, "set", "getmoney")
end
return 0
end
else
return self.PlayerData.money[moneytype]
end
end🔍 AddItem Function
Description: qb-inventory/server/open_server.lua Replace the AddItem function with the following:
function AddItem(source, item, amount, slot, info,reason, created, ismoney)
local Player = QBCore.Functions.GetPlayer(source)
if Stashes[source] then
if not QBCore.Shared.Items[item:lower()].unique then
slot = slot or GetFirstSlotByItem(Stashes[source].items, item)
if not slot then slot = slot or GetFirstFreeSlot(Stashes[source].items, Stashes[source].slots or Config.StashSize.slots) end
else
slot = slot or GetFirstFreeSlot(Stashes[source].items, Stashes[source].slots or Config.StashSize.slots)
end
AddToStash(source, slot, slot, QBCore.Shared.Items[item:lower()]["name"], amount, info, created)
return true
elseif Drops[source] then
if not QBCore.Shared.Items[item:lower()].unique then
slot = slot or GetFirstSlotByItem(Drops[source].items, item)
end
AddToDrop(source, slot, QBCore.Shared.Items[item:lower()]["name"], amount, info,created)
return true
elseif not Player then return false end
local totalWeight = GetTotalPlayerWeight(Player.PlayerData.items)
local itemInfo = QBCore.Shared.Items[item:lower()]
local time = os.time()
local maxweight = Config.MaxInventoryWeight
local addReason = reason or 'No reason specified'
local resourceName = GetInvokingResource() or 'qb-inventory'
if not itemInfo and not Player.Offline then
QBCore.Functions.Notify(source, Lang:t("notify.no_suchitem"), "error")
return false
end
if itemInfo['unique'] then
amount = 1
else
amount = tonumber(amount) or 1
end
slot = tonumber(slot)
totalWeight = GetInvWeight(Player.PlayerData.items) + GetBacpackWeight(Player.PlayerData.items)
maxweight = Config.MaxInventoryWeight+Config.MaxBackpackWeight
if slot and slot < Config.MaxInventorySlots then
if (GetInvWeight(Player.PlayerData.items) + (itemInfo['weight'] * amount)) > Config.MaxInventoryWeight then
slot = false
end
end
info = info or {}
if not created then
created = time
end
if itemInfo['type'] == 'item' then
info.quality = info.quality or 100
end
if itemInfo['type'] == 'weapon' then
info.serie = info.serie or tostring(QBCore.Shared.RandomInt(2) .. QBCore.Shared.RandomStr(3) .. QBCore.Shared.RandomInt(1) .. QBCore.Shared.RandomStr(2) .. QBCore.Shared.RandomInt(3) .. QBCore.Shared.RandomStr(4))
info.quality = info.quality or 100
end
if (totalWeight + (itemInfo['weight'] * amount)) <= maxweight then
totalWeight = GetInvWeight(Player.PlayerData.items)
totalWeight2 = GetBacpackWeight(Player.PlayerData.items)
if (slot and Player.PlayerData.items[slot]) and (Player.PlayerData.items[slot].name:lower() == item:lower()) and (itemInfo['type'] == 'item' and not itemInfo['unique']) then
if slot <= Config.MaxInventorySlots and totalWeight + (itemInfo['weight'] * amount) > Config.MaxInventoryWeight then
return false
elseif(slot > Config.MaxInventorySlots and totalWeight2 + (itemInfo['weight'] * amount) > Config.MaxBackpackWeight) then
return false
end
Player.PlayerData.items[slot].created = created
Player.PlayerData.items[slot].amount = Player.PlayerData.items[slot].amount + amount
Player.Functions.SetPlayerData("items", Player.PlayerData.items)
if Player.Offline then return true end
TriggerEvent('qb-log:server:CreateLog', 'additem', 'AddItem', 'green', '**' .. GetPlayerName(source) .. ' (citizenid: ' .. Player.PlayerData.citizenid .. ' | id: ' .. source .. ')** got item: [slot:' .. slot .. '], itemname: ' .. Player.PlayerData.items[slot].name .. ', added amount: ' .. amount .. ', new total amount: ' .. Player.PlayerData.items[slot].amount.. ', reason: ' ..addReason..', resource:'..resourceName )
if item:lower() == "cash" and reason ~= "qb-core:addmoney" and not ismoney then
Player.Functions.GetMoney('cash',true)
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'AddMoney Envanter', 'lightgreen', '**' .. GetPlayerName(source) .. ' (citizenid: ' .. Player.PlayerData.citizenid .. ' | id: ' .. source .. ')** $' .. amount .. ' (cash) added')
end
return true
elseif not itemInfo['unique'] and slot or slot and Player.PlayerData.items[slot] == nil then
if slot <= Config.MaxInventorySlots and totalWeight + (itemInfo['weight'] * amount) > Config.MaxInventoryWeight then
return false
elseif(slot > Config.MaxInventorySlots and totalWeight2 + (itemInfo['weight'] * amount) > Config.MaxBackpackWeight) then
return false
end
Player.PlayerData.items[slot] = { name = itemInfo['name'], amount = amount, info = info or '', label = itemInfo['label'], description = itemInfo['description'] or '', weight = itemInfo['weight'], type = itemInfo['type'], unique = itemInfo['unique'], useable = itemInfo['useable'], image = itemInfo['image'], shouldClose = itemInfo['shouldClose'], slot = slot, combinable = itemInfo['combinable'], created = created }
Player.Functions.SetPlayerData("items", Player.PlayerData.items)
if Player.Offline then return true end
TriggerEvent('qb-log:server:CreateLog', 'additem', 'AddItem', 'green', '**' .. GetPlayerName(source) .. ' (citizenid: ' .. Player.PlayerData.citizenid .. ' | id: ' .. source .. ')** got item: [slot:' .. slot .. '], itemname: ' .. Player.PlayerData.items[slot].name .. ', added amount: ' .. amount .. ', new total amount: ' .. Player.PlayerData.items[slot].amount.. ', reason: ' ..addReason..', resource:'..resourceName)
if item:lower() == "cash" and reason ~= "qb-core:addmoney" and not ismoney then
Player.Functions.GetMoney('cash',true)
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'AddMoney Envanter', 'lightgreen', '**' .. GetPlayerName(source) .. ' (citizenid: ' .. Player.PlayerData.citizenid .. ' | id: ' .. source .. ')** $' .. amount .. ' (cash) added')
end
return true
elseif itemInfo['unique'] or (not slot or slot == nil) or itemInfo['type'] == 'weapon' then
oldslots = GetFirstSlotByItem(Player.PlayerData.items, item,0,Config.MaxInventorySlots,info.quality)
newslot = GetFirstSlotByItem(Player.PlayerData.items, item,Config.MaxInventorySlots-1,Config.MaxInventorySlots+Config.MaxBackpackSlots,info.quality)
for i = 1, Config.MaxInventorySlots+Config.MaxBackpackSlots, 1 do
::skip_to_next::
if Player.PlayerData.items[i] == nil then
amounts = nil
if (totalWeight + (itemInfo['weight'] * amount)) > Config.MaxInventoryWeight and i <= Config.MaxInventorySlots and not itemInfo['unique'] then
if newslot ~= nil then
i = newslot
amounts = math.floor((Config.MaxInventoryWeight-totalWeight) / itemInfo['weight'])
else
i= i+1
goto skip_to_next
end
elseif (totalWeight2 + (itemInfo['weight'] * amount)) > Config.MaxBackpackWeight and i > Config.MaxInventorySlots and not itemInfo['unique'] then
if oldslots ~= nil then
i = oldslots
amounts = math.floor((Config.MaxBackpackWeight-totalWeight2) / itemInfo['weight'])
else
i= i+1
goto skip_to_next
end
end
if oldslots ~= nil and totalWeight + (itemInfo['weight'] * amount) > Config.MaxInventoryWeight and not amounts then
oldslots = nil
elseif newslot ~= nil and totalWeight2 + (itemInfo['weight'] * amount) > Config.MaxBackpackWeight and not amounts then
newslot = nil
end
if newslot and not itemInfo['unique'] then
i = newslot
if oldslots and amounts and amounts > 0 then
Player.PlayerData.items[oldslots].amount = Player.PlayerData.items[oldslots].amount + amounts
Player.PlayerData.items[newslot].amount = Player.PlayerData.items[newslot].amount + (amount-amounts)
else
Player.PlayerData.items[newslot].amount = Player.PlayerData.items[newslot].amount + amount
end
elseif oldslots and not itemInfo['unique'] then
i = oldslots
if newslot and amounts and amounts > 0 then
Player.PlayerData.items[newslot].amount = Player.PlayerData.items[newslot].amount + amounts
Player.PlayerData.items[oldslots].amount = Player.PlayerData.items[oldslots].amount + (amount-amounts)
else
Player.PlayerData.items[oldslots].amount = Player.PlayerData.items[oldslots].amount + amount
end
else
if i <= Config.MaxInventorySlots and totalWeight + (itemInfo['weight'] * amount) > Config.MaxInventoryWeight then
i= i+1
goto skip_to_next
elseif i > Config.MaxInventorySlots and totalWeight2 + (itemInfo['weight'] * amount) > Config.MaxBackpackWeight then
i= i+1
goto skip_to_next
end
Player.PlayerData.items[i] = { name = itemInfo['name'], amount = amount, info = info or '', label = itemInfo['label'], description = itemInfo['description'] or '', weight = itemInfo['weight'], type = itemInfo['type'], unique = itemInfo['unique'], useable = itemInfo['useable'], image = itemInfo['image'], shouldClose = itemInfo['shouldClose'], slot = i, combinable = itemInfo['combinable'], created = created }
end
Player.Functions.SetPlayerData("items", Player.PlayerData.items)
if Player.Offline then return true end
TriggerEvent('qb-log:server:CreateLog', 'additem', 'AddItem', 'green', '**' .. GetPlayerName(source) .. ' (citizenid: ' .. Player.PlayerData.citizenid .. ' | id: ' .. source .. ')** got item: [slot:' .. i .. '], itemname: ' .. Player.PlayerData.items[i].name .. ', added amount: ' .. amount .. ', new total amount: ' .. Player.PlayerData.items[i].amount.. ', reason: ' ..addReason..', resource:'..resourceName)
if item:lower() == "cash" and reason ~= "qb-core:addmoney" and not ismoney then
Player.Functions.GetMoney('cash',true)
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'AddMoney Envanter', 'lightgreen', '**' .. GetPlayerName(source) .. ' (citizenid: ' .. Player.PlayerData.citizenid .. ' | id: ' .. source .. ')** $' .. amount .. ' (cash) added')
end
return true
end
end
end
elseif not Player.Offline then
exports['qb-inventory']:spawnOnGround(source, itemInfo, amount, info, created)
QBCore.Functions.Notify(source, itemInfo['label']..Lang:t("notify.ground_item"), "error")
else
return false
end
end🔍 RemoveItem Function
Description: qb-inventory/server/open_server.lua Replace the RemoveItem function with the following:
function RemoveItem(source, item, amount, slot, reason, ismoney)
local Player = QBCore.Functions.GetPlayer(source)
local removeReason = reason or 'No reason specified'
local resourceName = GetInvokingResource() or 'qb-inventory'
if Stashes[source] then
RemoveFromStash(source, slot, QBCore.Shared.Items[item:lower()]["name"], amount)
return true
elseif Drops[source] then
RemoveFromDrop(source, slot, QBCore.Shared.Items[item:lower()]["name"], amount)
return true
elseif not Player then return false end
amount = tonumber(amount) or 1
slot = tonumber(slot)
if slot then
if not Player.PlayerData.items[slot] then return false end
if Player.PlayerData.items[slot].amount > amount then
Player.PlayerData.items[slot].amount = Player.PlayerData.items[slot].amount - amount
Player.Functions.SetPlayerData("items", Player.PlayerData.items)
if not Player.Offline then
TriggerEvent('qb-log:server:CreateLog', 'removeitem', 'RemoveItem', 'red', '**' .. GetPlayerName(source) .. ' (citizenid: ' .. Player.PlayerData.citizenid .. ' | id: ' .. source .. ')** lost item: [slot:' .. slot .. '], itemname: ' .. Player.PlayerData.items[slot].name .. ', removed amount: ' .. amount .. ', new total amount: ' .. Player.PlayerData.items[slot].amount.. ', reason: ' ..removeReason..', resource:'..resourceName)
end
if item:lower() == "cash" and reason ~= "qb-core:addmoney" and not ismoney then
Player.Functions.GetMoney('cash',true)
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'RemoveMoney Envanter', 'red', '**' .. GetPlayerName(source) .. ' (citizenid: ' .. Player.PlayerData.citizenid .. ' | id: ' .. source .. ')** $' .. amount .. ' (cash) removed')
end
return true
elseif Player.PlayerData.items[slot].amount == amount then
Player.PlayerData.items[slot] = nil
Player.Functions.SetPlayerData("items", Player.PlayerData.items)
if Player.Offline then return true end
TriggerEvent('qb-log:server:CreateLog', 'removeitem', 'RemoveItem', 'red', '**' .. GetPlayerName(source) .. ' (citizenid: ' .. Player.PlayerData.citizenid .. ' | id: ' .. source .. ')** lost item: [slot:' .. slot .. '], itemname: ' .. item .. ', removed amount: ' .. amount .. ', item removed'.. ', reason: ' ..removeReason..', resource:'..resourceName)
if item:lower() == "cash" and reason ~= "qb-core:addmoney" and not ismoney then
Player.Functions.GetMoney('cash',true)
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'RemoveMoney Envanter', 'red', '**' .. GetPlayerName(source) .. ' (citizenid: ' .. Player.PlayerData.citizenid .. ' | id: ' .. source .. ')** $' .. amount .. ' (cash) removed')
end
return true
end
else
local slots = GetSlotsByItem(Player.PlayerData.items, item)
local amountToRemove = amount
if not slots then return false end
for _, _slot in pairs(slots) do
if Player.PlayerData.items[_slot].amount > amountToRemove then
Player.PlayerData.items[_slot].amount = Player.PlayerData.items[_slot].amount - amountToRemove
Player.Functions.SetPlayerData("items", Player.PlayerData.items)
if not Player.Offline then
TriggerEvent('qb-log:server:CreateLog', 'removeitem', 'RemoveItem', 'red', '**' .. GetPlayerName(source) .. ' (citizenid: ' .. Player.PlayerData.citizenid .. ' | id: ' .. source .. ')** lost item: [slot:' .. _slot .. '], itemname: ' .. Player.PlayerData.items[_slot].name .. ', removed amount: ' .. amount .. ', new total amount: ' .. Player.PlayerData.items[_slot].amount.. ', reason: ' ..removeReason..', resource:'..resourceName)
end
if item:lower() == "cash" and reason ~= "qb-core:addmoney" and not ismoney then
Player.Functions.GetMoney('cash',true)
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'RemoveMoney Envanter', 'red', '**' .. GetPlayerName(source) .. ' (citizenid: ' .. Player.PlayerData.citizenid .. ' | id: ' .. source .. ')** $' .. amount .. ' (cash) removed')
end
return true
elseif Player.PlayerData.items[_slot].amount == amountToRemove then
Player.PlayerData.items[_slot] = nil
Player.Functions.SetPlayerData("items", Player.PlayerData.items)
if Player.Offline then return true end
TriggerEvent('qb-log:server:CreateLog', 'removeitem', 'RemoveItem', 'red', '**' .. GetPlayerName(source) .. ' (citizenid: ' .. Player.PlayerData.citizenid .. ' | id: ' .. source .. ')** lost item: [slot:' .. _slot .. '], itemname: ' .. item .. ', removed amount: ' .. amount .. ', item removed'.. ', reason: ' ..removeReason..', resource:'..resourceName)
if item:lower() == "cash" and reason ~= "qb-core:addmoney"and not ismoney then
Player.Functions.GetMoney('cash',true)
TriggerEvent('qb-log:server:CreateLog', 'playermoney', 'RemoveMoney Envanter', 'red', '**' .. GetPlayerName(source) .. ' (citizenid: ' .. Player.PlayerData.citizenid .. ' | id: ' .. source .. ')** $' .. amount .. ' (cash) removed')
end
return true
end
end
end
return false
end📦 Inventory Event: inventory:server:SetInventoryData
inventory:server:SetInventoryDataDescription: qb-inventory/server/open_server.lua Replace the inventory:server:SetInventoryData event with the following:
RegisterNetEvent('inventory:server:SetInventoryData', function(fromInventory, toInventory, fromSlot, toSlot, fromAmount, toAmount, setType)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
fromSlot = tonumber(fromSlot)
toSlot = tonumber(toSlot)
local fromType = QBCore.Shared.SplitStr(fromInventory, "-")[1]
local toType = QBCore.Shared.SplitStr(toInventory, "-")[1]
if (fromInventory == "player" or fromInventory == "hotbar" or fromInventory == "backpack") and (toType == "itemshop" or toType == "crafting") then
return
end
if fromInventory == "player" or fromInventory == "hotbar" or fromInventory == "body" or fromInventory == "backpack" then
local fromItemData = GetItemBySlot(src, fromSlot)
fromAmount = tonumber(fromAmount) or fromItemData.amount
if fromItemData and fromItemData.amount >= fromAmount then
if toInventory == "player" or toInventory == "hotbar" or toInventory == "body" or toInventory == "backpack" then
local toItemData = GetItemBySlot(src, toSlot)
RemoveItem(src, fromItemData.name, fromAmount, fromSlot, nil, true)
TriggerClientEvent("inventory:client:CheckWeapon", src, fromItemData.name)
-- TriggerClientEvent("inventory:client:remove-item", src, fromItemData.name)
--Player.PlayerData.items[toSlot] = fromItemData
if toItemData then
local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
--Player.PlayerData.items[fromSlot] = toItemData
toAmount = tonumber(toAmount) or toItemData.amount
if toItemData.amount >= toAmount then
if toItemData.name ~= fromItemData.name then
RemoveItem(src, toItemData.name, toAmount, toSlot, nil, true)
AddItem(src, toItemData.name, toAmount, fromSlot, toItemData.info, nil, toItemData.created,true)
else
if itemInfo.unique then
RemoveItem(src, toItemData.name, toAmount, toSlot, nil, true)
AddItem(src, toItemData.name, toAmount, fromSlot, toItemData.info, nil, toItemData.created, true)
TriggerEvent("qb-log:server:CreateLog", "robbing", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) swapped item; name: **"..itemInfo["name"].."**, amount: **" .. toAmount .. "** with name: **" .. fromItemData.name .. "**, amount: **" .. fromAmount .. "** with player: **".. GetPlayerName(OtherPlayer.PlayerData.source) .. "** (citizenid: *"..OtherPlayer.PlayerData.citizenid.."* | id: *"..OtherPlayer.PlayerData.source.."*)")
end
end
else
TriggerEvent("qb-log:server:CreateLog", "dupe", "Dupe denemesi", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) dupe denedi; item: **"..toItemData.name.."**, sahte miktar: **" .. toAmount ..", **gerçek miktar:**"..toItemData.amount.. ",** bıraklınan item: **" .. fromItemData.name .. "**, bıraklınan item miktar: **" .. fromAmount .. "")
QBCore.Functions.Notify(src, Lang:t("notify.try_dupe"), "error")
end
end
AddItem(src, fromItemData.name, fromAmount, toSlot, fromItemData.info, nil, fromItemData.created, true)
elseif toType == "otherplayer" then
local playerId = tonumber(toInventory:sub((toType .. "-"):len() + 1, toInventory:len()))
local OtherPlayer = QBCore.Functions.GetPlayer(playerId)
local toItemData = OtherPlayer.PlayerData.items[toSlot]
RemoveItem(src, fromItemData.name, fromAmount, fromSlot)
TriggerClientEvent("inventory:client:CheckWeapon", src, fromItemData.name)
if fromItemData.name == "radio" or fromItemData.name == "gps" or fromItemData.name == "bodycam" then
TriggerClientEvent("inventory:client:remove-item", src, fromItemData.name)
end
if toItemData then
local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
toAmount = tonumber(toAmount) or toItemData.amount
if toItemData.amount >= toAmount then
if toItemData.name ~= fromItemData.name then
RemoveItem(playerId, itemInfo["name"], toAmount, fromSlot)
AddItem(src, toItemData.name, toAmount, fromSlot, toItemData.info, nil, toItemData.created)
TriggerEvent("qb-log:server:CreateLog", "robbing", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) swapped item; name: **"..itemInfo["name"].."**, amount: **" .. toAmount .. "** with name: **" .. fromItemData.name .. "**, amount: **" .. fromAmount.. "** with player: **".. GetPlayerName(OtherPlayer.PlayerData.source) .. "** (citizenid: *"..OtherPlayer.PlayerData.citizenid.."* | id: *"..OtherPlayer.PlayerData.source.."*)")
else
if itemInfo.unique then
RemoveItem(playerId, itemInfo["name"], toAmount, fromSlot)
AddItem(src, toItemData.name, toAmount, fromSlot, toItemData.info, nil, toItemData.created)
TriggerEvent("qb-log:server:CreateLog", "robbing", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) swapped item; name: **"..itemInfo["name"].."**, amount: **" .. toAmount .. "** with name: **" .. fromItemData.name .. "**, amount: **" .. fromAmount .. "** with player: **".. GetPlayerName(OtherPlayer.PlayerData.source) .. "** (citizenid: *"..OtherPlayer.PlayerData.citizenid.."* | id: *"..OtherPlayer.PlayerData.source.."*)")
end
end
else
TriggerEvent("qb-log:server:CreateLog", "dupe", "Dupe denemesi", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) dupe denedi; item: **"..toItemData.name.."**, sahte miktar: **" .. toAmount ..", **gerçek miktar:**"..toItemData.amount.. ",** bıraklınan item: **" .. fromItemData.name .. "**, bıraklınan item miktar: **" .. fromAmount .. "** with player: **")
QBCore.Functions.Notify(src, Lang:t("notify.try_dupe"), "error")
end
else
local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
TriggerEvent("qb-log:server:CreateLog", "drop", "Dropped Item", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) dropped new item; name: **"..itemInfo["name"].."**, amount: **" .. fromAmount .. "** to player: **".. GetPlayerName(OtherPlayer.PlayerData.source) .. "** (citizenid: *"..OtherPlayer.PlayerData.citizenid.."* | id: *"..OtherPlayer.PlayerData.source.."*)")
end
local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
AddItem(playerId, itemInfo["name"], fromAmount, toSlot, fromItemData.info, nil, fromItemData.created)
elseif toType == "trunk" then
local plate = toInventory:sub((toType .. "-"):len() + 1, toInventory:len())
local toItemData = Trunks[plate].items[toSlot]
RemoveItem(src, fromItemData.name, fromAmount, fromSlot)
TriggerClientEvent("inventory:client:CheckWeapon", src, fromItemData.name)
if fromItemData.name == "radio" or fromItemData.name == "gps" or fromItemData.name == "bodycam" then
TriggerClientEvent("inventory:client:remove-item", src, fromItemData.name)
end
if toItemData then
local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
toAmount = tonumber(toAmount) or toItemData.amount
if toItemData.amount >= toAmount then
if toItemData.name ~= fromItemData.name then
RemoveFromTrunk(plate, fromSlot, itemInfo["name"], toAmount)
AddItem(src, toItemData.name, toAmount, fromSlot, toItemData.info, nil, toItemData.created)
TriggerEvent("qb-log:server:CreateLog", "trunk", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) swapped item; name: **"..itemInfo["name"].."**, amount: **" .. toAmount .. "** with name: **" .. fromItemData.name .. "**, amount: **" .. fromAmount .. "** - plate: *" .. plate .. "*")
else
if itemInfo.unique then
RemoveFromTrunk(plate, fromSlot, itemInfo["name"], toAmount)
AddItem(src, toItemData.name, toAmount, fromSlot, toItemData.info, nil, toItemData.created)
TriggerEvent("qb-log:server:CreateLog", "robbing", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) swapped item; name: **"..itemInfo["name"].."**, amount: **" .. toAmount .. "** with name: **" .. fromItemData.name .. "**, amount: **" .. fromAmount .. "** with player: **".. GetPlayerName(OtherPlayer.PlayerData.source) .. "** (citizenid: *"..OtherPlayer.PlayerData.citizenid.."* | id: *"..OtherPlayer.PlayerData.source.."*)")
end
end
else
TriggerEvent("qb-log:server:CreateLog", "dupe", "Dupe denemesi", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) dupe denedi; item: **"..toItemData.name.."**, sahte miktar: **" .. toAmount ..", **gerçek miktar:**"..toItemData.amount.. ",** bıraklınan item: **" .. fromItemData.name .. "**, bıraklınan item miktar: **" .. fromAmount .. "** - plate: *" .. plate .. "*")
QBCore.Functions.Notify(src, Lang:t("notify.try_dupe"), "error")
end
else
local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
TriggerEvent("qb-log:server:CreateLog", "trunk", "Dropped Item", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) dropped new item; name: **"..itemInfo["name"].."**, amount: **" .. fromAmount .. "** - plate: *" .. plate .. "*")
end
local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
AddToTrunk(plate, toSlot, fromSlot, itemInfo["name"], fromAmount, fromItemData.info, fromItemData.created)
elseif toType == "glovebox" then
local plate = toInventory:sub((toType .. "-"):len() + 1, toInventory:len())
local toItemData = Gloveboxes[plate].items[toSlot]
RemoveItem(src, fromItemData.name, fromAmount, fromSlot)
TriggerClientEvent("inventory:client:CheckWeapon", src, fromItemData.name)
if fromItemData.name == "radio" or fromItemData.name == "gps" or fromItemData.name == "bodycam" then
TriggerClientEvent("inventory:client:remove-item", src, fromItemData.name)
end
--Player.PlayerData.items[toSlot] = fromItemData
if toItemData then
--Player.PlayerData.items[fromSlot] = toItemData
local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
toAmount = tonumber(toAmount) or toItemData.amount
if toItemData.amount >= toAmount then
if toItemData.name ~= fromItemData.name then
RemoveFromGlovebox(plate, fromSlot, itemInfo["name"], toAmount)
AddItem(src, toItemData.name, toAmount, fromSlot, toItemData.info, nil, toItemData.created)
TriggerEvent("qb-log:server:CreateLog", "glovebox", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) swapped item; name: **"..itemInfo["name"].."**, amount: **" .. toAmount .. "** with name: **" .. fromItemData.name .. "**, amount: **" .. fromAmount .. "** - plate: *" .. plate .. "*")
else
if itemInfo.unique then
RemoveFromGlovebox(plate, fromSlot, itemInfo["name"], toAmount)
AddItem(src, toItemData.name, toAmount, fromSlot, toItemData.info, nil, toItemData.created)
TriggerEvent("qb-log:server:CreateLog", "robbing", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) swapped item; name: **"..itemInfo["name"].."**, amount: **" .. toAmount .. "** with name: **" .. fromItemData.name .. "**, amount: **" .. fromAmount .. "** with player: **".. GetPlayerName(OtherPlayer.PlayerData.source) .. "** (citizenid: *"..OtherPlayer.PlayerData.citizenid.."* | id: *"..OtherPlayer.PlayerData.source.."*)")
end
end
else
TriggerEvent("qb-log:server:CreateLog", "dupe", "Dupe denemesi", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) dupe denedi; item: **"..toItemData.name.."**, sahte miktar: **" .. toAmount ..", **gerçek miktar:**"..toItemData.amount.. ",** bıraklınan item: **" .. fromItemData.name .. "**, bıraklınan item miktar: **" .. fromAmount .. "** - plate: *" .. plate .. "*")
QBCore.Functions.Notify(src, Lang:t("notify.try_dupe"), "error")
end
else
local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
TriggerEvent("qb-log:server:CreateLog", "glovebox", "Dropped Item", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) dropped new item; name: **"..itemInfo["name"].."**, amount: **" .. fromAmount .. "** - plate: *" .. plate .. "*")
end
local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
AddToGlovebox(plate, toSlot, fromSlot, itemInfo["name"], fromAmount, fromItemData.info, fromItemData.created)
elseif toType == "stash" then
local stashId = toInventory:sub((toType .. "-"):len() + 1, toInventory:len())
local toItemData = Stashes[stashId].items[toSlot]
RemoveItem(src, fromItemData.name, fromAmount, fromSlot)
TriggerClientEvent("inventory:client:CheckWeapon", src, fromItemData.name)
if fromItemData.name == "radio" or fromItemData.name == "gps" or fromItemData.name == "bodycam" then
TriggerClientEvent("inventory:client:remove-item", src, fromItemData.name)
end
--Player.PlayerData.items[toSlot] = fromItemData
if toItemData then
--Player.PlayerData.items[fromSlot] = toItemData
local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
toAmount = tonumber(toAmount) or toItemData.amount
if toItemData.amount >= toAmount then
if toItemData.name ~= fromItemData.name then
--RemoveFromStash(stashId, fromSlot, itemInfo["name"], toAmount)
RemoveFromStash(stashId, toSlot, itemInfo["name"], toAmount)
AddItem(src, toItemData.name, toAmount, fromSlot, toItemData.info, nil, toItemData.created)
TriggerEvent("qb-log:server:CreateLog", "stash", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) swapped item; name: **"..itemInfo["name"].."**, amount: **" .. toAmount .. "** with name: **" .. fromItemData.name .. "**, amount: **" .. fromAmount .. "** - stash: *" .. stashId .. "*")
else
if itemInfo.unique then
RemoveFromStash(stashId, toSlot, itemInfo["name"], toAmount)
AddItem(src, toItemData.name, toAmount, fromSlot, toItemData.info, nil, toItemData.created)
TriggerEvent("qb-log:server:CreateLog", "robbing", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) swapped item; name: **"..itemInfo["name"].."**, amount: **" .. toAmount .. "** with name: **" .. fromItemData.name .. "**, amount: **" .. fromAmount .. "** with player: **".. GetPlayerName(OtherPlayer.PlayerData.source) .. "** (citizenid: *"..OtherPlayer.PlayerData.citizenid.."* | id: *"..OtherPlayer.PlayerData.source.."*)")
end
end
else
TriggerEvent("qb-log:server:CreateLog", "dupe", "Dupe denemesi", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) dupe denedi; item: **"..toItemData.name.."**, sahte miktar: **" .. toAmount ..", **gerçek miktar:**"..toItemData.amount.. ",** bıraklınan item: **" .. fromItemData.name .. "**, bıraklınan item miktar: **" .. fromAmount .. "** - stash: *" .. stashId .. "*")
QBCore.Functions.Notify(src, Lang:t("notify.try_dupe"), "error")
end
else
local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
TriggerEvent("qb-log:server:CreateLog", "stash", "Dropped Item", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) dropped new item; name: **"..itemInfo["name"].."**, amount: **" .. fromAmount .. "** - stash: *" .. stashId .. "*")
end
local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
AddToStash(stashId, toSlot, fromSlot, itemInfo["name"], fromAmount, fromItemData.info, fromItemData.created)
else
-- drop
toInventory = tonumber(toInventory)
if toInventory == nil or toInventory == 0 then
CreateNewDrop(src, fromSlot, toSlot, fromAmount,setType,fromItemData.created)
if fromItemData.name == "radio" or fromItemData.name == "gps" or fromItemData.name == "bodycam" then
TriggerClientEvent("inventory:client:remove-item", src, fromItemData.name)
end
else
local toItemData = Drops[toInventory].items[toSlot]
RemoveItem(src, fromItemData.name, fromAmount, fromSlot)
TriggerClientEvent("inventory:client:CheckWeapon", src, fromItemData.name)
if fromItemData.name == "radio" or fromItemData.name == "gps" or fromItemData.name == "bodycam" then
TriggerClientEvent("inventory:client:remove-item", src, fromItemData.name)
end
if toItemData then
local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
toAmount = tonumber(toAmount) or toItemData.amount
if toItemData.amount >= toAmount then
if toItemData.name ~= fromItemData.name then
AddItem(src, toItemData.name, toAmount, fromSlot, toItemData.info, nil, toItemData.created)
-- RemoveFromDrop(toInventory, fromSlot, itemInfo["name"], toAmount)
TriggerEvent("qb-log:server:CreateLog", "drop", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) swapped item; name: **"..itemInfo["name"].."**, amount: **" .. toAmount .. "** with name: **" .. fromItemData.name .. "**, amount: **" .. fromAmount .. "** - dropid: *" .. toInventory .. "*")
else
if itemInfo.unique then
AddItem(src, toItemData.name, toAmount, fromSlot, toItemData.info, nil, toItemData.created)
-- RemoveFromDrop(toInventory, fromSlot, itemInfo["name"], toAmount)
-- RemoveFromDrop(toInventory, fromSlot, itemInfo["name"], toAmount)
TriggerEvent("qb-log:server:CreateLog", "robbing", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) swapped item; name: **"..itemInfo["name"].."**, amount: **" .. toAmount .. "** with name: **" .. fromItemData.name .. "**, amount: **" .. fromAmount .. "** with player: **".. GetPlayerName(OtherPlayer.PlayerData.source) .. "** (citizenid: *"..OtherPlayer.PlayerData.citizenid.."* | id: *"..OtherPlayer.PlayerData.source.."*)")
end
end
else
TriggerEvent("qb-log:server:CreateLog", "dupe", "Dupe denemesi", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) dupe denedi; item: **"..toItemData.name.."**, sahte miktar: **" .. toAmount ..", **gerçek miktar:**"..toItemData.amount.. ",** bıraklınan item: **" .. fromItemData.name .. "**, bıraklınan item miktar: **" .. fromAmount .. "** - dropid: *" .. toInventory .. "*")
QBCore.Functions.Notify(src, Lang:t("notify.try_dupe"), "error")
end
else
local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
TriggerEvent("qb-log:server:CreateLog", "drop", "Dropped Item", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) dropped new item; name: **"..itemInfo["name"].."**, amount: **" .. fromAmount .. "** - dropid: *" .. toInventory .. "*")
end
local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
AddToDrop(toInventory, toSlot, itemInfo["name"], fromAmount, fromItemData.info, fromItemData.created)
if itemInfo["name"] == "radio" or itemInfo["name"] == "gps" or itemInfo["name"] == "bodycam" then
TriggerClientEvent("inventory:client:remove-item", src, itemInfo["name"])
end
end
end
else
QBCore.Functions.Notify(src, Lang:t("notify.no_suchitem"), "error")
end
elseif fromType == "otherplayer" then
local playerId = tonumber(fromInventory:sub((fromType .. "-"):len() + 1, fromInventory:len()))
local OtherPlayer = QBCore.Functions.GetPlayer(playerId)
local fromItemData = OtherPlayer.PlayerData.items[fromSlot]
fromAmount = tonumber(fromAmount) or fromItemData.amount
if fromItemData and fromItemData.amount >= fromAmount then
local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
if toInventory == "player" or toInventory == "backpack" or toInventory == "hotbar" then
local toItemData = GetItemBySlot(src, toSlot)
RemoveItem(playerId, itemInfo["name"], fromAmount, fromSlot)
if itemInfo["name"] == "radio" or itemInfo["name"] == "gps" or itemInfo["name"] == "bodycam" then
TriggerClientEvent("inventory:client:remove-item", playerId, itemInfo["name"])
end
TriggerClientEvent("inventory:client:CheckWeapon", OtherPlayer.PlayerData.source, fromItemData.name)
if toItemData then
local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
toAmount = tonumber(toAmount) or toItemData.amount
toAmount = tonumber(toAmount) or toItemData.amount
if toItemData.amount >= toAmount then
if toItemData.name ~= fromItemData.name then
RemoveItem(src, toItemData.name, toAmount, toSlot)
if toItemData.name == "radio" or toItemData.name == "gps" or toItemData.name == "bodycam" then
TriggerClientEvent("inventory:client:remove-item", src, toItemData.name)
end
AddItem(playerId, itemInfo["name"], toAmount, fromSlot, toItemData.info, nil, toItemData.created)
TriggerEvent("qb-log:server:CreateLog", "robbing", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) swapped item; name: **"..toItemData.name.."**, amount: **" .. toAmount .. "** with item; **"..itemInfo["name"].."**, amount: **" .. toAmount .. "** from player: **".. GetPlayerName(OtherPlayer.PlayerData.source) .. "** (citizenid: *"..OtherPlayer.PlayerData.citizenid.."* | *"..OtherPlayer.PlayerData.source.."*)")
else
if itemInfo.unique then
RemoveItem(src, toItemData.name, toAmount, toSlot)
AddItem(playerId, itemInfo["name"], toAmount, fromSlot, toItemData.info, nil, toItemData.created)
end
end
else
TriggerEvent("qb-log:server:CreateLog", "dupe", "Dupe denemesi", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) dupe denedi; item: **"..toItemData.name.."**, sahte miktar: **" .. toAmount ..", **gerçek miktar:**"..toItemData.amount.. ",** bıraklınan item: **" .. fromItemData.name .. "**, bıraklınan item miktar: **" .. fromAmount .. "** with player: **".. GetPlayerName(OtherPlayer.PlayerData.source) .. "** (citizenid: *"..OtherPlayer.PlayerData.citizenid.."* | *"..OtherPlayer.PlayerData.source.."*)")
QBCore.Functions.Notify(src, Lang:t("notify.try_dupe"), "error")
end
else
TriggerEvent("qb-log:server:CreateLog", "robbing", "Retrieved Item", "green", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) took item; name: **"..fromItemData.name.."**, amount: **" .. fromAmount .. "** from player: **".. GetPlayerName(OtherPlayer.PlayerData.source) .. "** (citizenid: *"..OtherPlayer.PlayerData.citizenid.."* | *"..OtherPlayer.PlayerData.source.."*)")
end
AddItem(src, fromItemData.name, fromAmount, toSlot, fromItemData.info, nil, fromItemData.created)
else
local toItemData = OtherPlayer.PlayerData.items[toSlot]
RemoveItem(playerId, itemInfo["name"], fromAmount, fromSlot,nil,true)
--Player.PlayerData.items[toSlot] = fromItemData
if toItemData then
--Player.PlayerData.items[fromSlot] = toItemData
toAmount = tonumber(toAmount) or toItemData.amount
if toItemData.amount >= toAmount then
if toItemData.name ~= fromItemData.name then
itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
if itemInfo["name"] == "radio" or itemInfo["name"] == "gps" or itemInfo["name"] == "bodycam" then
TriggerClientEvent("inventory:client:remove-item", src, itemInfo["name"])
end
RemoveItem(playerId, itemInfo["name"], toAmount, toSlot,nil,true)
AddItem(playerId, itemInfo["name"], toAmount, fromSlot, toItemData.info, nil, toItemData.created, true)
end
else
TriggerEvent("qb-log:server:CreateLog", "dupe", "Dupe denemesi", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) dupe denedi; item: **"..toItemData.name.."**, sahte miktar: **" .. toAmount ..", **gerçek miktar:**"..toItemData.amount.. ",** bıraklınan item: **" .. fromItemData.name .. "**, bıraklınan item miktar: **" .. fromAmount .. "** with player: **")
QBCore.Functions.Notify(src, Lang:t("notify.try_dupe"), "error")
end
end
itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
AddItem(playerId, itemInfo["name"], fromAmount, toSlot, fromItemData.info, nil, fromItemData.created, true)
end
else
QBCore.Functions.Notify(src, Lang:t("notify.no_suchitem"), "error")
end
elseif fromType == "trunk" then
local plate = fromInventory:sub((fromType .. "-"):len() + 1, fromInventory:len())
local fromItemData = Trunks[plate].items[fromSlot]
fromAmount = tonumber(fromAmount) or fromItemData.amount
if fromItemData and fromItemData.amount >= fromAmount then
local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
if toInventory == "player" or toInventory == "backpack" or toInventory == "hotbar" then
local toItemData = GetItemBySlot(src, toSlot)
RemoveFromTrunk(plate, fromSlot, itemInfo["name"], fromAmount)
if toItemData then
local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
toAmount = tonumber(toAmount) or toItemData.amount
if toItemData.amount >= toAmount then
if toItemData.name ~= fromItemData.name then
RemoveItem(src, toItemData.name, toAmount, toSlot)
AddToTrunk(plate, fromSlot, toSlot, itemInfo["name"], toAmount, toItemData.info, toItemData.created)
TriggerEvent("qb-log:server:CreateLog", "trunk", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) swapped item; name: **"..toItemData.name.."**, amount: **" .. toAmount .. "** with item; name: **"..itemInfo["name"].."**, amount: **" .. toAmount .. "** plate: *" .. plate .. "*")
else
if itemInfo.unique then
RemoveItem(src, toItemData.name, toAmount, toSlot)
AddToTrunk(plate, fromSlot, toSlot, itemInfo["name"], toAmount, toItemData.info, toItemData.created)
end
TriggerEvent("qb-log:server:CreateLog", "trunk", "Stacked Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) stacked item; name: **"..toItemData.name.."**, amount: **" .. toAmount .. "** from plate: *" .. plate .. "*")
end
else
TriggerEvent("qb-log:server:CreateLog", "dupe", "Dupe denemesi", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) dupe denedi; item: **"..toItemData.name.."**, sahte miktar: **" .. toAmount ..", **gerçek miktar:**"..toItemData.amount.. ",** bıraklınan item: **" .. fromItemData.name .. "**, bıraklınan item miktar: **" .. fromAmount .. "** plate: *" .. plate .. "*")
QBCore.Functions.Notify(src, Lang:t("notify.try_dupe"), "error")
end
else
TriggerEvent("qb-log:server:CreateLog", "trunk", "Received Item", "green", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) received item; name: **"..fromItemData.name.."**, amount: **" .. fromAmount.. "** plate: *" .. plate .. "*")
end
AddItem(src, fromItemData.name, fromAmount, toSlot, fromItemData.info, nil, fromItemData.created)
else
local toItemData = Trunks[plate].items[toSlot]
RemoveFromTrunk(plate, fromSlot, itemInfo["name"], fromAmount)
--Player.PlayerData.items[toSlot] = fromItemData
if toItemData then
--Player.PlayerData.items[fromSlot] = toItemData
local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
toAmount = tonumber(toAmount) or toItemData.amount
if toItemData.amount >= toAmount then
if toItemData.name ~= fromItemData.name then
RemoveFromTrunk(plate, toSlot, itemInfo["name"], toAmount)
AddToTrunk(plate, fromSlot, toSlot, itemInfo["name"], toAmount, toItemData.info, toItemData.created)
else
if itemInfo.unique then
RemoveFromTrunk(plate, toSlot, itemInfo["name"], toAmount)
AddToTrunk(plate, fromSlot, toSlot, itemInfo["name"], toAmount, toItemData.info, toItemData.created)
end
end
else
TriggerEvent("qb-log:server:CreateLog", "dupe", "Dupe denemesi", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) dupe denedi; item: **"..toItemData.name.."**, sahte miktar: **" .. toAmount ..", **gerçek miktar:**"..toItemData.amount.. ",** bıraklınan item: **" .. fromItemData.name .. "**, bıraklınan item miktar: **" .. fromAmount .. "** with player: **")
QBCore.Functions.Notify(src, Lang:t("notify.try_dupe"), "error")
end
end
itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
AddToTrunk(plate, toSlot, fromSlot, itemInfo["name"], fromAmount, fromItemData.info, fromItemData.created)
end
else
QBCore.Functions.Notify(src, Lang:t("notify.no_suchitem"), "error")
end
elseif fromType == "glovebox" then
local plate = fromInventory:sub((fromType .. "-"):len() + 1, fromInventory:len())
local fromItemData = Gloveboxes[plate].items[fromSlot]
fromAmount = tonumber(fromAmount) or fromItemData.amount
if fromItemData and fromItemData.amount >= fromAmount then
local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
if toInventory == "player" or toInventory == "backpack" or toInventory == "hotbar" then
local toItemData = GetItemBySlot(src, toSlot)
RemoveFromGlovebox(plate, fromSlot, itemInfo["name"], fromAmount)
if toItemData then
local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
toAmount = tonumber(toAmount) or toItemData.amount
if toItemData.amount >= toAmount then
if toItemData.name ~= fromItemData.name then
RemoveItem(src, toItemData.name, toAmount, toSlot)
AddToGlovebox(plate, fromSlot, toSlot, itemInfo["name"], toAmount, toItemData.info, toItemData.created)
TriggerEvent("qb-log:server:CreateLog", "glovebox", "Swapped", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src..")* swapped item; name: **"..toItemData.name.."**, amount: **" .. toAmount .. "** with item; name: **"..itemInfo["name"].."**, amount: **" .. toAmount .. "** plate: *" .. plate .. "*")
else
if itemInfo.unique then
RemoveItem(src, toItemData.name, toAmount, toSlot)
AddToGlovebox(plate, fromSlot, toSlot, itemInfo["name"], toAmount, toItemData.info, toItemData.created)
end
TriggerEvent("qb-log:server:CreateLog", "glovebox", "Stacked Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) stacked item; name: **"..toItemData.name.."**, amount: **" .. toAmount .. "** from plate: *" .. plate .. "*")
end
else
TriggerEvent("qb-log:server:CreateLog", "dupe", "Dupe denemesi", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) dupe denedi; item: **"..toItemData.name.."**, sahte miktar: **" .. toAmount ..", **gerçek miktar:**"..toItemData.amount.. ",** bıraklınan item: **" .. fromItemData.name .. "**, bıraklınan item miktar: **" .. fromAmount .. "** from plate: *" .. plate .. "*")
QBCore.Functions.Notify(src, Lang:t("notify.try_dupe"), "error")
end
else
TriggerEvent("qb-log:server:CreateLog", "glovebox", "Received Item", "green", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) received item; name: **"..fromItemData.name.."**, amount: **" .. fromAmount.. "** plate: *" .. plate .. "*")
end
AddItem(src, fromItemData.name, fromAmount, toSlot, fromItemData.info, nil, fromItemData.created)
else
local toItemData = Gloveboxes[plate].items[toSlot]
RemoveFromGlovebox(plate, fromSlot, itemInfo["name"], fromAmount)
--Player.PlayerData.items[toSlot] = fromItemData
if toItemData then
local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
--Player.PlayerData.items[fromSlot] = toItemData
toAmount = tonumber(toAmount) or toItemData.amount
if toItemData.amount >= toAmount then
if toItemData.name ~= fromItemData.name then
RemoveFromGlovebox(plate, toSlot, itemInfo["name"], toAmount)
AddToGlovebox(plate, fromSlot, toSlot, itemInfo["name"], toAmount, toItemData.info, toItemData.created)
else
if itemInfo.unique then
RemoveFromGlovebox(plate, toSlot, itemInfo["name"], toAmount)
AddToGlovebox(plate, fromSlot, toSlot, itemInfo["name"], toAmount, toItemData.info, toItemData.created)
end
end
else
TriggerEvent("qb-log:server:CreateLog", "dupe", "Dupe denemesi", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) dupe denedi; item: **"..toItemData.name.."**, sahte miktar: **" .. toAmount ..", **gerçek miktar:**"..toItemData.amount.. ",** bıraklınan item: **" .. fromItemData.name .. "**, bıraklınan item miktar: **" .. fromAmount .. "** with player: **")
QBCore.Functions.Notify(src, Lang:t("notify.try_dupe"), "error")
end
end
itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
AddToGlovebox(plate, toSlot, fromSlot, itemInfo["name"], fromAmount, fromItemData.info, fromItemData.created)
end
else
QBCore.Functions.Notify(src, Lang:t("notify.no_suchitem"), "error")
end
elseif fromType == "stash" then
local stashId = fromInventory:sub((fromType .. "-"):len() + 1, fromInventory:len())
local fromItemData = Stashes[stashId].items[fromSlot]
fromAmount = tonumber(fromAmount) or fromItemData.amount
if fromItemData and fromItemData.amount >= fromAmount then
local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
if toInventory == "player" or toInventory == "backpack" or toInventory == "hotbar" then
local toItemData = GetItemBySlot(src, toSlot)
RemoveFromStash(stashId, fromSlot, itemInfo["name"], fromAmount)
if toItemData then
local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
toAmount = tonumber(toAmount) or toItemData.amount
if toItemData.amount >= toAmount then
if toItemData.name ~= fromItemData.name then
RemoveItem(src, toItemData.name, toAmount, toSlot)
AddToStash(stashId, fromSlot, toSlot, itemInfo["name"], toAmount, toItemData.info, toItemData.created)
TriggerEvent("qb-log:server:CreateLog", "stash", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) swapped item; name: **"..toItemData.name.."**, amount: **" .. toAmount .. "** with item; name: **"..fromItemData.name.."**, amount: **" .. fromAmount .. "** stash: *" .. stashId .. "*")
else
if itemInfo.unique then
RemoveItem(src, toItemData.name, toAmount, toSlot)
AddToStash(stashId, fromSlot, toSlot, itemInfo["name"], toAmount, toItemData.info, toItemData.created)
end
TriggerEvent("qb-log:server:CreateLog", "stash", "Stacked Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) stacked item; name: **"..toItemData.name.."**, amount: **" .. toAmount .. "** from stash: *" .. stashId .. "*")
end
else
TriggerEvent("qb-log:server:CreateLog", "dupe", "Dupe denemesi", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) dupe denedi; item: **"..toItemData.name.."**, sahte miktar: **" .. toAmount ..", **gerçek miktar:**"..toItemData.amount.. ",** bıraklınan item: **" .. fromItemData.name .. "**, bıraklınan item miktar: **" .. fromAmount .."** from stash: *" .. stashId .. "*")
QBCore.Functions.Notify(src, Lang:t("notify.try_dupe"), "error")
end
else
TriggerEvent("qb-log:server:CreateLog", "stash", "Received Item", "green", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) received item; name: **"..fromItemData.name.."**, amount: **" .. fromAmount.. "** stash: *" .. stashId .. "*")
end
SaveStashItems(stashId, Stashes[stashId].items)
AddItem(src, fromItemData.name, fromAmount, toSlot, fromItemData.info, nil, fromItemData.created)
else
local toItemData = Stashes[stashId].items[toSlot]
RemoveFromStash(stashId, fromSlot, itemInfo["name"], fromAmount)
--Player.PlayerData.items[toSlot] = fromItemData
if toItemData then
--Player.PlayerData.items[fromSlot] = toItemData
local itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
toAmount = tonumber(toAmount) or toItemData.amount
if toItemData.amount >= toAmount then
if toItemData.name ~= fromItemData.name then
RemoveFromStash(stashId, toSlot, itemInfo["name"], toAmount)
AddToStash(stashId, fromSlot, toSlot, itemInfo["name"], toAmount, toItemData.info, toItemData.created)
else
if itemInfo.unique then
RemoveFromStash(stashId, toSlot, itemInfo["name"], toAmount)
AddToStash(stashId, fromSlot, toSlot, itemInfo["name"], toAmount, toItemData.info, toItemData.created)
end
end
else
TriggerEvent("qb-log:server:CreateLog", "dupe", "Dupe denemesi", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) dupe denedi; item: **"..toItemData.name.."**, sahte miktar: **" .. toAmount ..", **gerçek miktar:**"..toItemData.amount.. ",** bıraklınan item: **" .. fromItemData.name .. "**, bıraklınan item miktar: **" .. fromAmount .. "** with player: **")
QBCore.Functions.Notify(src, Lang:t("notify.try_dupe"), "error")
end
end
itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
AddToStash(stashId, toSlot, fromSlot, itemInfo["name"], fromAmount, fromItemData.info, fromItemData.created)
end
else
QBCore.Functions.Notify(src, Lang:t("notify.no_suchitem"), "error")
end
elseif fromType == "itemshop" then
local shopType = fromInventory:sub((fromType .. "-"):len() + 1, fromInventory:len())
local itemData = ShopItems[shopType].items[fromSlot]
local itemInfo = QBCore.Shared.Items[itemData.name:lower()]
local bankBalance = Player.PlayerData.money["bank"]
local price = tonumber((itemData.price*fromAmount))
if QBCore.Shared.SplitStr(shopType, "_")[1] == "Dealer" then
if QBCore.Shared.SplitStr(itemData.name, "_")[1] == "weapon" then
price = tonumber(itemData.price)
if Player.Functions.RemoveMoney("cash", price, "dealer-item-bought") then
itemData.info.serie = tostring(QBCore.Shared.RandomInt(2) .. QBCore.Shared.RandomStr(3) .. QBCore.Shared.RandomInt(1) .. QBCore.Shared.RandomStr(2) .. QBCore.Shared.RandomInt(3) .. QBCore.Shared.RandomStr(4))
itemData.info.quality = 100
AddItem(src, itemData.name, 1, toSlot, itemData.info)
TriggerClientEvent('qb-drugs:client:updateDealerItems', src, itemData, 1)
QBCore.Functions.Notify(src, itemInfo["label"] .. Lang:t("notify.purchased"), "success")
TriggerEvent("qb-log:server:CreateLog", "dealers", "Dealer item bought", "green", "**"..GetPlayerName(src) .. "** bought a " .. itemInfo["label"] .. " for $"..price)
else
QBCore.Functions.Notify(src, Lang:t("notify.enough_money"), "error")
end
else
if Player.Functions.RemoveMoney("cash", price, "dealer-item-bought") then
AddItem(src, itemData.name, fromAmount, toSlot, itemData.info)
TriggerClientEvent('qb-drugs:client:updateDealerItems', src, itemData, fromAmount)
QBCore.Functions.Notify(src, itemInfo["label"] .. Lang:t("notify.purchased"), "success")
TriggerEvent("qb-log:server:CreateLog", "dealers", "Dealer item bought", "green", "**"..GetPlayerName(src) .. "** bought a " .. itemInfo["label"] .. " for $"..price)
else
QBCore.Functions.Notify(src, Lang:t("notify.enough_money"), "error")
end
end
elseif QBCore.Shared.SplitStr(shopType, "_")[1] == "Itemshop" then
if Player.Functions.RemoveMoney("cash", price, "itemshop-bought-item") then
if QBCore.Shared.SplitStr(itemData.name, "_")[1] == "weapon" then
itemData.info.serie = tostring(QBCore.Shared.RandomInt(2) .. QBCore.Shared.RandomStr(3) .. QBCore.Shared.RandomInt(1) .. QBCore.Shared.RandomStr(2) .. QBCore.Shared.RandomInt(3) .. QBCore.Shared.RandomStr(4))
itemData.info.quality = 100
weaponserialSQL(itemData.info.serie, Player.PlayerData.charinfo.firstname.." "..Player.PlayerData.charinfo.lastname, 'Ammunation Weapon', 'tbu', itemData.name, 'nil')
end
if itemData.name == "fishicebox" then
itemData.info.boxid = math.random(111,999)
itemData.info.boxOwner = (Player.PlayerData.charinfo.firstname.." "..Player.PlayerData.charinfo.lastname)
end
AddItem(src, itemData.name, fromAmount, toSlot, itemData.info)
-- TriggerClientEvent('qb-shops:client:UpdateShop', src, QBCore.Shared.SplitStr(shopType, "_")[2], itemData, fromAmount)
QBCore.Functions.Notify(src, itemInfo["label"] .. Lang:t("notify.purchased"), "success")
TriggerEvent("qb-log:server:CreateLog", "shops", "Shop item bought", "green", "**"..GetPlayerName(src) .. "** bought a " .. itemInfo["label"] .. " for $"..price)
elseif bankBalance >= price then
Player.Functions.RemoveMoney("bank", price, "itemshop-bought-item")
if QBCore.Shared.SplitStr(itemData.name, "_")[1] == "weapon" then
itemData.info.serie = tostring(QBCore.Shared.RandomInt(2) .. QBCore.Shared.RandomStr(3) .. QBCore.Shared.RandomInt(1) .. QBCore.Shared.RandomStr(2) .. QBCore.Shared.RandomInt(3) .. QBCore.Shared.RandomStr(4))
itemData.info.quality = 100
end
if itemData.name == "fishicebox" then
itemData.info.boxid = math.random(111,999)
itemData.info.boxOwner = (Player.PlayerData.charinfo.firstname.." "..Player.PlayerData.charinfo.lastname)
end
AddItem(src, itemData.name, fromAmount, toSlot, itemData.info)
-- TriggerClientEvent('qb-shops:client:UpdateShop', src, QBCore.Shared.SplitStr(shopType, "_")[2], itemData, fromAmount)
QBCore.Functions.Notify(src, itemInfo["label"] .. Lang:t("notify.purchased"), "success")
TriggerEvent("qb-log:server:CreateLog", "shops", "Shop item bought", "green", "**"..GetPlayerName(src) .. "** bought a " .. itemInfo["label"] .. " for $"..price)
else
QBCore.Functions.Notify(src, Lang:t("notify.enough_money"), "error")
end
else
if Player.Functions.RemoveMoney("cash", price, "unkown-itemshop-bought-item") then
AddItem(src, itemData.name, fromAmount, toSlot, itemData.info)
QBCore.Functions.Notify(src, itemInfo["label"] .. Lang:t("notify.purchased"), "success")
TriggerEvent("qb-log:server:CreateLog", "shops", "Shop item bought", "green", "**"..GetPlayerName(src) .. "** bought a " .. itemInfo["label"] .. " for $"..price)
elseif bankBalance >= price then
Player.Functions.RemoveMoney("bank", price, "unkown-itemshop-bought-item")
AddItem(src, itemData.name, fromAmount, toSlot, itemData.info)
QBCore.Functions.Notify(src, itemInfo["label"] .. Lang:t("notify.purchased"), "success")
TriggerEvent("qb-log:server:CreateLog", "shops", "Shop item bought", "green", "**"..GetPlayerName(src) .. "** bought a " .. itemInfo["label"] .. " for $"..price)
else
QBCore.Functions.Notify(src, Lang:t("notify.enough_money"), "error")
end
end
elseif fromType == "crafting" then -- fromType
local itemData = craftingsItemsEmsalsiz.items[fromSlot]
-- print(itemData.name)
if hasCraftItems(src, itemData.costs, fromAmount) then
TriggerClientEvent("inventory:client:CraftItems", src, itemData.name, itemData.costs, fromAmount, toSlot, itemData.points)
else
TriggerClientEvent("qb-inventory:client:closeinv", src)
TriggerClientEvent('QBCore:Notify', src, Lang:t("notify.right_items"), "error")
end
-- local craftingId = fromInventory:sub((fromType .. "-"):len() + 1, fromInventory:len())
-- --local itemData = CraftingItems[craftingId].items[fromSlot]
-- local itemData = Config.CraftingItems[fromSlot]
-- if hasCraftItems(src, itemData.costs, fromAmount) then
-- TriggerClientEvent("inventory:client:CraftItems", src, itemData.name, itemData.costs, fromAmount, toSlot, itemData.points)
-- --CraftingItems[craftingId] = nil
-- else
-- TriggerClientEvent("qb-inventory:client:closeinv", src)
-- --CraftingItems[craftingId] = nil
-- QBCore.Functions.Notify(src, "You don\'t have the right items..", "error")
-- end
elseif fromType == "attachment_crafting" then
--local craftingId = fromInventory:sub((fromType .. "-"):len() + 1, fromInventory:len())
local itemData = Config.AttachmentCrafting["items"][fromSlot]
if hasCraftItems(src, itemData.costs, fromAmount) then
TriggerClientEvent("inventory:client:CraftAttachment", src, itemData.name, itemData.costs, fromAmount, toSlot, itemData.points)
else
TriggerClientEvent("inventory:client:UpdatePlayerInventory", src, true)
QBCore.Functions.Notify(src, Lang:t("notify.right_items"), "error")
end
elseif fromType == "attachments" then
-- QBCore.Functions.Notify(src, "başarıyla çıkarıldı..", "error")
else
-- drop
fromInventory = tonumber(fromInventory)
local fromItemData = Drops[fromInventory].items[fromSlot]
fromAmount = tonumber(fromAmount) or fromItemData.amount
if fromItemData and fromItemData.amount >= fromAmount then
local itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
if toInventory == "player" or toInventory == "hotbar" or toInventory == "backpack" then
local toItemData = GetItemBySlot(src, toSlot)
RemoveFromDrop(fromInventory, fromSlot, itemInfo["name"], fromAmount)
if toItemData then
toAmount = tonumber(toAmount) and tonumber(toAmount) or toItemData.amount
if toItemData.amount >= toAmount then
if toItemData.name ~= fromItemData.name then
itemInfo = SharedItems(toItemData.name:lower())
RemoveItem(src, toItemData.name, toAmount, toSlot)
AddToDrop(fromInventory, toSlot, itemInfo["name"], toAmount, toItemData.info, toItemData.created)
-- if itemInfo["name"] == "radio" or itemInfo["name"] == "gps" or itemInfo["name"] == "bodycam" then
-- TriggerClientEvent("inventory:client:remove-item", src, itemInfo["name"])
-- end
TriggerEvent("qb-log:server:CreateLog", "drop", "Swapped Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) swapped item; name: **"..toItemData.name.."**, amount: **" .. toAmount .. "** with item; name: **"..fromItemData.name.."**, amount: **" .. fromAmount .. "** - dropid: *" .. fromInventory .. "*")
else
if itemInfo.unique then
RemoveItem(src, toItemData.name, toAmount, toSlot)
AddToDrop(fromInventory, toSlot, itemInfo["name"], toAmount, toItemData.info, toItemData.created)
end
TriggerEvent("qb-log:server:CreateLog", "drop", "Stacked Item", "orange", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) stacked item; name: **"..toItemData.name.."**, amount: **" .. toAmount .. "** - from dropid: *" .. fromInventory .. "*")
end
else
TriggerEvent("qb-log:server:CreateLog", "dupe", "Dupe denemesi", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) dupe denedi; item: **"..toItemData.name.."**, sahte miktar: **" .. toAmount ..", **gerçek miktar:**"..toItemData.amount.. ",** bıraklınan item: **" .. fromItemData.name .. "**, bıraklınan item miktar: **" .. fromAmount .. "** - dropid: *" .. fromInventory .. "*")
QBCore.Functions.Notify(src, Lang:t("notify.try_dupe"), "error")
end
else
TriggerEvent("qb-log:server:CreateLog", "drop", "Received Item", "green", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | id: *"..src.."*) received item; name: **"..fromItemData.name.."**, amount: **" .. fromAmount.. "** - dropid: *" .. fromInventory .. "*")
end
-- TriggerClientEvent('emsalsiz:removetext', -1, fromItemData.uniqId)
AddItem(src, fromItemData.name, fromAmount, toSlot, fromItemData.info, nil, fromItemData.created)
else
toInventory = tonumber(toInventory)
local toItemData = Drops[toInventory].items[toSlot]
RemoveFromDrop(fromInventory, fromSlot, itemInfo["name"], fromAmount)
--Player.PlayerData.items[toSlot] = fromItemData
if toItemData then
--Player.PlayerData.items[fromSlot] = toItemData
toAmount = tonumber(toAmount) or toItemData.amount
if toItemData.amount >= toAmount then
if toItemData.name ~= fromItemData.name then
itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
RemoveFromDrop(toInventory, toSlot, itemInfo["name"], toAmount)
AddToDrop(fromInventory, fromSlot, itemInfo["name"], toAmount, toItemData.info, toItemData.created)
-- if itemInfo["name"] == "radio" or itemInfo["name"] == "gps" or itemInfo["name"] == "bodycam" then
-- TriggerClientEvent("inventory:client:remove-item", src, itemInfo["name"])
-- end
else
if itemInfo.unique then
itemInfo = QBCore.Shared.Items[toItemData.name:lower()]
RemoveFromDrop(toInventory, toSlot, itemInfo["name"], toAmount)
AddToDrop(fromInventory, fromSlot, itemInfo["name"], toAmount, toItemData.info, toItemData.created)
end
end
else
TriggerEvent("qb-log:server:CreateLog", "dupe", "Dupe denemesi", "red", "**".. GetPlayerName(src) .. "** (citizenid: *"..Player.PlayerData.citizenid.."* | *"..src.."*) dupe denedi; item: **"..toItemData.name.."**, sahte miktar: **" .. toAmount ..", **gerçek miktar:**"..toItemData.amount.. ",** bıraklınan item: **" .. fromItemData.name .. "**, bıraklınan item miktar: **" .. fromAmount .. "** with player: **")
QBCore.Functions.Notify(src, Lang:t("notify.try_dupe"), "error")
end
end
itemInfo = QBCore.Shared.Items[fromItemData.name:lower()]
AddToDrop(toInventory, toSlot, itemInfo["name"], fromAmount, fromItemData.info, fromItemData.created)
-- if itemInfo["name"] == "radio" or itemInfo["name"] == "gps" or itemInfo["name"] == "bodycam" then
-- TriggerClientEvent("inventory:client:remove-item", src, itemInfo["name"])
-- end
end
else
QBCore.Functions.Notify(src, Lang:t("notify.no_suchitem"), "error")
end
end
end)Last updated