This commit is contained in:
Nordi98 2025-07-09 19:36:36 +02:00
parent 7f26844507
commit a2990fe815
120 changed files with 0 additions and 0 deletions

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,244 @@
local adminPerm = config.tgiannServer and { "tgi" } or config.framework == "qb" and "god" or "admin"
tgiCore.CommandsAdd(config.commands.admin.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 src = source
local id = tonumber(args[1])
local Player = config.tgiannServer and tgiCore.getPlayerById(id) or tgiCore.getPlayer(id)
local amount = tonumber(args[3]) or 1
local itemData = itemList[tostring(args[2]):lower()]
if not Player then return tgiCore.notif(src, "Player Offline", "error") end
local targetSrc = tgiCore.getSource(Player)
if not itemData then return tgiCore.notif(src, "There is no such item", "error") end
if not AddItem(targetSrc, itemData.name, amount) then return tgiCore.notif(src, "Player Is Full", "error") end
tgiCore.notif(src, "Item Given ID:" .. tgiCore.getCid(Player) .. " | " .. amount .. "x " .. itemData.name .. "", "success")
TriggerEvent("tgiann-core:discordLog", webhooks.adminLog, string.format("/giveitem %s %s %s", id, args[2], amount), src, targetSrc)
end, adminPerm)
tgiCore.CommandsAdd(config.commands.admin.setitem, "Set 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 src = source
local id = tonumber(args[1])
local Player = config.tgiannServer and tgiCore.getPlayerById(id) or tgiCore.getPlayer(id)
local amount = tonumber(args[3]) or 1
local itemData = itemList[tostring(args[2]):lower()]
if not Player then return tgiCore.notif(src, "Player Offline", "error") end
local targetSrc = tgiCore.getSource(Player)
local pInventory = GetInventory(targetSrc, "player")
if not itemData then return tgiCore.notif(src, "There is no such item", "error") end
if not pInventory.Functions.SetItem(itemData.name, amount) then return tgiCore.notif(src, "Player Is Full", "error") end
pInventory.Functions.Save()
tgiCore.notif(src, "Item Given ID:" .. tgiCore.getCid(Player) .. " | " .. amount .. "x " .. itemData.name .. "", "success")
TriggerEvent("tgiann-core:discordLog", webhooks.adminLog, string.format("/giveitem %s %s %s", id, args[2], amount), src, targetSrc)
end, adminPerm)
tgiCore.CommandsAdd(config.commands.admin.clearinv, 'Clear Players Inventory (Admin Only)', { { name = 'id', help = 'Player ID' } }, false, function(source, args)
local src = source
if args[1] then
local Player = config.tgiannServer and tgiCore.getPlayerById(tonumber(args[1])) or tgiCore.getPlayer(tonumber(args[1]))
if Player then
local targetSrc = tgiCore.getSource(Player)
local pInventory = GetInventory(targetSrc, "player")
pInventory.Functions.ClearInventory()
tgiCore.notif(src, "Player's Inventory Deleted", "error")
TriggerEvent("tgiann-core:discordLog", webhooks.adminLog, string.format("/clearinv %s (Target Online)", args[1]), src, targetSrc)
else
local row = MySQL.single.await('SELECT `inventory`, `citizenid` FROM `tgiann_inventory_player` WHERE `citizenid` = ? LIMIT 1', { args[1] })
if row then
MySQL.update('UPDATE tgiann_inventory_player SET inventory = ? WHERE citizenid = ?', { "[]", row.citizenid })
tgiCore.notif(src, "Player's Inventory Deleted", "error")
TriggerEvent("tgiann-core:discordLog", webhooks.adminLog, string.format("/clearinv %s (Target Offline)", args[1]), src)
else
tgiCore.notif(src, "There is no such player", "error")
end
end
else
local Player = tgiCore.getPlayer(src)
if not Player then return tgiCore.notif(src, "Player Offline", "error") end
local pInventory = GetInventory(tgiCore.getSource(Player), "player")
pInventory.Functions.ClearInventory()
TriggerEvent("tgiann-core:discordLog", webhooks.adminLog, "/clearinv (Self Inventory)", src)
end
end, adminPerm)
tgiCore.CommandsAdd(config.commands.admin.backpack, "Set Backpack Level", { { name = "id", help = "Player ID" }, { name = "level", help = "1-2-3" } }, true, function(source, args)
local src = source
local backpack = tonumber(args[2])
if not backpack then return tgiCore.notif(src, "You Have To Write a Level", "error") end
local max = #config.backpack
if backpack <= 0 and backpack > max then return tgiCore.notif(src, string.format("Backpack Level Can Be Max %s Min 1", max), "error") end
local xPlayer = config.tgiannServer and tgiCore.getPlayerById(tonumber(args[1])) or tgiCore.getPlayer(tonumber(args[1]))
if not xPlayer then return tgiCore.notif(src, "Player Offline", "error") end
local targetSrc = tgiCore.getSource(xPlayer)
MySQL.insert('INSERT INTO tgiann_inventory_player (citizenid, lvl) VALUES (:citizenid, :lvl) ON DUPLICATE KEY UPDATE citizenid = :citizenid, lvl = :lvl', {
citizenid = tgiCore.getCid(xPlayer),
lvl = backpack,
})
local pInventory = GetInventory(targetSrc, "player")
if pInventory then
local data = config.backpack[backpack]
pInventory.Functions.UpdateData({
MaxSlots = data.slots,
MaxWeight = data.weight
})
end
tgiCore.notif(src, "Backpack Level Seted", "success")
TriggerEvent("tgiann-core:discordLog", webhooks.adminLog, string.format("/backpack %s %s", args[1], backpack), src, targetSrc)
end, adminPerm)
tgiCore.CommandsAdd(config.commands.admin.deleteinv, "Deletes Inventory", { { name = "id", help = "Inventory Name/Plate" }, { name = "invType", help = "Inventory Type(trunk, glovebox, stash)" } }, true, function(source, args)
local src = source
local invType = args[2]
local invId = args[1]
if DeleteInventory(invType, invId) then
tgiCore.notif(src, "Inventory Deleted! " .. secondInventoryId, "success")
TriggerEvent("tgiann-core:discordLog", webhooks.adminLog, string.format("/deleteinv %s %s", invType, invId), src)
else
tgiCore.notif(src, "There Is No Such Inventory!", "error")
end
end, adminPerm)
tgiCore.CommandsAdd(config.commands.admin.openinv, "Open a Inventory", { { name = "id", help = "Inventory Name/Plate" }, { name = "invType", help = "Inventory Type(trunk, glovebox, stash)" } }, true, function(source, args)
local src = source
local invType = args[2]
local invId = args[1]
OpenInventory(src, invType, invId, {
maxweight = 999999999999,
slots = 1000,
})
TriggerEvent("tgiann-core:discordLog", webhooks.adminLog, string.format("/openinv %s %s", invType, invId), src)
end, adminPerm)
local checkItemAmount = 0
local checkItemTotalAmount = 0
local function checkItemListAdd(name, amount, findItem)
if name == findItem then
checkItemAmount = checkItemAmount + amount
end
end
local function checkItemListPrint(inventoryType, inventoryName, findItem, findAmount)
if checkItemAmount > findAmount then
tgiCore.DebugLog(string.format("Env Type: %s | %s | Item: %s | Amount: %s", inventoryType, inventoryName, findItem, checkItemAmount))
checkItemTotalAmount = checkItemTotalAmount + checkItemAmount
end
checkItemAmount = 0
end
tgiCore.CommandsAdd(config.commands.admin.checkitem, "Checks One Item in All Inventories", { { name = "item", help = "Item Name" }, { name = "minamount", help = "Min Amount" } }, true, function(source, args)
local findItem = args[1]
local findAmount = tonumber(args[2])
local src = source
checkItemTotalAmount = 0
if itemList[findItem] then
local result = MySQL.query.await('SELECT inventory, citizenid, citizenid FROM tgiann_inventory_player')
if result then
for i = 1, #result do
local resultData = result[i]
resultData.inventory = json.decode(resultData.inventory)
if resultData.inventory then
for _, data in pairs(resultData.inventory) do
checkItemListAdd(data.name, data.amount, findItem)
end
checkItemListPrint("Player", resultData.citizenid, findItem, findAmount)
end
end
end
local result = MySQL.query.await('SELECT * FROM tgiann_inventory_stashitems')
if result then
for i = 1, #result do
local resultData = result[i]
resultData.items = json.decode(resultData.items)
for _, data in pairs(resultData.items) do
checkItemListAdd(data.name, data.amount, findItem)
end
checkItemListPrint("stash", resultData.stash, findItem, findAmount)
end
end
local result = MySQL.query.await('SELECT * FROM tgiann_inventory_trunkitems')
if result then
for i = 1, #result do
local resultData = result[i]
resultData.items = json.decode(resultData.items)
for _, data in pairs(resultData.items) do
checkItemListAdd(data.name, data.amount, findItem)
end
checkItemListPrint("trunk", resultData.plate, findItem, findAmount)
end
end
local result = MySQL.query.await('SELECT * FROM tgiann_inventory_gloveboxitems')
if result then
for i = 1, #result do
local resultData = result[i]
resultData.items = json.decode(resultData.items)
for _, data in pairs(resultData.items) do
checkItemListAdd(data.name, data.amount, findItem)
end
checkItemListPrint("glovebox", resultData.plate, findItem, findAmount)
end
end
--[[ local result = MySQL.query.await('SELECT id, item, amount FROM tgiann_market_sell')
if result then
for i=1, #result do
local resultData = result[i]
checkItemListAdd(resultData.item, resultData.amount, findItem)
checkItemListPrint("tgiann_market_sell", resultData.id, findItem, findAmount)
end
end
local result = MySQL.query.await('SELECT id, item, amount FROM tgiann_market_item_storage')
if result then
for i=1, #result do
local resultData = result[i]
checkItemListAdd(resultData.item, resultData.amount, findItem)
checkItemListPrint("tgiann_market_item_storage", resultData.id, findItem, findAmount)
end
end
]]
tgiCore.DebugLog(string.format("Total Amount: %s", checkItemTotalAmount))
else
tgiCore.notif(src, "There is no such item!", "error")
end
end, adminPerm)
tgiCore.CommandsAdd(config.commands.admin.items, "Lists all Items available in the server", {}, false, function(source, args)
OpenShop(source, "admin")
end, adminPerm)
-- PLAYER COMMANDS
-- https://github.com/qbcore-framework/qb-banking/blob/main/server.lua#L493
if config.commands.player.givecash.active then
tgiCore.CommandsAdd(config.commands.player.givecash.command, 'Give Cash', { { name = 'id', help = 'Player ID' }, { name = 'amount', help = 'Amount' } }, true, function(source, args)
local src = source
local xPlayer = tgiCore.getPlayer(src)
if not xPlayer then return end
local playerPed = GetPlayerPed(src)
local playerCoords = GetEntityCoords(playerPed)
local tPlayer = tgiCore.getPlayer(tonumber(args[1]))
if not tPlayer then return tgiCore.notif(src, lang.giveCashNoUser, 'error') end
local targetPed = GetPlayerPed(tonumber(args[1]))
local targetCoords = GetEntityCoords(targetPed)
local amount = tonumber(args[2])
if not amount then return tgiCore.notif(src, lang.giveCashInvalidAmount, 'error') end
if amount <= 0 then return tgiCore.notif(src, lang.giveCashInvalidAmount, 'error') end
if #(playerCoords - targetCoords) > 5 then return tgiCore.notif(src, lang.giveCashToofar, 'error') end
if tgiCore.getMoney(xPlayer, "cash") < amount then return tgiCore.notif(src, lang.giveCashNoMoney, 'error') end
tgiCore.removeMoney(xPlayer, 'cash', amount, 'cash transfer')
tgiCore.addMoney(tPlayer, 'cash', amount, 'cash transfer')
tgiCore.notif(src, string.format(lang.giveCashSuccesGive, amount), 'success')
tgiCore.notif(tgiCore.getSource(tPlayer), string.format(lang.giveCashSuccesGet, amount), 'success')
end)
end
if config.commands.player.rob.active then
tgiCore.CommandsAdd(config.commands.player.rob.command, 'Rob Closest Player', {}, false, function(source, args)
local targetPlayer = lib.callback.await("tgiann-inventory:robPlayer", source)
if not targetPlayer then return end
OpenInventoryById(source, targetPlayer, true)
end)
end

Binary file not shown.

View file

@ -0,0 +1,339 @@
-- with this command you can integrate your qb inventories into the new system
-- if you write a code for different inventories please share it with us
-- Commands only available from cmd/live consol
local function convertItemsFile()
local addedAnyItems = false
if config.framework == "qb" then
local QBCore = exports['qb-core']:GetCoreObject({ "Shared" })
local items = QBCore.Shared.Items
if items and table.type(items) ~= 'empty' then
for k, item in pairs(items) do
if type(item) == 'table' then
item.name = tgiCore.trim(string.lower(item.name or k))
if not string.find(item.name, "weapon_") and not itemsData[item.name] then
item.type = item.type or 'item'
item.image = item.image or item.name .. ".webp"
item.unique = item.unique or false
item.useable = item.useable or false
item.shouldClose = item.shouldClose or false
item.description = item.description or ""
itemsData[item.name] = item
addedAnyItems = true
end
end
end
end
elseif config.framework == "esx" then
local items = MySQL.query.await("SELECT * FROM items")
if items and table.type(items) ~= 'empty' then
for _, item in pairs(items) do
item.name = tgiCore.trim(string.lower(item.name))
if not string.find(item.name, "weapon_") and not itemsData[item.name] then
itemsData[item.name] = {
name = item.name, label = item.label, weight = item.weight, type = 'item', image = item.name .. '.webp', unique = false, useable = true, shouldClose = true, description = ''
}
addedAnyItems = true
end
end
end
end
if not addedAnyItems then
return tgiCore.DebugLog('No items added to items.lua file! Your tgiann-inventory items file already converted!')
end
local fileContent = "itemsData = " .. tgiCore.SerializeTable(itemsData)
SaveResourceFile("tgiann-inventory", 'items/items.lua', fileContent, -1)
if config.framework == "qb" then
tgiCore.DebugLog('Your items have been copied from the QBCore.Shared.Items! You should restart the resource to load the new items! You can edit your items from items/items.lua file.')
else
tgiCore.DebugLog('Your items have been copied from the items database! You should restart the resource to load the new items! You can edit your items from items/items.lua file.')
end
end
local function convertItems(items)
if not items then return "[]" end
items = json.decode(items)
if not items then return "[]" end
for _, itemData in pairs(items) do
if itemData then
itemData.info = itemData.metadata or itemData.info
itemData.amount = itemData.count or itemData.amount
if string.find(itemData.name, "weapon_") then itemData.info = nil end
end
end
return json.encode(items)
end
local function checkTableExist(table)
return MySQL.single.await("SHOW TABLES LIKE ?", { table })
end
RegisterCommand(config.commands.convert.convertItemsFile, function(source)
if source > 0 then return tgiCore.DebugErrorLog("Pls use on server cmd") end
convertItemsFile()
end)
-- Qb Inventory
RegisterCommand(config.commands.convert.convertqb, function(source)
if source > 0 then return tgiCore.DebugErrorLog("Pls use on server cmd") end
local newQb = checkTableExist("inventories")
if newQb then
local result = MySQL.query.await('SELECT * FROM inventories')
if result and #result > 0 then
for i = 1, #result do
local inventory = result[i]
local items = inventory.items
local identifier = inventory.identifier
if identifier:find('trunk-') then
MySQL.query.await('INSERT INTO `tgiann_inventory_trunkitems` (plate, items) VALUES (?, ?) ON DUPLICATE KEY UPDATE items = VALUES(items)', {
string.gsub(identifier, "trunk-", ""), items
})
elseif identifier:find('glovebox-') then
MySQL.query.await('INSERT INTO `tgiann_inventory_gloveboxitems` (plate, items) VALUES (?, ?) ON DUPLICATE KEY UPDATE items = VALUES(items)', {
string.gsub(identifier, "glovebox-", ""), items
})
else
MySQL.query.await('INSERT INTO `tgiann_inventory_stashitems` (stash, items) VALUES (?, ?) ON DUPLICATE KEY UPDATE items = VALUES(items)', {
identifier, items
})
end
end
end
tgiCore.DebugLog("New Qb inventories converted")
else
local response = MySQL.query.await('SELECT * FROM `stashitems`')
if response and next(response) then
for i = 1, #response do
MySQL.query.await('INSERT INTO `tgiann_inventory_stashitems` (stash, items) VALUES (?, ?) ON DUPLICATE KEY UPDATE items = VALUES(items)', {
response[i].stash, response[i].items
})
end
tgiCore.DebugLog("stashitems converted")
end
local response = MySQL.query.await('SELECT * FROM `trunkitems`')
if response and next(response) then
for i = 1, #response do
MySQL.query.await('INSERT INTO `tgiann_inventory_trunkitems` (plate, items) VALUES (?, ?) ON DUPLICATE KEY UPDATE items = VALUES(items)', {
response[i].plate, response[i].items
})
end
tgiCore.DebugLog("trunkitems converted")
end
local response = MySQL.query.await('SELECT * FROM `gloveboxitems`')
if response and next(response) then
for i = 1, #response do
MySQL.query.await('INSERT INTO `tgiann_inventory_gloveboxitems` (plate, items) VALUES (?, ?) ON DUPLICATE KEY UPDATE items = VALUES(items)', {
response[i].plate, response[i].items
})
end
tgiCore.DebugLog("gloveboxitems converted")
end
end
if checkTableExist("players") then
local response = MySQL.query.await('SELECT citizenid, inventory FROM `players`')
if response and next(response) then
for i = 1, #response do
if response[i].inventory then
MySQL.query.await('INSERT INTO `tgiann_inventory_player` (citizenid, inventory, clotheinventory) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE inventory = VALUES(inventory), clotheinventory = VALUES(clotheinventory)', {
response[i].citizenid, response[i].inventory, "[]"
})
end
end
tgiCore.DebugLog("Player inventorys converted")
end
end
convertItemsFile()
tgiCore.DebugLog("Finished")
end)
-- Ox Inventory
RegisterCommand(config.commands.convert.convertox, function(source)
if source > 0 then return tgiCore.DebugErrorLog("Pls use on server cmd") end
if not checkTableExist("ox_inventory") then
return tgiCore.DebugErrorLog("Ox Inventory not found")
end
local response = MySQL.query.await('SELECT name, data FROM `ox_inventory`')
if response and next(response) then
for i = 1, #response do
local owner = response[i].owner or ""
MySQL.query.await('INSERT INTO `tgiann_inventory_stashitems` (stash, items) VALUES (?, ?) ON DUPLICATE KEY UPDATE items = VALUES(items)', {
response[i].name .. "_" .. owner, convertItems(response[i].data)
})
if response[i].owner then
tgiCore.DebugWarningLog(string.format("%s Converted but u need the edit open event! When opening the stash you need to send the player id in the stash name! Example: TriggerServerEvent('inventory:server:OpenInventory', 'stash', %s_PlayerData.citizenid)", response[i].name, response[i].name))
end
end
tgiCore.DebugLog("stashitems converted")
end
if config.framework == "qb" then
local response = MySQL.query.await('SELECT glovebox, trunk, plate FROM `player_vehicles`')
if response and next(response) then
for i = 1, #response do
MySQL.query.await('INSERT INTO `tgiann_inventory_gloveboxitems` (plate, items) VALUES (?, ?) ON DUPLICATE KEY UPDATE items = VALUES(items)', {
response[i].plate, convertItems(response[i].glovebox)
})
MySQL.query.await('INSERT INTO `tgiann_inventory_trunkitems` (plate, items) VALUES (?, ?) ON DUPLICATE KEY UPDATE items = VALUES(items)', {
response[i].plate, convertItems(response[i].trunk)
})
end
tgiCore.DebugLog("gloveboxitems and trunkitems converted")
end
else
local response = MySQL.query.await('SELECT glovebox, trunk, plate FROM `owned_vehicles`')
if response and next(response) then
for i = 1, #response do
MySQL.query.await('INSERT INTO `tgiann_inventory_gloveboxitems` (plate, items) VALUES (?, ?) ON DUPLICATE KEY UPDATE items = VALUES(items)', {
response[i].plate, convertItems(response[i].glovebox)
})
MySQL.query.await('INSERT INTO `tgiann_inventory_trunkitems` (plate, items) VALUES (?, ?) ON DUPLICATE KEY UPDATE items = VALUES(items)', {
response[i].plate, convertItems(response[i].trunk)
})
end
tgiCore.DebugLog("gloveboxitems and trunkitems converted")
end
end
if config.framework == "qb" then
local response = MySQL.query.await('SELECT citizenid, inventory FROM `players`')
if response and next(response) then
for i = 1, #response do
if response[i].inventory then
MySQL.query.await('INSERT INTO `tgiann_inventory_player` (citizenid, inventory, clotheinventory) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE inventory = VALUES(inventory), clotheinventory = VALUES(clotheinventory)', {
response[i].citizenid, convertItems(response[i].inventory), "[]"
})
end
end
tgiCore.DebugLog("Player inventorys converted")
end
else
local response = MySQL.query.await('SELECT identifier, inventory FROM `users`')
if response and next(response) then
for i = 1, #response do
if response[i].inventory then
MySQL.query.await('INSERT INTO `tgiann_inventory_player` (citizenid, inventory, clotheinventory) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE inventory = VALUES(inventory), clotheinventory = VALUES(clotheinventory)', {
response[i].identifier, convertItems(response[i].inventory), "[]"
})
end
end
tgiCore.DebugLog("Player inventorys converted")
end
end
tgiCore.DebugLog("Finished")
end)
-- qs_inventory
RegisterCommand(config.commands.convert.convertqsinv, function(source)
if source > 0 then return tgiCore.DebugErrorLog("Pls use on server cmd") end
local response = MySQL.query.await('SELECT * FROM `inventory_stash`')
if response and next(response) then
for i = 1, #response do
MySQL.query.await('INSERT INTO `tgiann_inventory_stashitems` (stash, items) VALUES (?, ?) ON DUPLICATE KEY UPDATE items = VALUES(items)', {
response[i].stash, response[i].items
})
end
tgiCore.DebugLog("inventory_stash converted")
end
local response = MySQL.query.await('SELECT * FROM `inventory_trunk`')
if response and next(response) then
for i = 1, #response do
MySQL.query.await('INSERT INTO `tgiann_inventory_trunkitems` (plate, items) VALUES (?, ?) ON DUPLICATE KEY UPDATE items = VALUES(items)', {
response[i].plate, response[i].items
})
end
tgiCore.DebugLog("inventory_trunk converted")
end
local response = MySQL.query.await('SELECT * FROM `inventory_glovebox`')
if response and next(response) then
for i = 1, #response do
MySQL.query.await('INSERT INTO `tgiann_inventory_gloveboxitems` (plate, items) VALUES (?, ?) ON DUPLICATE KEY UPDATE items = VALUES(items)', {
response[i].plate, response[i].items
})
end
tgiCore.DebugLog("inventory_glovebox converted")
end
if config.framework == "qb" then
local response = MySQL.query.await('SELECT citizenid, inventory FROM `players`')
if response and next(response) then
for i = 1, #response do
if response[i].inventory then
MySQL.query.await('INSERT INTO `tgiann_inventory_player` (citizenid, inventory, clotheinventory) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE inventory = VALUES(inventory), clotheinventory = VALUES(clotheinventory)', {
response[i].citizenid, convertItems(response[i].inventory), "[]"
})
end
end
tgiCore.DebugLog("Player inventorys converted")
end
else
local response = MySQL.query.await('SELECT identifier, inventory FROM `users`')
if response and next(response) then
for i = 1, #response do
if response[i].inventory then
MySQL.query.await('INSERT INTO `tgiann_inventory_player` (citizenid, inventory, clotheinventory) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE inventory = VALUES(inventory), clotheinventory = VALUES(clotheinventory)', {
response[i].identifier, convertItems(response[i].inventory), "[]"
})
end
end
tgiCore.DebugLog("Player inventorys converted")
end
end
tgiCore.DebugLog("Finished")
end)
-- codem-inventory
RegisterCommand(config.commands.convert.convertcodeminv, function(source)
if source > 0 then return tgiCore.DebugErrorLog("Pls use on server cmd") end
local response = MySQL.query.await('SELECT * FROM `codem_new_stash`')
if response and next(response) then
for i = 1, #response do
MySQL.query.await('INSERT INTO `tgiann_inventory_stashitems` (stash, items) VALUES (?, ?) ON DUPLICATE KEY UPDATE items = VALUES(items)', {
response[i].stashname, response[i].items
})
end
tgiCore.DebugLog("codem_new_stash converted")
end
local response = MySQL.query.await('SELECT * FROM `codem_new_vehicleandglovebox`')
if response and next(response) then
for i = 1, #response do
MySQL.query.await('INSERT INTO `tgiann_inventory_gloveboxitems` (plate, items) VALUES (?, ?) ON DUPLICATE KEY UPDATE items = VALUES(items)', {
response[i].plate, response[i].glovebox
})
MySQL.query.await('INSERT INTO `tgiann_inventory_trunkitems` (plate, items) VALUES (?, ?) ON DUPLICATE KEY UPDATE items = VALUES(items)', {
response[i].plate, response[i].trunk
})
end
tgiCore.DebugLog("codem_new_vehicleandglovebox converted")
end
local response = MySQL.query.await('SELECT identifier, inventory FROM `codem_new_inventory`')
if response and next(response) then
for i = 1, #response do
if response[i].inventory then
MySQL.query.await('INSERT INTO `tgiann_inventory_player` (citizenid, inventory, clotheinventory) VALUES (?, ?, ?) ON DUPLICATE KEY UPDATE inventory = VALUES(inventory), clotheinventory = VALUES(clotheinventory)', {
response[i].identifier, convertItems(response[i].inventory), "[]"
})
end
end
tgiCore.DebugLog("Player inventorys converted")
end
tgiCore.DebugLog("Finished")
end)

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,242 @@
---@param src number
---@param banLogType "banOpenOtherPlayerInventory" | "banGiveItemSelf" | "banGiveMinusAmount" | "banRemoveMinusAmount" | "banCustomShop" | "banOpeningOtherPlayerInventoryFromDistance" | "banClientOpenInventory"
---@param msg string
function ban(src, banLogType, msg)
banLog(src, banLogType, msg)
if config.kickPlayerWhenHackingDatected then DropPlayer(tostring(src), "Cheating For Inventory System") end
--[[
-- Example ban event
TriggerClientEvent("tgiann-anticheat:ban", src, { -- Example Code
adminMessage = msg,
ban = 131487,
kickMessage = "Cheating!"
}) ]]
end
---@param plate string
---@return string | false
function isPlayerVehicle(plate)
local table = config.framework == "qb" and "player_vehicles" or "owned_vehicles"
local owner = config.framework == "qb" and "citizenid" or "owner"
local result = MySQL.single.await('SELECT ' .. owner .. ' from ' .. table .. ' WHERE plate = ?', { plate })
return result and result[owner] or false
end
---@param src number
---@return boolean
function isAdmin(src)
if config.framework == "qb" then
return IsPlayerAceAllowed(tostring(src), "command") -- refarance: https://github.com/qbcore-framework/qb-adminmenu/blob/main/server/server.lua#L52
else
local xPlayer = tgiCore.getPlayer(src)
return xPlayer.getGroup(src) == "admin"
end
end
lib.callback.register("tgiann-inventory:server:isAdmin", isAdmin)
--- @param moneyType string
--- @return boolean, string | nil
function isMoneyItem(moneyType)
if not config.moneyAsItem.active then return false end
for itemName, mType in pairs(config.moneyAsItem.items[config.framework]) do
if mType == moneyType then
return true, itemName
end
end
return false
end
exports("IsMoneyItem", isMoneyItem)
--- For money as item
---@param src number
---@param itemName string
local function setMoney(src, itemName)
if not config.moneyAsItem.active then return end
local moneyType = config.moneyAsItem.items[config.framework][itemName]
if not moneyType then return end
local pInventory = GetInventory(src, "player")
if not pInventory then return end
local xPlayer = tgiCore.getPlayer(src)
if not xPlayer then return end
local totalAmount = pInventory.Functions.GetItemTotalAmount(itemName)
if config.framework == "esx" then
xPlayer.setAccountMoney(moneyType, totalAmount, "inventory money as item", true)
elseif config.framework == "qb" then
if config.qbx then
exports["qbx_core"]:SetMoney(src, moneyType, totalAmount, "inventory money as item", true)
else
xPlayer.Functions.SetMoney(moneyType, totalAmount, "inventory money as item", true)
end
end
end
--- if the value is false, the use of the item is canceled
---@param src number
---@param itemData table
---@param itemSharedData table
---@diagnostic disable-next-line: unused-local
function useItemEditable(src, itemData, itemSharedData)
local decayableItemsData = IsDecayableItem(itemData.name)
if decayableItemsData then
local durability = itemData.info?.durability and GetDurabilityPercent(itemData.info.durability, decayableItemsData, os.time()) or 1
if durability <= 0 then
if config.removeDecayableItem then
RemoveItem(src, itemData.name, 1, itemData.slot)
end
tgiCore.notif(src, lang.cantUseThisItem, "error")
return false
end
end
if itemData.name == "myCustomUseItem" then
TriggerClientEvent('myCustomEvent', src, itemData.name)
return false -- We make it false because we do not want the main use item function to continue
end
return true
end
---@param src number
---@param itemData table
---@param amount number
function addItemDetect(src, itemData, amount)
if not itemData then return end
itemData.itemAddRemoveLog = "added"
TriggerClientEvent("tgiann-inventory:itemAddRemoveLog", src, itemData, amount)
if string.match(itemData.name:lower(), "weapon") then
TriggerClientEvent('inventory:client:addWeapon', src, true, true, itemData.slot)
else
if config.moneyAsItem.active then setMoney(src, itemData.name) end
TriggerClientEvent('tgiann-inventory:addedItem', src, itemData.name)
end
end
---@param src number
---@param itemData table
---@param amount number
function removeItemDetect(src, itemData, amount)
if not itemData then return end
itemData.itemAddRemoveLog = "removed"
TriggerClientEvent("tgiann-inventory:itemAddRemoveLog", src, itemData, amount)
if string.match(itemData.name:lower(), "weapon") then
TriggerClientEvent('inventory:client:removeWeapon', src, true, true, itemData.slot)
elseif itemData.name:lower() == "kemer" then
TriggerClientEvent('tgiann-hud:removeKemer', src)
elseif itemData.name:lower() == "megaphone" then
TriggerClientEvent('tgiann-megaphone:drop', src)
elseif itemData.name:lower() == "scooter" then
TriggerClientEvent('tgiann-scooter:drop', src)
else
if config.moneyAsItem then setMoney(src, itemData.name) end
TriggerClientEvent('tgiann-inventory:dropItem', src, itemData.name)
end
end
---@param payload { source:number, shopType: string, itemName: string, metadata: table, count:number, price: number }
function itemBought(payload)
buyItemLog(payload.shopType, payload.itemName, payload.count, payload.price, payload.source)
if config.tgiannServer and payload.shopType == "police" then
local itemName = payload.itemName
if string.find(itemName, "weapon") then
local label = itemList[itemName].label
local xPlayer = tgiCore.getPlayer(payload.source)
if not xPlayer then return end
MySQL.insert('INSERT INTO tgiann_mdt_shop (name, itemname, itemserial, time) VALUES (?, ?, ?, ?) ', { xPlayer.PlayerData.charinfo.firstname .. " " .. xPlayer.PlayerData.charinfo.lastname, label, payload.metadata.serie or "Eşya", os.time() })
end
end
end
---@param itemData table
---@param info? table
---@param Player? table
local function setQbItemInfo(itemData, info, Player)
if config.framework == "esx" then return info end
if itemData.name == "id_card" then
if Player 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
end
elseif itemData.name == "driver_license" then
if Player then
info.firstname = Player.PlayerData.charinfo.firstname
info.lastname = Player.PlayerData.charinfo.lastname
info.birthdate = Player.PlayerData.charinfo.birthdate
end
info.type = "Class C Driver License"
elseif itemData.name == "harness" then
info.uses = 20
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
return info
end
---@param itemData table
---@param info? table
---@param Player? table
function setItemInfo(itemData, info, Player)
if not info or info == "" or (type(info) == "table" and not next(info)) then
info = {}
local decayableItemsData = IsDecayableItem(itemData.name)
if itemData.name == config.jerryCan.item then
info = config.jerryCan.metadata
elseif decayableItemsData then
info.type = "decayableItems"
info.durability = os.time()
info.durabilitySecond = decayableItemsData
elseif itemData.type == 'weapon' then
info = {
serie = GetRandomItemId(),
durabilityPercent = 100,
ammo = 0,
usedTotalAmmo = 0
}
elseif GetResourceState("tgiann-food-jobs") == "started" and exports["tgiann-food-jobs"]:items()[itemData.name] and Player then
info = exports["tgiann-food-jobs"]:customItemMetadata(tgiCore.getSource(Player), tgiCore.getCid(Player))
elseif config.maxUseAmount[itemData.name] then
info.type = "maxUseAmount"
info.maxUseAmount = config.maxUseAmount[itemData.name].amount
elseif config.realisticArmor.active and config.realisticArmor.items[itemData.name] then
info.durabilityPercent = config.realisticArmor.items[itemData.name].armor
info.realisticArmor = true
else
info = setQbItemInfo(itemData, info, Player)
end
end
return info
end
for i = 1, #config.itemStash do
local stashData = config.itemStash[i]
tgiCore.CreateUseableItem(stashData.item, function(source, item)
local src = source
if openedAnySecondaryInventory(src) then
return tgiCore.notif(src, lang.closeInventoryFirst, "error", 5000)
end
if not item.info.id then
local xPlayer = tgiCore.getPlayer(src)
item.info = { id = stashData.item .. tgiCore.getCid(xPlayer) .. GetRandomItemId() }
UpdateItemMetadata(src, stashData.item, item.slot, item.info)
end
OpenInventory(src, "stash", item.info.id, {
maxweight = stashData.maxweight,
slots = stashData.slots,
whitelist = stashData.whitelist
})
end)
end

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View file

@ -0,0 +1,89 @@
webhooks = {
use = "",
giveOtherPlayer = "",
buyItem = "",
transfer = "",
delete = "",
adminLog = "",
addItem = "",
banLog = "",
dumpsterSearch = "",
-- drop when die
dropWeapon = "",
dropMoney = "",
dropItems = "", -- Also using throw item
pickUpWeapon = "",
pickUpCash = "",
pickUpItems = "", -- Also using throw item
}
-- u can edit commands logs from server/commands.lua
function dropMoneyLog(cash, src)
TriggerEvent("tgiann-core:discordLog", webhooks.dropMoney, string.format(lang.logDropMoney, cash), src)
end
function dropWeaponLog(val, src)
TriggerEvent("tgiann-core:discordLog", webhooks.dropWeapon, string.format(lang.logDropWeapon, val.namecash), src)
end
function dropItemsLog(dropItemList, src)
TriggerEvent("tgiann-core:discordLog", webhooks.dropItems, string.format("%s: %s", lang.logDropItems, json.encode(dropItemList)), src)
end
function pickUpWeaponLog(data, src)
TriggerEvent("tgiann-core:discordLog", webhooks.pickUpWeapon, string.format(lang.logGetWeapon, data.weapon.name), src)
end
function pickUpCashLog(data, src)
TriggerEvent("tgiann-core:discordLog", webhooks.pickUpCash, string.format(lang.logGetMoney, data.cash), src)
end
function pickUpItemsLog(data, src)
TriggerEvent("tgiann-core:discordLog", webhooks.pickUpItems, string.format("%s: %s", lang.logGetItems, json.encode(data.dropItemList)), src)
end
function openAdminShopLog(src)
TriggerEvent("tgiann-core:discordLog", webhooks.adminLog, "Open Admin Shop", src)
end
function giveOtherPlayer(inputVal, label, src, OtherPlayerSrc)
TriggerEvent("tgiann-core:discordLog", webhooks.giveOtherPlayer, string.format(lang.logGiveItem, inputVal, label), src, OtherPlayerSrc)
end
function buyItemLog(shopType, itemName, count, price, src)
TriggerEvent("tgiann-core:discordLog", webhooks.buyItem, string.format(lang.logBoughtItem, shopType, count, GetItemLabel(itemName), price), src)
end
function transferLog(itemName, amount, dragDataInvKeyName, dropDataInvKeyName, src)
TriggerEvent("tgiann-core:discordLog", webhooks.transfer, string.format(lang.logSwapItem, itemName, amount, dragDataInvKeyName, dropDataInvKeyName), src)
end
function addItemLog(src, itemName, amount, slot, invokingResource)
TriggerEvent("tgiann-core:discordLog", webhooks.addItem, string.format(lang.logAddItem, itemName, amount, slot, invokingResource), src)
end
function removeItemLog(src, itemName, amount, slot, invokingResource)
TriggerEvent("tgiann-core:discordLog", webhooks.removeItem, string.format(lang.logRemoveItem, itemName, amount, slot, invokingResource), src)
end
function deleteItemLog(data, src) --Not Using
TriggerEvent("tgiann-core:discordLog", webhooks.delete, string.format(lang.logDeleteItem, data.invKeyName, data.itemData.amount, GetItemLabel(data.itemData.name)), src)
end
function useLog(label, src)
TriggerEvent("tgiann-core:discordLog", webhooks.use, string.format(lang.logUseItem, label), src)
end
function dumpsterSearch(src, item, amount)
TriggerEvent("tgiann-core:discordLog", webhooks.dumpsterSearch, string.format(lang.logDumpsterSearch, item, amount), src)
end
function banLog(src, banLogType, msg)
local playerName = GetPlayerName(src) or "Unknown Player Name"
banLogType = banLogType or "Unknown Ban Type"
msg = msg or "Unknown Reason"
tgiCore.DebugErrorLog("^1[ANTICHEAT] ^0 [ " .. src .. " ]" .. playerName .. " Has been kicked for " .. msg .. " (" .. banLogType .. ")")
TriggerEvent("tgiann-core:discordLog", webhooks.banLog, msg, src)
end