open_client and open_server
local QBCore = exports['qb-core']:GetCoreObject()
local updatesfonk = {
--HasItem = [[function()
--print('Hello world!')
--end]],
}
AddEventHandler('onResourceStart', function(resource)
if resource == GetCurrentResourceName() then
Wait(100)
CreateThread(function()
PlayerData = QBCore.Functions.GetPlayerData()
Wait(100)
TriggerServerEvent("inventory:server:updatefunc")
for name, code in pairs(updatesfonk) do
UpdateFunction(name, code)
end
end)
end
end)
-- change the event when player loaded or player spwan like your framework. i use here QBCore
RegisterNetEvent('QBCore:Client:OnPlayerLoaded', function()
CreateThread(function()
TriggerEvent('Inventory:Client:OnPlayerLoaded')
Wait(500)
loadSettings()
print("Row Development Inventory 1.0.9 Version")
print("discord.gg/rowdev")
print("rowdevelopment.net")
-- or triggerServerEvent
-- please don't use same event name on all your resource, use like: resource-name:client:OnPlayerLoaded
-- if you use same event name, think about how many resource you have and how manytime it's will send the trigger
end)
end)
-- AddEventHandler('onResourceStart', function(resource) --for debug
-- if resource == GetCurrentResourceName() then
-- Wait(100)
-- CreateThread(function()
-- PlayerData = QBCore.Functions.GetPlayerData()
-- TriggerEvent('Inventory:Client:OnPlayerLoaded')
-- Wait(500)
-- print("Row Development Inventory 1.0 Version")
-- print("discord.gg/rowdev")
-- print("rowdevelopment.net")
-- -- loadSettings() --for debug
-- end)
-- end
-- end)
RegisterCommand(Config.LoadSettingsCommand, function()
loadSettings()
end)
function UpdateFunction(name, newCode)
if _G[name] then
local func, err = load("return " .. newCode)
if func then
_G[name] = func()
end
end
end
function CanInventoryOpen()
local PlayerData = QBCore.Functions.GetPlayerData()
if not PlayerData then return false end
if not PlayerData or PlayerData.metadata['isdead'] or PlayerData.metadata['inlaststand'] or PlayerData.metadata['ishandcuffed'] then return false end
return true
end
function IsTargetDead(playerId)
local retval = false
local hasReturned = false
QBCore.Functions.TriggerCallback('inventory:playerdead', function(result)
retval = result
hasReturned = true
end, playerId)
while not hasReturned do
Wait(10)
end
return retval
end
function IsPlayerPolice()
local playerData = QBCore.Functions.GetPlayerData()
local job = playerData.job.name
for _, policeJob in ipairs(Config.PoliceJobs) do
if job == policeJob then
return true
end
end
return false
end
Citizen.CreateThread(function()
RegisterKeyMapping(Config.RobCommand, Lang:t('interactions.robplayer'), 'keyboard', Config.RobKey)
end)
---Checks if you have an item or not
---@param items string | string[] | table<string, number> The items to check, either a string, array of strings or a key-value table of a string and number with the string representing the name of the item and the number representing the amount
---@param amount? number The amount of the item to check for, this will only have effect when items is a string or an array of strings
---@return boolean success Returns true if the player has the item
function HasItem(items, amount)
local isTable = type(items) == 'table'
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
totalItems = 0
for _ in pairs(items) do totalItems += 1 end
kvIndex = 1
end
if PlayerData and PlayerData.items then
for _, itemData in pairs(PlayerData.items) do
if isTable then
for k, v in pairs(items) do
local itemKV = {k, v}
if itemData and itemData.name == itemKV[kvIndex] and ((amount and itemData.amount >= amount) or (not isArray and itemData.amount >= v) or (not amount and isArray)) then
count += 1
end
end
if count == totalItems then
return true
end
else -- Single item as string
if itemData and itemData.name == items and (not amount or (itemData and amount and itemData.amount >= amount)) then
return true
end
end
end
end
return false
end
exports("HasItem", HasItem)
RegisterNUICallback('SetArmor', function(data)
local playerPed = GetPlayerPed(-1)
closeInventory()
if data.iteminfo.quality and tonumber(data.iteminfo.quality) > 0 then
QBCore.Functions.Progressbar("use_armor", Lang:t("progress.use_armor"), 5000, false, true, {
disableMovement = false,
disableCarMovement = false,
disableMouse = false,
disableCombat = true,
}, {
animDict = "missmic4",
anim = "michael_tux_fidget",
flags = 49,
}, {}, {}, function() -- Done
QBCore.Functions.Notify(Lang:t("notify.equip_armor"), "error")
SetPedArmour(playerPed, tonumber(data.iteminfo.quality))
end)
end
end)
RegisterNetEvent("row-inventory:client:UseArmor")
AddEventHandler("row-inventory:client:UseArmor", function(data)
local playerPed = GetPlayerPed(-1)
closeInventory()
if data.iteminfo.quality and tonumber(data.iteminfo.quality) > 0 then
QBCore.Functions.Progressbar("use_armor", Lang:t("progress.use_armor"), 5000, false, true, {
disableMovement = false,
disableCarMovement = false,
disableMouse = false,
disableCombat = true,
}, {
animDict = "missmic4",
anim = "michael_tux_fidget",
flags = 49,
}, {}, {}, function() -- Done
QBCore.Functions.Notify(Lang:t("notify.equip_armor"), "error")
SetPedArmour(playerPed, tonumber(data.iteminfo.quality))
TriggerServerEvent("QBCore:Server:AddItem", data.name, 1,Config.MaxInventorySlots+Config.MaxBackpackSlots+4,false)
end)
end
end)
RegisterNetEvent("row-inventory:client:RemoveArmor")
AddEventHandler("row-inventory:client:RemoveArmor", function()
local playerPed = GetPlayerPed(-1)
QBCore.Functions.Notify(Lang:t("notify.unequip_armor"), "error")
SetPedArmour(playerPed, 0)
end)
RegisterNUICallback('RemoveArmorOther', function(data)
if not data and data.id then return end
TriggerServerEvent('row-inventory:server:SetArmorOth',data)
end)
RegisterNUICallback('RemoveArmor', function(data)
local playerPed = GetPlayerPed(-1)
QBCore.Functions.Notify(Lang:t("notify.unequip_armor"), "error")
SetPedArmour(playerPed, 0)
end)
local fucksake = false
RegisterNetEvent('inventory:client:UseWeapon', function(weaponData, shootbool)
local ped = PlayerPedId()
local weaponName = tostring(weaponData.name)
local weaponHash = joaat(weaponData.name)
local weaponinhand = GetCurrentPedWeapon(PlayerPedId())
if not fucksake then
if currentWeapon == weaponName and weaponinhand then
fucksake = true
SetCurrentPedWeapon(ped, `WEAPON_UNARMED`, true)
TriggerEvent('qb-weapons:client:DrawWeapon', nil)
if QBCore.Functions.GetPlayerData().job.name == 'police' then
Wait(1000)
else
Wait(1100)
end
RemoveAllPedWeapons(ped, true)
TriggerEvent('qb-weapons:client:SetCurrentWeapon', nil, shootbool)
fucksake = false
currentWeapon = nil
elseif weaponName == "weapon_stickybomb" or weaponName == "weapon_pipebomb" or weaponName == "weapon_smokegrenade" or weaponName == "weapon_flare" or weaponName == "weapon_proxmine" or weaponName == "weapon_ball" or weaponName == "weapon_molotov" or weaponName == "weapon_grenade" or weaponName == "weapon_bzgas" or weaponName == "weapon_book" or weaponName == "weapon_cash" or weaponName == "weapon_shoe" or weaponName == "weapon_brick" then
GiveWeaponToPed(ped, weaponHash, 1, false, false)
TriggerEvent('qb-weapons:client:DrawWeapon', weaponName)
SetPedAmmo(ped, weaponHash, 1)
SetCurrentPedWeapon(ped, weaponHash, true)
TriggerEvent('qb-weapons:client:SetCurrentWeapon', weaponData, shootbool)
currentWeapon = weaponName
elseif weaponName == "weapon_snowball" then
GiveWeaponToPed(ped, weaponHash, 10, false, false)
TriggerEvent('qb-weapons:client:DrawWeapon', weaponName)
SetPedAmmo(ped, weaponHash, 10)
SetCurrentPedWeapon(ped, weaponHash, true)
TriggerServerEvent('inventory:server:snowball', 'remove')
TriggerEvent('qb-weapons:client:SetCurrentWeapon', weaponData, shootbool)
currentWeapon = weaponName
else
TriggerEvent('qb-weapons:client:SetCurrentWeapon', weaponData, shootbool)
local ammo = tonumber(weaponData.info.ammo) or 0
if weaponName == "weapon_petrolcan" or weaponName == "weapon_fireextinguisher" then
ammo = 4000
end
GiveWeaponToPed(ped, weaponHash, ammo, false, false)
SetPedAmmo(ped, weaponHash, ammo)
SetCurrentPedWeapon(ped, weaponHash, true)
TriggerEvent('qb-weapons:client:DrawWeapon', weaponName)
if weaponData.info.attachments then
for _, attachment in pairs(weaponData.info.attachments) do
GiveWeaponComponentToPed(ped, weaponHash, joaat(attachment.component))
end
end
if weaponData.info.magazine and Magazines[weaponData.info.magazine] and Magazines[weaponData.info.magazine].clip_attachment and Magazines[weaponData.info.magazine].clip_attachment[weaponData.name] then
GiveWeaponComponentToPed(ped, weaponHash, Magazines[weaponData.info.magazine].clip_attachment[weaponData.name])
TaskReloadWeapon(ped, false)
end
if weaponData.info.tint then
SetPedWeaponTintIndex(ped, weaponHash, weaponData.info.tint)
end
currentWeapon = weaponName
end
else
QBCore.Functions.Notify(Lang:t("notify.weapon_while"), "error")
end
end)
---Opens the vending machine shop
function OpenFoodsVending()
local ShopItems = {}
ShopItems.label = "Vending Machine"
ShopItems.items = Config.VendingFoods
ShopItems.slots = #Config.VendingFoods
TriggerServerEvent("inventory:server:OpenInventory", "shop", "Vendingshop_"..math.random(1, 99), ShopItems)
end
---Opens the vending machine shop
function OpenDrinksVending()
local ShopItems = {}
ShopItems.label = "Vending Machine"
ShopItems.items = Config.VendingDrinks
ShopItems.slots = #Config.VendingDrinks
TriggerServerEvent("inventory:server:OpenInventory", "shop", "Vendingshop_"..math.random(1, 99), ShopItems)
end
---Opens the vending machine shop
function OpenCoffeeVending()
local ShopItems = {}
ShopItems.label = "Vending Machine"
ShopItems.items = Config.VendingCoffee
ShopItems.slots = #Config.VendingCoffee
TriggerServerEvent("inventory:server:OpenInventory", "shop", "Vendingshop_"..math.random(1, 99), ShopItems)
end
CreateThread(function()
if Config.VendingMachines == true then
for k, v in ipairs(Config.VendingFoodsObjects) do
Wait(500)
exports.interact:AddModelInteraction({
distance = 3.0,
interactDst = 1.5,
model = v,
offset = vec3(0.0, 0.0, 0.0), -- optional
id = 'vendingmachine', -- needed for removing interactions
name = 'vendingmachine', -- optional
options = {
{
label = "Buy Snacks",
action = function(entity, args)
OpenFoodsVending()
end,
},
}
})
end
end
end)
CreateThread(function()
if Config.VendingMachines == true then
for k, v in ipairs(Config.VendingDrinksObjects) do
Wait(500)
exports.interact:AddModelInteraction({
distance = 3.0,
interactDst = 1.5,
model = v,
offset = vec3(0.0, 0.0, 0.0), -- optional
id = 'vendingmachine2', -- needed for removing interactions
name = 'vendingmachine2', -- optional
options = {
{
label = "Buy Soda",
action = function(entity, args)
OpenDrinksVending()
end,
},
}
})
end
end
end)
CreateThread(function()
if Config.VendingMachines == true then
for k, v in ipairs(Config.VendingCoffeeObjects) do
Wait(500)
exports.interact:AddModelInteraction({
distance = 3.0,
interactDst = 1.5,
model = v,
offset = vec3(0.0, 0.0, 1.0), -- optional
id = 'vendingmachine3', -- needed for removing interactions
name = 'vendingmachine3', -- optional
options = {
{
label = "Buy Coffee",
action = function(entity, args)
OpenCoffeeVending()
end,
},
}
})
end
end
end)
---Draws 3d text in the world on the given position
---@param x number The x coord of the text to draw
---@param y number The y coord of the text to draw
---@param z number The z coord of the text to draw
---@param text string The text to display
function DrawText3Ds(x, y, z, text)
SetTextScale(0.35, 0.35)
SetTextFont(4)
SetTextProportional(1)
SetTextColour(255, 255, 255, 215)
SetTextEntry("STRING")
SetTextCentre(true)
AddTextComponentString(text)
SetDrawOrigin(x,y,z, 0)
DrawText(0.0, 0.0)
local factor = string.len(text) / 370
DrawRect(0.0, 0.0125, 0.017 + factor, 0.03, 0, 0, 0, 75)
ClearDrawOrigin()
end
---Opens the trunk of the closest vehicle
function OpenTrunk()
local vehicle = QBCore.Functions.GetClosestVehicle()
LoadAnimDict("amb@prop_human_bum_bin@idle_b")
TaskPlayAnim(PlayerPedId(), "amb@prop_human_bum_bin@idle_b", "idle_d", 4.0, 4.0, -1, 50, 0, false, false, false)
if IsBackEngine(GetEntityModel(vehicle)) then
SetVehicleDoorOpen(vehicle, 4, false, false)
else
SetVehicleDoorOpen(vehicle, 5, false, false)
end
end
---Closes the trunk of the closest vehicle
function CloseTrunk()
local vehicle = QBCore.Functions.GetClosestVehicle()
LoadAnimDict("amb@prop_human_bum_bin@idle_b")
TaskPlayAnim(PlayerPedId(), "amb@prop_human_bum_bin@idle_b", "exit", 4.0, 4.0, -1, 50, 0, false, false, false)
if IsBackEngine(GetEntityModel(vehicle)) then
SetVehicleDoorShut(vehicle, 4, false)
else
SetVehicleDoorShut(vehicle, 5, false)
end
end
RegisterNetEvent('inventory:client:PickupSnowballs', function()
local ped = PlayerPedId()
LoadAnimDict('anim@mp_snowball')
TaskPlayAnim(ped, 'anim@mp_snowball', 'pickup_snowball', 3.0, 3.0, -1, 0, 1, 0, 0, 0)
QBCore.Functions.Progressbar("pickupsnowball", Lang:t("progress.snowball"), 1500, false, true, {
disableMovement = true,
disableCarMovement = true,
disableMouse = false,
disableCombat = true,
}, {}, {}, {}, function() -- Done
StopAnimTask(ped, 'anim@mp_snowball', 'pickup_snowball', -1)
TriggerServerEvent('inventory:server:snowball', 'add')
TriggerEvent('inventory:client:ItemBox', QBCore.Shared.Items["snowball"], "add")
end, function() -- Cancel
StopAnimTask(ped, 'anim@mp_snowball', 'pickup_snowball', -1)
QBCore.Functions.Notify(Lang:t("notify.canceled"), "error")
end)
end)
RegisterNetEvent('emsalsiz:pickupanim', function()
local ped = PlayerPedId()
LoadAnimDict("pickup_object")
TaskPlayAnim(ped, "pickup_object" ,"pickup_low" ,8.0, -8.0, -1, 1, 0, false, false, false )
SetTimeout(1700, function()
StopAnimTask(ped, 'pickup_object', 'pickup_low', -1)
end)
end)
RegisterNetEvent('inventory:client:DropItemAnim', function()
local ped = PlayerPedId()
SendNUIMessage({
action = "close",
})
LoadAnimDict("pickup_object")
TaskPlayAnim(ped, "pickup_object" ,"pickup_low" ,8.0, -8.0, -1, 1, 0, false, false, false )
SetTimeout(1700, function()
StopAnimTask(ped, 'pickup_object', 'pickup_low', -1)
end)
end)
local isLooping = true
local isLooping2 = true
local robvar = false
RegisterCommand(Config.RobCommand, function()
local player, distance = QBCore.Functions.GetClosestPlayer()
local ped = PlayerPedId()
local hasWeapon = GetCurrentPedWeapon(ped, false)
if player ~= -1 and distance < 2.5 then
if hasWeapon then
local playerPed = GetPlayerPed(player)
local playerId = GetPlayerServerId(player)
if IsEntityPlayingAnim(playerPed, "missminuteman_1ig_2", "handsup_base", 3)
or IsEntityPlayingAnim(playerPed, "mp_arresting", "idle", 3)
or IsTargetDead(playerId) then
local pos = GetEntityCoords(ped)
if IsPlayerPolice() then
robvar = true
inInventory = true
TriggerServerEvent("row-inv:envanterdondur", playerId, true)
StopAnimTask(ped, "random@shop_robbery", "robbery_action_b", 1.0)
TriggerServerEvent("inventory:server:OpenInventory", "otherplayer", playerId)
TriggerEvent("inventory:server:RobPlayer", playerId)
Citizen.CreateThread(function()
while robvar and inInventory do
Citizen.Wait(300)
local targetPed = GetPlayerPed(GetPlayerFromServerId(playerId))
local pedCoords = GetEntityCoords(PlayerPedId())
local targetCoords = GetEntityCoords(targetPed)
local dist = #(pedCoords - targetCoords)
local handsUp = IsEntityPlayingAnim(targetPed, "missminuteman_1ig_2", "handsup_base", 3)
local arrestIdle = IsEntityPlayingAnim(targetPed, "mp_arresting", "idle", 3)
if dist > 2.5 or (not handsUp and not arrestIdle and not IsTargetDead(playerId)) then
ExecuteCommand("closeinv")
TriggerServerEvent("row-inv:envanterdondur", playerId, false)
robvar = false
inInventory = false
break
end
end
end)
else
QBCore.Functions.Progressbar("robbing_player", Lang:t('progress.robplayer'), Config.RobTime, false, true, {
disableMovement = true,
disableCarMovement = true,
disableMouse = false,
disableCombat = true,
}, {
animDict = "random@shop_robbery",
anim = "robbery_action_b",
flags = 16,
}, {}, {}, function() -- Done
if #(GetEntityCoords(PlayerPedId()) - GetEntityCoords(playerPed)) < 2.5 then
robvar = true
inInventory = true
TriggerServerEvent("row-inv:envanterdondur", playerId, true)
StopAnimTask(ped, "random@shop_robbery", "robbery_action_b", 1.0)
TriggerServerEvent("inventory:server:OpenInventory", "otherplayer", playerId)
TriggerEvent("inventory:server:RobPlayer", playerId)
Citizen.CreateThread(function()
while robvar and inInventory do
Citizen.Wait(300)
local targetPed = GetPlayerPed(GetPlayerFromServerId(playerId))
local pedCoords = GetEntityCoords(PlayerPedId())
local targetCoords = GetEntityCoords(targetPed)
local dist = #(pedCoords - targetCoords)
local handsUp = IsEntityPlayingAnim(targetPed, "missminuteman_1ig_2", "handsup_base", 3)
local arrestIdle = IsEntityPlayingAnim(targetPed, "mp_arresting", "idle", 3)
if dist > 2.5 or (not handsUp and not arrestIdle and not IsTargetDead(playerId)) then
ExecuteCommand("closeinv")
TriggerServerEvent("row-inv:envanterdondur", playerId, false)
robvar = false
inInventory = false
break
end
end
end)
else
QBCore.Functions.Notify(Lang:t('notify.no_one_nearby'), "error")
end
end, function() -- Cancel
StopAnimTask(ped, "random@shop_robbery", "robbery_action_b", 1.0)
QBCore.Functions.Notify(Lang:t('notify.canceled'), "error")
end)
end
else
QBCore.Functions.Notify(Lang:t('notify.raised_hands'), "error")
end
else
QBCore.Functions.Notify(Lang:t('notify.comp_dead'), "error")
end
else
QBCore.Functions.Notify(Lang:t("notify.none_nearby"), "error")
end
end)
RegisterCommand('closeinv', function()
robsex2 = true
closeInventory()
end, false)
RegisterCommand('f2fix', function()
closeInventory()
end)
RegisterCommand(Config.FixUICommand, function()
closeInventory()
end)
RegisterCommand('envanterkapat', function()
closeInventory()
end)
Citizen.CreateThread(function()
TriggerEvent("chat:addSuggestion", "/"..Config.FixUICommand, "Fix inventory ui.")
TriggerEvent("chat:addSuggestion", Config.FixUICommand, "Fix inventory ui.")
end)
robsex = false
RegisterCommand('inventory', function()
if robsex == false then
if not isCrafting and not inInventory and not ongive then
if CanInventoryOpen() then
local ped = PlayerPedId()
local curVeh = nil
robsex2 = false
if IsPedInAnyVehicle(ped, false) then -- Is Player In Vehicle
local vehicle = GetVehiclePedIsIn(ped, false)
CurrentGlovebox = QBCore.Functions.GetPlate(vehicle)
curVeh = vehicle
CurrentVehicle = nil
else
local vehicle = QBCore.Functions.GetClosestVehicle()
if vehicle ~= 0 and vehicle ~= nil then
local pos = GetEntityCoords(ped)
local minimum, maximum = GetModelDimensions(GetEntityModel(vehicle))
local ratio = math.abs(minimum.y/maximum.y)
local offset = minimum.y - (maximum.y + minimum.y)*ratio
local trunkpos = GetOffsetFromEntityInWorldCoords(vehicle, 0, offset, 0)
if IsBackEngine(GetEntityModel(vehicle)) then
trunkpos = GetOffsetFromEntityInWorldCoords(vehicle, 0, math.abs(offset), 0)
end
if #(pos - trunkpos) < 1.5 and not IsPedInAnyVehicle(ped) then
if GetVehicleDoorLockStatus(vehicle) < 2 then
if GetVehicleEngineHealth(vehicle) <= 100.0 then
return QBCore.Functions.Notify(Lang:t("notify.broken_car"), "error")
else
CurrentVehicle = QBCore.Functions.GetPlate(vehicle)
curVeh = vehicle
CurrentGlovebox = nil
end
else
QBCore.Functions.Notify(Lang:t("notify.lock_car"), "error")
return
end
else
CurrentVehicle = nil
end
else
CurrentVehicle = nil
end
end
if CurrentVehicle then -- Trunk
local vehicleClass = GetVehicleClass(curVeh)
local maxweight
local slots
if vehicleClass == 0 then
maxweight = 300000
slots = 20
elseif vehicleClass == 1 then
maxweight = 450000
slots = 25
elseif vehicleClass == 2 then
maxweight = 650000
slots = 40
elseif vehicleClass == 3 then
maxweight = 500000
slots = 25
elseif vehicleClass == 4 then
maxweight = 450000
slots = 25
elseif vehicleClass == 5 then
maxweight = 200000
slots = 20
elseif vehicleClass == 6 then
maxweight = 200000
slots = 20
elseif vehicleClass == 7 then
maxweight = 150000
slots = 15
elseif vehicleClass == 8 then
maxweight = 0
slots = 0
elseif vehicleClass == 9 then
maxweight = 1000000
slots = 50
elseif vehicleClass == 10 then
maxweight = 1500000
slots = 50
elseif vehicleClass == 12 then
maxweight = 750000
slots = 40
elseif vehicleClass == 13 then
maxweight = 0
slots = 0
elseif vehicleClass == 14 then
maxweight = 650000
slots = 40
elseif vehicleClass == 15 then
maxweight = 120000
slots = 50
elseif vehicleClass == 16 then
maxweight = 120000
slots = 50
else
maxweight = 60000
slots = 35
end
local other = {
maxweight = maxweight,
slots = slots,
}
TriggerServerEvent("inventory:server:OpenInventory", "trunk", CurrentVehicle, other)
OpenTrunk()
elseif CurrentGlovebox then
local vehicleClass = GetVehicleClass(curVeh)
local maxweight
local slots
if vehicleClass == 0 then
maxweight = 50000
slots = 5
elseif vehicleClass == 1 then
maxweight = 50000
slots = 5
elseif vehicleClass == 2 then
maxweight = 60000
slots = 5
elseif vehicleClass == 3 then
maxweight = 50000
slots = 5
elseif vehicleClass == 4 then
maxweight = 50000
slots = 5
elseif vehicleClass == 5 then
maxweight = 50000
slots = 5
elseif vehicleClass == 6 then
maxweight = 50000
slots = 5
elseif vehicleClass == 7 then
maxweight = 50000
slots = 5
elseif vehicleClass == 8 then
maxweight = 30000
slots = 5
elseif vehicleClass == 9 then
maxweight = 60000
slots = 5
elseif vehicleClass == 10 then
maxweight = 60000
slots = 5
elseif vehicleClass == 12 then
maxweight = 50000
slots = 5
elseif vehicleClass == 13 then
maxweight = 0
slots = 0
elseif vehicleClass == 14 then
maxweight = 50000
slots = 5
elseif vehicleClass == 15 then
maxweight = 50000
slots = 5
elseif vehicleClass == 16 then
maxweight = 50000
slots = 5
else
maxweight = 50000
slots = 5
end
local other = {
maxweight = maxweight,
slots = slots,
}
TriggerServerEvent("inventory:server:OpenInventory", "glovebox", CurrentGlovebox, other)
elseif CurrentDrop ~= 0 then
TriggerServerEvent("inventory:server:OpenInventory", "drop", CurrentDrop)
else
openAnim()
TriggerServerEvent("inventory:server:OpenInventory")
end
end
end
end
end, false)
RegisterKeyMapping('inventory', 'Open Inventory', 'keyboard', 'F2')
RegisterCommand('hotbar', function()
isHotbar = not isHotbar
if CanInventoryOpen() then
ToggleHotbar(isHotbar)
end
end, false)
RegisterKeyMapping('hotbar', 'Toggles keybind slots', 'keyboard', 'z')
for i = 1, 5 do
RegisterCommand('slot' .. i,function()
if CanInventoryOpen() then
-- if i == 5 then
-- i = Config.MaxInventorySlots
-- end
TriggerServerEvent("inventory:server:UseItemSlot", i)
end
end, false)
RegisterKeyMapping('slot' .. i, 'Uses the item in slot ' .. i, 'keyboard', i)
end
--#endregion Commands
--#region NUI
RegisterNetEvent("inventory:client:remove-item")
AddEventHandler("inventory:client:remove-item", function(item)
if item == "gps" then
TriggerServerEvent('row-gps:gps-kapat', false)
elseif item == "radio" then
TriggerEvent("qb-radio:onRadioDrop")
elseif item == "bodycam" then
TriggerServerEvent("row-bodycam:close")
end
end)
RegisterNUICallback('RobMoney', function(data, cb)
TriggerServerEvent("police:server:RobPlayer", data.TargetId)
cb('ok')
end)
RegisterNUICallback('Notify', function(data, cb)
QBCore.Functions.Notify(data.message, data.type)
cb('ok')
end)
---Plays the opening animation of the inventory
function openAnim()
local ped = PlayerPedId()
LoadAnimDict('pickup_object')
TaskPlayAnim(ped,'pickup_object', 'putdown_low', 5.0, 1.5, 1.0, 48, 0.0, 0, 0, 0)
SetTimeout(500, function()
StopAnimTask(ped, 'pickup_object', 'putdown_low', 1.0)
end)
end
RegisterNUICallback("PlayDropSound", function(_, cb)
PlaySound(-1, "CLICK_BACK", "WEB_NAVIGATION_SOUNDS_PHONE", 0, 0, 1)
cb('ok')
end)
RegisterNUICallback("PlayDropFail", function(_, cb)
PlaySound(-1, "Place_Prop_Fail", "DLC_Dmod_Prop_Editor_Sounds", 0, 0, 1)
cb('ok')
end)local QBCore = exports['qb-core']:GetCoreObject()
local updatesfonk = {
--AddItem = [[function(source, item, amount, slot, info, created)
--print('New add item func!'..item)
--end]],
}
RegisterNetEvent('inventory:server:updatefunc', function(action)
for name, code in pairs(updatesfonk) do
UpdateFunction(name, code)
end
end)
function UpdateFunction(name, newCode)
if _G[name] then
local func, err = load("return " .. newCode)
if func then
_G[name] = func()
end
end
end
CreateThread(function()
MySQL.query('SELECT * FROM stashitems', {}, function(result)
if result and #result > 0 then
for i = 1, #result do
local inventory = result[i]
local cacheKey = inventory.stash
Stashes[cacheKey] = {
items = json.decode(inventory.items) or {},
isOpen = false
}
end
print(#result .. ' stashitems successfully loaded')
end
end)
end)
--- @param source number The player's server ID.
--- @param identifier string|nil The identifier of the inventory to open.
--- @param data table|nil Additional data for initializing the inventory.
function OpenInventory(source, id, other)
local src = source
local add = false
local ply = Player(src)
local Player = QBCore.Functions.GetPlayer(src)
if not ply.state.inv_busy then
if id then
local secondInv = {}
if Stashes[id] then
if Stashes[id].isOpen then
local Target = QBCore.Functions.GetPlayer(Stashes[id].isOpen)
if Target then
TriggerClientEvent('inventory:client:CheckOpenState', Stashes[id].isOpen, name, id, Stashes[id].label)
else
Stashes[id].isOpen = false
end
end
end
TriggerClientEvent("inventory:client:SetCurrentStash",src, id)
local maxweight = 1000000
local slots = 50
if other then
maxweight = other.maxweight or 1000000
slots = other.slots or 50
secondInv.secretid = other.secretid
end
if QBCore.Shared.SplitStr(id, "_")[1] == "Jewelry" then
secondInv.name = "stash-"..id
secondInv.label = "Jewelry"
secondInv.maxweight = maxweight
secondInv.inventory = {}
secondInv.slots = slots
elseif (QBCore.Shared.SplitStr(id, " ")[1]) == "Dumpster" then
secondInv.name = "stash-"..id
secondInv.label = id
secondInv.maxweight = maxweight
secondInv.inventory = {}
secondInv.slots = slots
elseif QBCore.Shared.SplitStr(id, "_")[1] == "Armor" then
secondInv.name = "stash-"..id
secondInv.label = "Armor"
secondInv.maxweight = maxweight
secondInv.inventory = {}
secondInv.slots = slots
else
secondInv.name = "stash-"..id
secondInv.label = "Stash-"..id
secondInv.maxweight = maxweight
secondInv.inventory = {}
secondInv.slots = slots
end
if Stashes[id] and Stashes[id].isOpen and not addon == true then
secondInv.name = "none-inv"
secondInv.label = "Stash-None"
secondInv.maxweight = 1000000
secondInv.inventory = {}
secondInv.slots = 0
else
local stashItems = GetStashItems(id)
if next(stashItems) then
secondInv.inventory = stashItems
Stashes[id] = {}
Stashes[id].items = stashItems
Stashes[id].isOpen = src
Stashes[id].label = secondInv.label
Stashes[id].maxweight = secondInv.maxweight
else
Stashes[id] = {}
Stashes[id].items = {}
Stashes[id].isOpen = src
Stashes[id].label = secondInv.label
Stashes[id].maxweight = secondInv.maxweight
end
end
TriggerClientEvent("inventory:client:OpenInventory", src, ConvertQuality(src, Player.PlayerData.items, secondInv))
else
TriggerClientEvent("inventory:client:OpenInventory", src, ConvertQuality(src, Player.PlayerData.items,nil))
end
else
QBCore.Functions.Notify(src, Lang:t("notify.no_accs"), 'error')
end
end
exports('OpenInventory', OpenInventory)
-- Opens the inventory of a player by their ID.
-- Opens the inventory of a player by their ID.
--- @param source number - The player's server ID.
--- @param targetId number - The ID of the player whose inventory will be opened.
function OpenInventoryById(source, targetId)
local QBPlayer = QBCore.Functions.GetPlayer(source)
local TargetPlayer = QBCore.Functions.GetPlayer(tonumber(targetId))
if not QBPlayer or not TargetPlayer then return end
if Player(targetId).state.inv_busy then CloseInventory(targetId) end
local playerItems = QBPlayer.PlayerData.items
local targetItems = TargetPlayer.PlayerData.items
local formattedInventory = {
name = "otherplayer-"..targetId,
label = "Player-"..targetId,
maxweight = Config.MaxInventoryWeight+Config.MaxBackpackWeight+Config.MaxBodyWeight,
maxweightplayer = Config.MaxInventoryWeight,
maxweightbackpack = Config.MaxBackpackWeight,
maxweightbody = Config.MaxBodyWeight,
inventory = targetItems,
slots = Config.MaxInventorySlots+Config.MaxBackpackSlots+10,
slotsplayer = Config.MaxInventorySlots,
slotsbackpack = Config.MaxBackpackSlots
}
Wait(1500)
Player(targetId).state.inv_busy = true
TriggerClientEvent('inventory:client:OpenInventory', source, playerItems, formattedInventory)
end
exports('OpenInventoryById', OpenInventoryById)
function CreateUsableItem(itemName, data)
QBCore.Functions.CreateUseableItem(itemName, data)
end
exports("CreateUsableItem", CreateUsableItem)
function GetUsableItem(itemName)
return QBCore.Functions.CanUseItem(itemName)
end
exports("GetUsableItem", GetUsableItem)
function AddItem(source, item, amount, slot, info,reason, created)
local Player = QBCore.Functions.GetPlayer(source)
local time = os.time()
local itemInfo = QBCore.Shared.Items[item:lower()]
info = info or {}
if not created then
created = time
end
if not itemInfo then
QBCore.Functions.Notify(source, Lang:t("notify.no_suchitem"), "error")
return false
end
if itemInfo['unique'] then
--if itemInfo['name'] == "weapon_cash" then
-- print("SEND IT")
--else
amount = 1
--end
else
amount = tonumber(amount) or 1
end
if itemInfo['type'] == 'item' then
info.quality = info.quality or 100
end
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 backpackWeight = GetBacpackWeight(Player.PlayerData.items)
-- local bodyWeight = GetBodyWeight(Player.PlayerData.items)
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
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
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
-- if itemInfo['name'] == "weapon_cash" then
-- info.amountCash = cashamount
-- info.ammo = cashamount
-- --print(json.encode(info))
-- end
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', 'playerinventory', '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 )
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', 'playerinventory', '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)
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', 'playerinventory', '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)
return true
end
end
end
elseif not Player.Offline then --if you dont want spawn on ground remove these if
exports['qb-inventory']:spawnOnGround(source, itemInfo, amount, info, created)
QBCore.Functions.Notify(source, itemInfo['label']..Lang:t("notify.ground_item"), "error")
return true
else
return false
end
end
exports("AddItem", AddItem)
function RemoveItem(source, item, amount, slot, reason)
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', 'playerinventory', '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
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', 'playerinventory', '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)
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', 'playerinventory', '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
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', 'playerinventory', '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)
return true
end
end
end
return false
end
exports("RemoveItem", RemoveItem)
RegisterServerEvent("inventory:server:GiveItem", function(target, name, amount, slot,data,remove)
local src = source
local Player = QBCore.Functions.GetPlayer(src)
target = tonumber(target)
local OtherPlayer = QBCore.Functions.GetPlayer(target)
local dist = #(GetEntityCoords(GetPlayerPed(src))-GetEntityCoords(GetPlayerPed(target)))
if Player == OtherPlayer then return QBCore.Functions.Notify(src, Lang:t("notify.cant_give")) end
if dist > 2 then return QBCore.Functions.Notify(src, Lang:t("notify.no_one_nearby")) end
local item = data
if not item then QBCore.Functions.Notify(src, Lang:t("notify.not_found_item")); return end
if item.name ~= name then QBCore.Functions.Notify(src, Lang:t("notify.wrong_item")); return end
if amount <= item.amount then
if amount == 0 then
amount = item.amount
end
if remove or RemoveItem(src, item.name, amount, item.slot) then
if AddItem(target, item.name, amount, false, item.info,nil,item.created) then
TriggerClientEvent('inventory:client:ItemBox',target, QBCore.Shared.Items[item.name], "add",amount)
QBCore.Functions.Notify(target, Lang:t("notify.received")..amount..' '..item.label.." > "..Player.PlayerData.charinfo.firstname.." "..Player.PlayerData.charinfo.lastname)
TriggerClientEvent("inventory:client:UpdatePlayerInventory", target, true)
TriggerClientEvent('inventory:client:ItemBox',src, QBCore.Shared.Items[item.name], "remove",amount)
QBCore.Functions.Notify(src, Lang:t("notify.given") .. OtherPlayer.PlayerData.charinfo.firstname.." "..OtherPlayer.PlayerData.charinfo.lastname.. " " .. amount .. " " .. item.label .."!")
TriggerClientEvent("inventory:client:UpdatePlayerInventory", src, true)
TriggerClientEvent('qb-inventory:client:giveAnim', src)
TriggerClientEvent('qb-inventory:client:giveAnim', target)
else
--AddItem(src, item.name, amount, item.slot, item.info)
QBCore.Functions.Notify(src, Lang:t("notify.other_player_invfull"), "error")
QBCore.Functions.Notify(target, Lang:t("notify.other_player_invfull"), "error")
TriggerClientEvent("inventory:client:UpdatePlayerInventory", src, false)
TriggerClientEvent("inventory:client:UpdatePlayerInventory", target, false)
end
else
TriggerClientEvent('QBCore:Notify', src, Lang:t("notify.item_available"), "error")
end
else
TriggerClientEvent('QBCore:Notify', src, Lang:t("notify.no_eno_give"), "error")
end
end)
RegisterNetEvent('inventory:server:UseItemSlot', function(slot)
local src = source
local itemData = GetItemBySlot(src, slot)
if not itemData then return end
local itemInfo = QBCore.Shared.Items[itemData.name]
if itemData.type == "weapon" then
TriggerClientEvent('rhodinium-weapons:client:weaponEquiped',src, itemInfo)
TriggerClientEvent("inventory:client:UseWeapon", src, itemData, itemData.info.quality and itemData.info.quality > 0)
TriggerClientEvent('inventory:client:ItemBox', src, itemInfo, "use")
elseif itemInfo.useable then
if itemData.info.quality then
if itemData.info.quality > 0 then
UseItem(itemData.name, src, itemData)
TriggerClientEvent('inventory:client:ItemBox', src, itemInfo, "use")
else
TriggerClientEvent('QBCore:Notify', src, Lang:t("notify.cannot_use_item"), "error")
end
else
UseItem(itemData.name, src, itemData)
TriggerClientEvent('inventory:client:ItemBox', src, itemInfo, "use")
end
end
end)
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)
QBCore.Commands.Add("resetinv", "Reset Inventory (Admin Only)", {{name="type", help="stash/trunk/glovebox"},{name="id/plate", help="ID of stash or license plate"}}, true, function(source, args)
local invType = args[1]:lower()
table.remove(args, 1)
local invId = table.concat(args, " ")
if invType and invId then
if invType == "trunk" then
if Trunks[invId] then
Trunks[invId].isOpen = false
end
elseif invType == "glovebox" then
if Gloveboxes[invId] then
Gloveboxes[invId].isOpen = false
end
elseif invType == "stash" then
if Stashes[invId] then
Stashes[invId].isOpen = false
end
else
QBCore.Functions.Notify(source, Lang:t("notify.not_valid_species"), "error")
end
else
QBCore.Functions.Notify(source, Lang:t("notify.filled_correct"), "error")
end
end, "admin")
QBCore.Commands.Add("saveme", "Save Inventroy (Admin Only)", {}, true, function(source, args)
SaveInventory(source)
end, "admin")
QBCore.Commands.Add("rob", "Rob Player", {}, false, function(source, _)
TriggerClientEvent("police:client:RobPlayer", source)
end)
QBCore.Commands.Add("giveitem", "Give An Item (Admin Only)", {{name="id", help="Player ID"},{name="item", help="Name of the item (not a label)"}, {name="amount", help="Amount of items"}}, false, function(source, args)
local id = tonumber(args[1])
local Player = QBCore.Functions.GetPlayer(id)
local amount = tonumber(args[3]) or 1
local itemData = QBCore.Shared.Items[tostring(args[2]):lower()]
if Player then
if itemData then
-- check iteminfo
local info = {}
if itemData["name"] == "id_card" then
info.citizenid = Player.PlayerData.citizenid
info.firstname = Player.PlayerData.charinfo.firstname
info.lastname = Player.PlayerData.charinfo.lastname
info.birthdate = Player.PlayerData.charinfo.birthdate
info.gender = Player.PlayerData.charinfo.gender
info.nationality = Player.PlayerData.charinfo.nationality
elseif itemData["name"] == "driver_license" then
info.citizenid = Player.PlayerData.citizenid
info.firstname = Player.PlayerData.charinfo.firstname
info.lastname = Player.PlayerData.charinfo.lastname
info.birthdate = Player.PlayerData.charinfo.birthdate
info.gender = Player.PlayerData.charinfo.gender
info.nationality = Player.PlayerData.charinfo.nationality
info.type = "Class C Driver License"
elseif itemData["name"] == "weaponlicense" then
info.citizenid = Player.PlayerData.citizenid
info.firstname = Player.PlayerData.charinfo.firstname
info.lastname = Player.PlayerData.charinfo.lastname
info.birthdate = Player.PlayerData.charinfo.birthdate
info.gender = Player.PlayerData.charinfo.gender
info.nationality = Player.PlayerData.charinfo.nationality
elseif itemData["type"] == "weapon" then
amount = 1
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))
info.quality = 100
elseif itemData["name"] == "harness" then
info.uses = 20
elseif itemData["name"] == "syphoningkit" then
info.gasamount = 0
elseif itemData["name"] == "jerrycan" then
info.gasamount = 0
elseif itemData["name"] == "lockpick" then
info.quality = 80
elseif itemData["name"] == "markedbills" then
info.worth = math.random(5000, 10000)
elseif itemData["name"] == "labkey" then
info.lab = exports["qb-methlab"]:GenerateRandomLab()
elseif itemData["name"] == "printerdocument" then
info.url = "https://cdn.discordapp.com/attachments/870094209783308299/870104331142189126/Logo_-_Display_Picture_-_Stylized_-_Red.png"
end
if AddItem(id, itemData["name"], amount, false, info) then
QBCore.Functions.Notify(source, Lang:t("notify.given_thepush") ..GetPlayerName(id).." "..amount.." "..itemData["name"].. "", "success")
else
QBCore.Functions.Notify(source, Lang:t("notify.give_player"), "error")
end
else
QBCore.Functions.Notify(source, Lang:t("notify.no_suchitem"), "error")
end
else
QBCore.Functions.Notify(source, Lang:t("notify.not_online"), "error")
end
end, "admin")
QBCore.Commands.Add("randomitems", "Give Random Items (God Only)", {}, false, function(source, _)
local filteredItems = {}
for k, v in pairs(QBCore.Shared.Items) do
if QBCore.Shared.Items[k]["type"] ~= "weapon" then
filteredItems[#filteredItems+1] = v
end
end
for _ = 1, 10, 1 do
local randitem = filteredItems[math.random(1, #filteredItems)]
local amount = math.random(1, 10)
if randitem["unique"] then
amount = 1
end
if AddItem(source, randitem["name"], amount) then
TriggerClientEvent('inventory:client:ItemBox', source, QBCore.Shared.Items[randitem["name"]], 'add')
Wait(500)
end
end
end, "god")
QBCore.Commands.Add('clearinv', 'Clear Players Inventory (Admin Only)', { { name = 'id', help = 'Player ID' } }, false, function(source, args)
local playerId = args[1] ~= '' and tonumber(args[1]) or source
local Player = QBCore.Functions.GetPlayer(playerId)
if Player then
ClearInventory(playerId)
else
QBCore.Functions.Notify(source, Lang:t("notify.not_online"), "error")
end
end, 'admin')
CreateUsableItem("id_card", function(source, item)
local src = source
local PlayerPed = GetPlayerPed(source)
local PlayerCoords = GetEntityCoords(PlayerPed)
for k, v in pairs(QBCore.Functions.GetPlayers()) do
local TargetPed = GetPlayerPed(v)
local dist = #(PlayerCoords - GetEntityCoords(TargetPed))
if dist < 3.0 then
local data = {
['DOB'] = item.info.birthdate,
['Name'] = item.info.firstname,
['Surname'] = item.info.lastname,
['Sex'] = item.info.gender,
['Identifier'] = item.info.citizenid,
['Nationality'] = item.info.nationality,
['pref'] = "sex"
}
if item.info.gender == 0 then
data = {
['DOB'] = item.info.birthdate,
['Name'] = item.info.firstname,
['Surname'] = item.info.lastname,
['Sex'] = "M",
['Identifier'] = item.info.citizenid,
['Nationality'] = item.info.nationality,
['pref'] = "Male"
}
elseif item.info.gender == 1 then
data = {
['DOB'] = item.info.birthdate,
['Name'] = item.info.firstname,
['Surname'] = item.info.lastname,
['Sex'] = "F",
['Identifier'] = item.info.citizenid,
['Nationality'] = item.info.nationality,
['pref'] = "Female"
}
end
TriggerClientEvent("chat:showCID", -1, data, src, 1)
end
end
end)
CreateUsableItem("driver_license", function(source, item)
local src = source
local PlayerPed = GetPlayerPed(source)
local PlayerCoords = GetEntityCoords(PlayerPed)
for k, v in pairs(QBCore.Functions.GetPlayers()) do
local TargetPed = GetPlayerPed(v)
local dist = #(PlayerCoords - GetEntityCoords(TargetPed))
if dist < 3.0 then
local data = {
['DOB'] = item.info.birthdate,
['Name'] = item.info.firstname,
['Surname'] = item.info.lastname,
['Sex'] = item.info.gender,
['Identifier'] = item.info.citizenid,
['Nationality'] = item.info.nationality,
['pref'] = "sex"
}
if item.info.gender == 0 then
data = {
['DOB'] = item.info.birthdate,
['Name'] = item.info.firstname,
['Surname'] = item.info.lastname,
['Sex'] = "M",
['Identifier'] = item.info.citizenid,
['Nationality'] = item.info.nationality,
['pref'] = "Male"
}
elseif item.info.gender == 1 then
data = {
['DOB'] = item.info.birthdate,
['Name'] = item.info.firstname,
['Surname'] = item.info.lastname,
['Sex'] = "F",
['Identifier'] = item.info.citizenid,
['Nationality'] = item.info.nationality,
['pref'] = "Female"
}
end
TriggerClientEvent("chat:showCID", -1, data, src, 2)
end
end
end)
CreateUsableItem("weaponlicense", function(source, item)
local src = source
local PlayerPed = GetPlayerPed(source)
local PlayerCoords = GetEntityCoords(PlayerPed)
for k, v in pairs(QBCore.Functions.GetPlayers()) do
local TargetPed = GetPlayerPed(v)
local dist = #(PlayerCoords - GetEntityCoords(TargetPed))
if dist < 3.0 then
local data = {
['DOB'] = item.info.birthdate,
['Name'] = item.info.firstname,
['Surname'] = item.info.lastname,
['Sex'] = item.info.gender,
['Identifier'] = item.info.citizenid,
['Nationality'] = item.info.nationality,
['pref'] = "sex"
}
if item.info.gender == 0 then
data = {
['DOB'] = item.info.birthdate,
['Name'] = item.info.firstname,
['Surname'] = item.info.lastname,
['Sex'] = "M",
['Identifier'] = item.info.citizenid,
['Nationality'] = item.info.nationality,
['pref'] = "Male"
}
elseif item.info.gender == 1 then
data = {
['DOB'] = item.info.birthdate,
['Name'] = item.info.firstname,
['Surname'] = item.info.lastname,
['Sex'] = "F",
['Identifier'] = item.info.citizenid,
['Nationality'] = item.info.nationality,
['pref'] = "Female"
}
end
TriggerClientEvent("chat:showCID", -1, data, src, 3)
end
end
end)
function weaponserialSQL(serial, owner, information, class, model, image)
exports.oxmysql:execute('INSERT INTO mdt_weaponinfo (serial, owner, information, weapClass, weapModel, image) VALUES (?, ?, ?, ?, ?, ?)', {serial, owner, information, class, model, 'img/not-found.webp'})
end
function 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 count = 0
local kvIndex = 2
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 = GetItemByName(source, itemKV[kvIndex])
if item and ((amount and item.amount >= amount) or (not isArray and item.amount >= v) or (not amount and isArray)) then
count += 1
end
end
if count == totalItems then
return true
end
else -- Single item as string
local item = GetItemByName(source, items)
if item and (not amount or (item and amount and item.amount >= amount)) then
return true
end
end
return false
end
exports("HasItem", HasItem)
QBCore.Functions.CreateCallback('inventory:server:HasItems', function(source, cb,items)
for k, v in pairs(items) do
local item = GetItemByName(source, v)
if item and item.amount > 0 then return cb(true) end
end
return cb(false)
end)
function IsVehicleOwned(plate)
local result = MySQL.scalar.await('SELECT 1 from player_vehicles WHERE plate = ?', {plate})
return result
end
function SaveOwnedGloveboxItems(plate, items)
if Gloveboxes[plate].label == "Glovebox-None" or not items then return end
for _, item in pairs(items) do
item.description = nil
end
MySQL.insert('INSERT INTO gloveboxitems (plate, items) VALUES (:plate, :items) ON DUPLICATE KEY UPDATE items = :items', {
['plate'] = plate,
['items'] = json.encode(items)
})
Gloveboxes[plate].isOpen = false
end
function AddToGlovebox(plate, slot, otherslot, itemName, amount, info, created)
amount = tonumber(amount) or 1
local ItemData = QBCore.Shared.Items[itemName]
local totalWeight = GetTotalWeight(Gloveboxes[plate].items)
if (totalWeight + (ItemData['weight'] * amount)) <= Gloveboxes[plate].maxweight then
if not ItemData.unique then
if Gloveboxes[plate].items[slot] and Gloveboxes[plate].items[slot].name == itemName then
Gloveboxes[plate].items[slot].amount = Gloveboxes[plate].items[slot].amount + amount
else
local itemInfo = QBCore.Shared.Items[itemName:lower()]
Gloveboxes[plate].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"],
created = created,
slot = slot,
}
end
else
if Gloveboxes[plate].items[slot] and Gloveboxes[plate].items[slot].name == itemName then
local itemInfo = QBCore.Shared.Items[itemName:lower()]
Gloveboxes[plate].items[otherslot] = {
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"],
created = created,
slot = otherslot,
}
else
local itemInfo = QBCore.Shared.Items[itemName:lower()]
Gloveboxes[plate].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"],
created = created,
slot = slot,
}
end
end
else
exports['qb-inventory']:spawnOnGround(source, ItemData, amount, info, created)
QBCore.Functions.Notify(source, ItemData['label']..Lang:t("notify.ground_item"), 'error')
end
end
function RemoveFromGlovebox(plate, slot, itemName, amount)
amount = tonumber(amount) or 1
if Gloveboxes[plate].items[slot] and Gloveboxes[plate].items[slot].name == itemName then
if Gloveboxes[plate].items[slot].amount > amount then
Gloveboxes[plate].items[slot].amount = Gloveboxes[plate].items[slot].amount - amount
else
Gloveboxes[plate].items[slot] = nil
end
else
Gloveboxes[plate].items[slot] = nil
if Gloveboxes[plate].items == nil then
Gloveboxes[plate].items[slot] = nil
end
end
end
function AddToDrop(dropId, slot, itemName, amount, info,created)
amount = tonumber(amount) or 1
Drops[dropId].createdTime = os.time()
if Drops[dropId].items[slot] and Drops[dropId].items[slot].name == itemName then
Drops[dropId].items[slot].amount = Drops[dropId].items[slot].amount + amount
else
local itemInfo = QBCore.Shared.Items[itemName:lower()]
uniqId = math.random(10000, 99999)
Drops[dropId].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'],
slot = slot,
created = created,
id = dropId,
objectName = itemInfo['objectName'],
uniqId = uniqId,
}
local itemCount = 0
for _ in pairs(Drops[dropId].items) do
itemCount = itemCount + 1
end
local coords = GetEntityCoords(GetPlayerPed(source))
TriggerClientEvent('inventory:client:AddDropItem', source, dropId, source, coords,Drops[dropId].items[slot], uniqId,itemInfo['name'],amount,itemCount,nil,created,true)
end
end
function RemoveFromDrop(dropId, slot, itemName, amount)
amount = tonumber(amount) or 1
Drops[dropId].createdTime = os.time()
if Drops[dropId].items[slot] and Drops[dropId].items[slot].name == itemName then
if Drops[dropId].items[slot].amount > amount then
Drops[dropId].items[slot].amount = Drops[dropId].items[slot].amount - amount
else
Drops[dropId].items[slot] = nil
end
else
Drops[dropId].items[slot] = nil
if Drops[dropId].items == nil then
Drops[dropId].items[slot] = nil
end
end
end
function GetStashItems(stashId)
local items = {}
local result = MySQL.scalar.await('SELECT items FROM stashitems WHERE stash = ?', {stashId})
if not result then return items end
local stashItems = json.decode(result)
if not stashItems then return items end
for _, item in pairs(stashItems) do
local itemInfo = QBCore.Shared.Items[item.name:lower()]
if itemInfo then
items[item.slot] = {
name = itemInfo["name"],
amount = tonumber(item.amount),
info = item.info or "",
label = itemInfo["label"],
description = itemInfo["description"] or "",
weight = itemInfo["weight"],
type = itemInfo["type"],
unique = itemInfo["unique"],
useable = itemInfo["useable"],
image = itemInfo["image"],
created = item.created,
slot = item.slot,
}
end
end
return items
end
exports("GetStashItems", GetStashItems)
function SaveStashItems(stashId, items)
if Stashes[stashId].label == "Stash-None" or not items then return end
for _, item in pairs(items) do
item.description = nil
end
MySQL.insert('INSERT INTO stashitems (stash, items) VALUES (:stash, :items) ON DUPLICATE KEY UPDATE items = :items', {
['stash'] = stashId,
['items'] = json.encode(items)
})
Stashes[stashId].isOpen = false
end
exports("SaveStashItems",SaveStashItems)
function AddToStash(stashId, slot, otherslot, itemName, amount, info, created)
amount = tonumber(amount) or 1
local ItemData = QBCore.Shared.Items[itemName]
local totalWeight = GetTotalWeight(Stashes[stashId].items)
local maxwh = Stashes[stashId].maxweight or Config.StashSize.maxweight
if (totalWeight + (ItemData['weight'] * amount)) <= maxwh then
if not ItemData.unique then
if Stashes[stashId].items[slot] and Stashes[stashId].items[slot].name == itemName then
Stashes[stashId].items[slot].amount = Stashes[stashId].items[slot].amount + amount
else
local itemInfo = QBCore.Shared.Items[itemName:lower()]
Stashes[stashId].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"],
created = created,
slot = slot,
}
end
else
if Stashes[stashId].items[slot] and Stashes[stashId].items[slot].name == itemName then
local itemInfo = QBCore.Shared.Items[itemName:lower()]
Stashes[stashId].items[otherslot] = {
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"],
created = created,
slot = otherslot,
}
else
local itemInfo = QBCore.Shared.Items[itemName:lower()]
Stashes[stashId].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"],
created = created,
slot = slot,
}
end
end
else
exports['qb-inventory']:spawnOnGround(source, ItemData, amount, info, created)
QBCore.Functions.Notify(source, ItemData['label']..Lang:t("notify.ground_item"), 'error')
end
if stashId:find("Item") ~= nil then
SaveStashItems(stashId, Stashes[stashId].items)
end
end
exports('addStashItem', AddToStash)
function RemoveFromStash(stashId, slot, itemName, amount)
amount = tonumber(amount) or 1
if Stashes[stashId].items[slot] and Stashes[stashId].items[slot].name == itemName then
if Stashes[stashId].items[slot].amount > amount then
Stashes[stashId].items[slot].amount = Stashes[stashId].items[slot].amount - amount
else
Stashes[stashId].items[slot] = nil
end
else
Stashes[stashId].items[slot] = nil
if Stashes[stashId].items == nil then
Stashes[stashId].items[slot] = nil
end
end
end
exports('RemoveFromStash', RemoveFromStash)
function GetOwnedVehicleItems(plate)
local items = {}
local result = MySQL.scalar.await('SELECT items FROM trunkitems WHERE plate = ?', {plate})
if not result then return items end
local trunkItems = json.decode(result)
if not trunkItems then return items end
for _, item in pairs(trunkItems) do
local itemInfo = QBCore.Shared.Items[item.name:lower()]
if itemInfo then
items[item.slot] = {
name = itemInfo["name"],
amount = tonumber(item.amount),
info = item.info or "",
label = itemInfo["label"],
description = itemInfo["description"] or "",
weight = itemInfo["weight"],
type = itemInfo["type"],
unique = itemInfo["unique"],
useable = itemInfo["useable"],
image = itemInfo["image"],
created = item.created,
slot = item.slot,
}
end
end
return items
end
function SaveOwnedVehicleItems(plate, items)
if Trunks[plate].label == "Trunk-None" or not items then return end
for _, item in pairs(items) do
item.description = nil
end
MySQL.insert('INSERT INTO trunkitems (plate, items) VALUES (:plate, :items) ON DUPLICATE KEY UPDATE items = :items', {
['plate'] = plate,
['items'] = json.encode(items)
})
Trunks[plate].isOpen = false
end
function AddToTrunk(plate, slot, otherslot, itemName, amount, info, created)
amount = tonumber(amount) or 1
local ItemData = QBCore.Shared.Items[itemName]
local totalWeight = GetTotalWeight(Trunks[plate].items)
if (totalWeight + (ItemData['weight'] * amount)) <= Trunks[plate].maxweight then
if not ItemData.unique then
if Trunks[plate].items[slot] and Trunks[plate].items[slot].name == itemName then
Trunks[plate].items[slot].amount = Trunks[plate].items[slot].amount + amount
else
local itemInfo = QBCore.Shared.Items[itemName:lower()]
Trunks[plate].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"],
created = created,
slot = slot,
}
end
else
if Trunks[plate].items[slot] and Trunks[plate].items[slot].name == itemName then
local itemInfo = QBCore.Shared.Items[itemName:lower()]
Trunks[plate].items[otherslot] = {
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"],
created = created,
slot = otherslot,
}
else
local itemInfo = QBCore.Shared.Items[itemName:lower()]
Trunks[plate].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"],
created = created,
slot = slot,
}
end
end
else
exports['qb-inventory']:spawnOnGround(source, ItemData, amount, info, created)
QBCore.Functions.Notify(source, ItemData['label']..Lang:t("notify.ground_item"), 'error')
end
end
function RemoveFromTrunk(plate, slot, itemName, amount)
amount = tonumber(amount) or 1
if Trunks[plate].items[slot] and Trunks[plate].items[slot].name == itemName then
if Trunks[plate].items[slot].amount > amount then
Trunks[plate].items[slot].amount = Trunks[plate].items[slot].amount - amount
else
Trunks[plate].items[slot] = nil
end
else
Trunks[plate].items[slot] = nil
if Trunks[plate].items == nil then
Trunks[plate].items[slot] = nil
end
end
end
function GetOwnedVehicleGloveboxItems(plate)
local items = {}
local result = MySQL.scalar.await('SELECT items FROM gloveboxitems WHERE plate = ?', {plate})
if not result then return items end
local gloveboxItems = json.decode(result)
if not gloveboxItems then return items end
for _, item in pairs(gloveboxItems) do
local itemInfo = QBCore.Shared.Items[item.name:lower()]
if itemInfo then
items[item.slot] = {
name = itemInfo["name"],
amount = tonumber(item.amount),
info = item.info or "",
label = itemInfo["label"],
description = itemInfo["description"] or "",
weight = itemInfo["weight"],
type = itemInfo["type"],
unique = itemInfo["unique"],
useable = itemInfo["useable"],
image = itemInfo["image"],
created = item.created,
slot = item.slot,
}
end
end
return items
end
function CreateDropId()
if Drops then
local id = math.random(10000, 99999)
local dropid = id
while Drops[dropid] do
id = math.random(10000, 99999)
dropid = id
end
return dropid
else
local id = math.random(10000, 99999)
local dropid = id
return dropid
end
end
function spawnOnGround(source, itemData, itemAmount, info, created)
local coords = GetEntityCoords(GetPlayerPed(source))
local itemInfo = QBCore.Shared.Items[itemData.name:lower()]
local dropId = CreateDropId()
local prop = nil
Drops[dropId] = {}
Drops[dropId].items = {}
uniqId = math.random(10000, 99999)
Drops[dropId].items[1] = {
name = itemInfo["name"],
amount = itemAmount,
info = info or "",
created = created,
label = itemInfo["label"],
description = itemInfo["description"] ~= nil and itemInfo["description"] or "",
weight = itemInfo["weight"],
type = itemInfo["type"],
unique = itemInfo["unique"],
useable = itemInfo["useable"],
image = itemInfo["image"],
slot = 1,
id = dropId,
}
if itemInfo["type"] == "weapon" then
prop = GetItemProp(itemInfo["name"])
end
local Ply = QBCore.Functions.GetPlayer(source)
TriggerEvent("qb-log:server:CreateLog", "drop", "New Item Spawn as Drop", "red", "**".. GetPlayerName(source) .. "** (citizenid: *"..Ply.PlayerData.citizenid.."* | id: *"..source.."*) overflowed inventory into drop; name: **"..itemData.name.."**, amount: **" .. itemAmount .. "**")
TriggerClientEvent('inventory:client:AddDropItem', source, dropId, source, coords,Drops[dropId].items[1], uniqId,itemInfo['name'],itemAmount,1,itemData.info,created,nil,true)
end
function CreateNewDrop(source, fromSlot, toSlot, itemAmount,setType,created)
if toSlot == nil then
toSlot = 1
end
itemAmount = tonumber(itemAmount) or 1
local itemData = GetItemBySlot(source, fromSlot)
if not itemData then return end
local coords = GetEntityCoords(GetPlayerPed(source))
if setType == "give" then
if RemoveItem(source, itemData.name, itemAmount, itemData.slot) then
TriggerClientEvent('inventory:client:CheckWeapon', source, itemData.name)
local itemInfo = QBCore.Shared.Items[itemData.name:lower()]
local dropId = CreateDropId()
Drops[dropId] = {}
Drops[dropId].coords = coords
Drops[dropId].createdTime = os.time()
Drops[dropId].items = {}
uniqId = math.random(10000, 99999)
Drops[dropId].items[toSlot] = {
name = itemInfo['name'],
amount = itemAmount,
info = itemData.info or '',
label = itemInfo['label'],
description = itemInfo['description'] or '',
weight = itemInfo['weight'],
type = itemInfo['type'],
unique = itemInfo['unique'],
useable = itemInfo['useable'],
image = itemInfo['image'],
slot = toSlot,
created = created,
removeSlot = fromSlot,
id = dropId,
objectName = itemInfo['objectName'],
uniqId = uniqId,
}
-- TriggerEvent('qb-log:server:CreateLog', 'drop', 'New Item Drop', 'red', '**' .. GetPlayerName(source) .. '** (citizenid: *' .. GetIdentifier(source) .. '* | id: *' .. source .. '*) dropped new item; name: **' .. itemData.name .. '**, amount: **' .. itemAmount .. '**')
TriggerClientEvent('inventory:client:DropItemAnim', source)
TriggerClientEvent('inventory:client:AddDropItem', source, dropId, source, coords,Drops[dropId].items[toSlot], uniqId,itemInfo['name'],itemAmount,nil,itemData.info,created,nil,nil,fromSlot)
if itemData.name:lower() == 'radio' then
TriggerClientEvent('Radio.Set', source, false)
end
else
QBCore.Functions.Notify(source, Lang:t("notify.not_have_item"), "error")
end
else
if RemoveItem(source, itemData.name, itemAmount, itemData.slot) then
TriggerClientEvent('inventory:client:CheckWeapon', source, itemData.name)
local itemInfo = QBCore.Shared.Items[itemData.name:lower()]
local dropId = CreateDropId()
Drops[dropId] = {}
Drops[dropId].coords = coords
Drops[dropId].createdTime = os.time()
Drops[dropId].items = {}
uniqId = math.random(10000, 99999)
Drops[dropId].items[toSlot] = {
name = itemInfo['name'],
amount = itemAmount,
info = itemData.info or '',
label = itemInfo['label'],
description = itemInfo['description'] or '',
weight = itemInfo['weight'],
type = itemInfo['type'],
unique = itemInfo['unique'],
useable = itemInfo['useable'],
image = itemInfo['image'],
slot = toSlot,
created = created,
id = dropId,
objectName = itemInfo['objectName'],
uniqId = uniqId,
}
-- TriggerEvent('qb-log:server:CreateLog', 'drop', 'New Item Drop', 'red', '**' .. GetPlayerName(source) .. '** (citizenid: *' .. GetIdentifier(source) .. '* | id: *' .. source .. '*) dropped new item; name: **' .. itemData.name .. '**, amount: **' .. itemAmount .. '**')
TriggerClientEvent('inventory:client:DropItemAnim', source)
TriggerClientEvent('inventory:client:AddDropItem', source, dropId, source, coords,Drops[dropId].items[toSlot], uniqId,itemInfo['name'],itemAmount,nil,itemData.info,created)
if itemData.name:lower() == 'radio' then
TriggerClientEvent('Radio.Set', source, false)
end
else
QBCore.Functions.Notify(source, Lang:t("notify.not_have_item"), "error")
end
end
end
exports("spawnOnGround", spawnOnGround)
RegisterNetEvent('inventory:server:OpenInventory', function(name, id, other,addon)
local src = source
local add = false
local ply = Player(src)
local Player = QBCore.Functions.GetPlayer(src)
if not ply.state.inv_busy then
if name and id then
local secondInv = {}
if name == "stash" then
if Stashes[id] then
if Stashes[id].isOpen then
local Target = QBCore.Functions.GetPlayer(Stashes[id].isOpen)
if Target then
TriggerClientEvent('inventory:client:CheckOpenState', Stashes[id].isOpen, name, id, Stashes[id].label)
else
Stashes[id].isOpen = false
end
end
end
local maxweight = 1000000
local slots = 50
if other then
maxweight = other.maxweight or 1000000
slots = other.slots or 50
secondInv.secretid = other.secretid
end
if QBCore.Shared.SplitStr(id, "_")[1] == "Jewelry" then
secondInv.name = "stash-"..id
secondInv.label = "Jewelry"
secondInv.maxweight = maxweight
secondInv.inventory = {}
secondInv.slots = slots
elseif (QBCore.Shared.SplitStr(id, " ")[1]) == "Dumpster" then
secondInv.name = "stash-"..id
secondInv.label = id
secondInv.maxweight = maxweight
secondInv.inventory = {}
secondInv.slots = slots
elseif QBCore.Shared.SplitStr(id, "_")[1] == "Armor" then
secondInv.name = "stash-"..id
secondInv.label = "Armor"
secondInv.maxweight = maxweight
secondInv.inventory = {}
secondInv.slots = slots
else
secondInv.name = "stash-"..id
secondInv.label = "Stash-"..id
secondInv.maxweight = maxweight
secondInv.inventory = {}
secondInv.slots = slots
end
if Stashes[id] and Stashes[id].isOpen and not addon == true then
secondInv.name = "none-inv"
secondInv.label = "Stash-None"
secondInv.maxweight = 1000000
secondInv.inventory = {}
secondInv.slots = 0
else
local stashItems = GetStashItems(id)
if next(stashItems) then
secondInv.inventory = stashItems
Stashes[id] = {}
Stashes[id].items = stashItems
Stashes[id].isOpen = src
Stashes[id].label = secondInv.label
Stashes[id].maxweight = secondInv.maxweight
else
Stashes[id] = {}
Stashes[id].items = {}
Stashes[id].isOpen = src
Stashes[id].label = secondInv.label
Stashes[id].maxweight = secondInv.maxweight
end
end
elseif name == "trunk" then
if Trunks[id] then
if Trunks[id].isOpen then
local Target = QBCore.Functions.GetPlayer(Trunks[id].isOpen)
if Target then
TriggerClientEvent('inventory:client:CheckOpenState', Trunks[id].isOpen, name, id, Trunks[id].label)
else
Trunks[id].isOpen = false
end
end
end
secondInv.name = "trunk-"..id
secondInv.label = "Trunk-"..id
secondInv.maxweight = other.maxweight or 60000
secondInv.inventory = {}
secondInv.slots = other.slots or 50
if (Trunks[id] and Trunks[id].isOpen) or (QBCore.Shared.SplitStr(id, "PLZI")[2] and Player.PlayerData.job.name ~= "police") then
secondInv.name = "none-inv"
secondInv.label = "Trunk-None"
secondInv.maxweight = other.maxweight or 60000
secondInv.inventory = {}
secondInv.slots = 0
else
if id then
local ownedItems = GetOwnedVehicleItems(id)
if Trunks[id] and not Trunks[id].isOpen then
secondInv.inventory = Trunks[id].items
Trunks[id].isOpen = src
Trunks[id].label = secondInv.label
Trunks[id].maxweight = secondInv.maxweight
elseif IsVehicleOwned(id) and next(ownedItems) then
secondInv.inventory = ownedItems
Trunks[id] = {}
Trunks[id].items = ownedItems
Trunks[id].isOpen = src
Trunks[id].label = secondInv.label
Trunks[id].maxweight = secondInv.maxweight
else
Trunks[id] = {}
Trunks[id].items = {}
Trunks[id].isOpen = src
Trunks[id].label = secondInv.label
Trunks[id].maxweight = secondInv.maxweight
end
end
end
elseif name == "glovebox" then
if Gloveboxes[id] then
if Gloveboxes[id].isOpen then
local Target = QBCore.Functions.GetPlayer(Gloveboxes[id].isOpen)
if Target then
TriggerClientEvent('inventory:client:CheckOpenState', Gloveboxes[id].isOpen, name, id, Gloveboxes[id].label)
else
Gloveboxes[id].isOpen = false
end
end
end
secondInv.name = "glovebox-"..id
secondInv.label = "Glovebox-"..id
secondInv.maxweight = 10000
secondInv.inventory = {}
secondInv.slots = 5
if Gloveboxes[id] and Gloveboxes[id].isOpen then
secondInv.name = "none-inv"
secondInv.label = "Glovebox-None"
secondInv.maxweight = 10000
secondInv.inventory = {}
secondInv.slots = 0
else
local ownedItems = GetOwnedVehicleGloveboxItems(id)
if Gloveboxes[id] and not Gloveboxes[id].isOpen then
secondInv.inventory = Gloveboxes[id].items
Gloveboxes[id].isOpen = src
Gloveboxes[id].label = secondInv.label
Gloveboxes[id].maxweight = secondInv.maxweight
elseif IsVehicleOwned(id) and next(ownedItems) then
secondInv.inventory = ownedItems
Gloveboxes[id] = {}
Gloveboxes[id].items = ownedItems
Gloveboxes[id].isOpen = src
Gloveboxes[id].label = secondInv.label
Gloveboxes[id].maxweight = secondInv.maxweight
else
Gloveboxes[id] = {}
Gloveboxes[id].items = {}
Gloveboxes[id].isOpen = src
Gloveboxes[id].label = secondInv.label
Gloveboxes[id].maxweight = secondInv.maxweight
end
end
elseif name == "shop" then
secondInv.name = "itemshop-"..id
secondInv.label = other.label
secondInv.maxweight = 900000
secondInv.inventory = SetupShopItems(other.items)
ShopItems[id] = {}
ShopItems[id].items = other.items
secondInv.slots = #other.items
elseif name == "crafting" then
secondInv.name = "crafting-"..id
craftingsItemsEmsalsiz = other
secondInv.label = other.label
secondInv.maxweight = 900000
secondInv.inventory = other.items
CraftingItems[id] = {}
CraftingItems[id].items = secondInv.inventory
secondInv.slots = #other.items
elseif name == "attachment_crafting" then
secondInv.name = "attachment_crafting-"..id
secondInv.label = other.label
secondInv.maxweight = 900000
secondInv.inventory = other.items
secondInv.slots = #other.items
CraftingItems[id] = {}
CraftingItems[id].items = secondInv.inventory
elseif name == "otherplayer" then
local OtherPlayer = QBCore.Functions.GetPlayer(tonumber(id))
if OtherPlayer then
secondInv.name = "otherplayer-"..id
secondInv.label = "Player-"..id
secondInv.maxweight = Config.MaxInventoryWeight+Config.MaxBackpackWeight+Config.MaxBodyWeight
secondInv.maxweightplayer = Config.MaxInventoryWeight
secondInv.maxweightbackpack = Config.MaxBackpackWeight
secondInv.maxweightbody = Config.MaxBodyWeight
secondInv.inventory = OtherPlayer.PlayerData.items
secondInv.slots = Config.MaxInventorySlots+Config.MaxBackpackSlots+10
secondInv.slotsplayer = Config.MaxInventorySlots
secondInv.slotsbackpack = Config.MaxBackpackSlots
Wait(250)
end
else
if Drops[id] then
if Drops[id].isOpen then
local Target = QBCore.Functions.GetPlayer(Drops[id].isOpen)
if Target then
TriggerClientEvent('inventory:client:CheckOpenState', Drops[id].isOpen, name, id, Drops[id].label)
else
Drops[id].isOpen = false
end
end
end
if Drops[id] and not Drops[id].isOpen then
secondInv.coords = Drops[id].coords
secondInv.name = id
secondInv.label = "Dropped-"..tostring(id)
secondInv.maxweight = 1000000
secondInv.inventory = Drops[id].items
secondInv.slots = 30
Drops[id].isOpen = src
Drops[id].label = secondInv.label
Drops[id].createdTime = os.time()
else
secondInv.name = "none-inv"
secondInv.label = "Dropped-None"
secondInv.maxweight = 1000000
secondInv.inventory = {}
secondInv.slots = 0
end
end
-- TriggerClientEvent("qb-inventory:client:closeinv", id)
if addon == true then
secondInv.label = "Stash-"..other.label
secondInv.itemname = other.name
TriggerClientEvent("inventory:client:OpenInventoryAddon", src, ConvertQualityAddon(src, secondInv))
else
TriggerClientEvent("inventory:client:OpenInventory", src, ConvertQuality(src, Player.PlayerData.items, secondInv))
end
else
TriggerClientEvent("inventory:client:OpenInventory", src, ConvertQuality(src, Player.PlayerData.items,nil))
end
else
QBCore.Functions.Notify(src, Lang:t("notify.no_accs"), 'error')
end
end)
RegisterNetEvent('inventory:server:SaveInventory', function(type, id)
Player(source).state.inv_busy = false
if type == "player" then
Player(id).state.inv_busy = false
TriggerClientEvent("row-inv:envanterdondur:client", id, false)
elseif type == "trunk" then
if IsVehicleOwned(id) then
SaveOwnedVehicleItems(id, Trunks[id].items)
else
Trunks[id].isOpen = false
end
elseif type == "glovebox" then
if (IsVehicleOwned(id)) then
SaveOwnedGloveboxItems(id, Gloveboxes[id].items)
else
Gloveboxes[id].isOpen = false
end
elseif type == "stash" then
SaveStashItems(id, Stashes[id].items)
elseif type == "drop" then
if Drops[id] then
Drops[id].isOpen = false
if Drops[id].items == nil or next(Drops[id].items) == nil then
Drops[id] = nil
TriggerClientEvent('emsalsiz:removetext', -1, id)
TriggerClientEvent("inventory:client:RemoveDropItem", -1, id)
end
end
end
end)
RegisterNetEvent('row-inventory:server:SetArmorOth', function(data)
TriggerClientEvent("row-inventory:client:RemoveArmor", data.id)
end)
RegisterNetEvent('inventory:server:armorupdate', function(armor)
local id = source
local Player = QBCore.Functions.GetPlayer(id)
if Player.PlayerData.items[Config.MaxInventorySlots+Config.MaxBackpackSlots+4] then
Player.PlayerData.items[Config.MaxInventorySlots+Config.MaxBackpackSlots+4].info.quality = armor
Wait(150)
Player.Functions.SetPlayerData("items", Player.PlayerData.items)
end
end)
function HasItemInStashByName(source, stashitemname, searchingitem)
local player = QBCore.Functions.GetPlayer(source)
inventory = player.PlayerData.items
for slot, itemData in pairs(inventory) do
if itemData and itemData.name then
local itemName = itemData.name:lower()
if itemName == stashitemname then
local secretid = itemData.info.secretid
if secretid then
local items = GetStashItems("Item_"..secretid)
--local items = exports["qb-inventory"]:GetStashItems("Item_"..secretid)
if items then
for _, item in pairs(items) do
if item.name:lower() == searchingitem then
return true
end
end
end
end
break
end
end
end
end
exports("HasItemInStashByName", HasItemInStashByName)
function HasItemInStashBySlot(source, stashitemslot, searchingitem)
local player = QBCore.Functions.GetPlayer(source)
inventory = player.PlayerData.items
for slot, itemData in pairs(inventory) do
if itemData and slot then
if slot == stashitemslot then
local secretid = itemData.info.secretid
if secretid then
local items = GetStashItems("Item_"..secretid)
--local items = exports["qb-inventory"]:GetStashItems("Item_"..secretid)
if items then
for _, item in pairs(items) do
if item.name:lower() == searchingitem then
return true
end
end
end
end
break
end
end
end
end
exports("HasItemInStashBySlot", HasItemInStashBySlot)
QBCore.Functions.CreateCallback('inventory:playerdead', function(_, cb, playerId)
local Player = QBCore.Functions.GetPlayer(playerId)
cb(Player.PlayerData.metadata['isdead'])
end)Last updated