forked from Simnation/Main
fix
This commit is contained in:
parent
0484090600
commit
b2139d1237
3 changed files with 197 additions and 51 deletions
|
@ -1,7 +1,7 @@
|
|||
if GetResourceState('qb-core') == 'started' then
|
||||
QBCore = exports['qb-core']:GetCoreObject()
|
||||
QBCore = exports['qb-core']:GetCoreObject()
|
||||
elseif GetResourceState('es_extended') == 'started' then
|
||||
ESX = exports['es_extended']:getSharedObject()
|
||||
ESX = exports['es_extended']:getSharedObject()
|
||||
end
|
||||
local resourceName = 'pl_printer'
|
||||
lib.versionCheck('pulsepk/pl_printer')
|
||||
|
@ -19,7 +19,7 @@ AddEventHandler('pl_printer:insertImageData', function(imageUrl, amount)
|
|||
['@image_name'] = tostring(imageName),
|
||||
['@image_link'] = imageUrl
|
||||
}, function(rowsChanged)
|
||||
|
||||
print("[DEBUG] Image saved to database: " .. imageName)
|
||||
end)
|
||||
RemovePlayerMoney(Player,account,TotalBill)
|
||||
TriggerClientEvent('pl_printer:notification',source,Locale("Money_Removed") .. TotalBill,'success')
|
||||
|
@ -31,18 +31,26 @@ AddEventHandler('pl_printer:insertImageData', function(imageUrl, amount)
|
|||
end
|
||||
end)
|
||||
|
||||
|
||||
RegisterServerEvent('pl_printer:fetchImageLink')
|
||||
AddEventHandler('pl_printer:fetchImageLink', function(imageName,playerSource)
|
||||
local hasItem = HasItem(playerSource)
|
||||
if not hasItem then return end
|
||||
AddEventHandler('pl_printer:fetchImageLink', function(imageName, playerSource)
|
||||
local src = playerSource or source
|
||||
local hasItem = HasItem(src)
|
||||
if not hasItem then
|
||||
print("[DEBUG] Player doesn't have the required item")
|
||||
return
|
||||
end
|
||||
|
||||
print("[DEBUG] Fetching image with name: " .. tostring(imageName))
|
||||
|
||||
MySQL.Async.fetchScalar('SELECT image_link FROM printer WHERE image_name = @imageName', {
|
||||
['@imageName'] = imageName
|
||||
}, function(imageLink)
|
||||
if imageLink then
|
||||
TriggerClientEvent('pl_printer:showImage',playerSource,imageLink)
|
||||
print("[DEBUG] Found image link: " .. tostring(imageLink))
|
||||
TriggerClientEvent('pl_printer:showImage', src, imageLink)
|
||||
else
|
||||
_debug('[DEBUG] '..' No Image Link Found for '..imageName..'')
|
||||
print("[DEBUG] No Image Link Found for " .. tostring(imageName))
|
||||
_debug('[DEBUG] '..' No Image Link Found for '..tostring(imageName)..'')
|
||||
end
|
||||
end)
|
||||
end)
|
||||
|
@ -54,27 +62,62 @@ function AddItem(source, amount, imageName)
|
|||
}
|
||||
if GetResourceState('qb-inventory') == 'started' then
|
||||
if lib.checkDependency('qb-inventory', '2.0.0') then
|
||||
exports['qb-inventory']:AddItem(src,Config.ItemName,amount,false,info)
|
||||
exports['qb-inventory']:AddItem(src, Config.ItemName, amount, false, info)
|
||||
TriggerClientEvent('qb-inventory:client:ItemBox', src, QBCore.Shared.Items[Config.ItemName], 'add', amount)
|
||||
else
|
||||
local Player = getPlayer(src)
|
||||
Player.Functions.AddItem(Config.ItemName, amount,false, info)
|
||||
Player.Functions.AddItem(Config.ItemName, amount, false, info)
|
||||
TriggerClientEvent('inventory:client:ItemBox', src, QBCore.Shared.Items[Config.ItemName], "add")
|
||||
end
|
||||
elseif GetResourceState('ox_inventory') == 'started' then
|
||||
exports.ox_inventory:AddItem(src,Config.ItemName,amount,imageName,false)
|
||||
exports.ox_inventory:AddItem(src, Config.ItemName, amount, {type = imageName}, false)
|
||||
elseif GetResourceState('qs-inventory') == 'started' then
|
||||
local itemMetadata ={ id = imageName }
|
||||
exports['qs-inventory']:AddItem(src,Config.ItemName,amount,false,itemMetadata)
|
||||
local itemMetadata = {id = imageName}
|
||||
exports['qs-inventory']:AddItem(src, Config.ItemName, amount, false, itemMetadata)
|
||||
end
|
||||
end
|
||||
|
||||
AddEventHandler('onServerResourceStart', function()
|
||||
-- Registriere verwendbare Items für verschiedene Frameworks
|
||||
AddEventHandler('onResourceStart', function(resourceName)
|
||||
if GetCurrentResourceName() ~= resourceName then return end
|
||||
|
||||
-- QB-Core Item Registration
|
||||
if GetResourceState('qb-core') == 'started' then
|
||||
QBCore.Functions.CreateUseableItem(Config.ItemName, function(source, item)
|
||||
local src = source
|
||||
local imageName = item.info and item.info.id
|
||||
if imageName then
|
||||
TriggerEvent('pl_printer:fetchImageLink', imageName, src)
|
||||
else
|
||||
print("[DEBUG] No image ID found in item info")
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- ESX Item Registration
|
||||
if GetResourceState('es_extended') == 'started' then
|
||||
ESX.RegisterUsableItem(Config.ItemName, function(source, item)
|
||||
local src = source
|
||||
local metadata = item.metadata or {}
|
||||
local imageName = metadata.id
|
||||
if imageName then
|
||||
TriggerEvent('pl_printer:fetchImageLink', imageName, src)
|
||||
else
|
||||
print("[DEBUG] No image ID found in item metadata")
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
-- ox_inventory export
|
||||
if GetResourceState('ox_inventory') == 'started' then
|
||||
exports(Config.ItemName,function (event,item,inventory,slot,data)
|
||||
exports(Config.ItemName, function(event, item, inventory, slot, data)
|
||||
if event == 'usingItem' then
|
||||
local item_metadata = exports.ox_inventory:GetSlot(inventory.id, slot)
|
||||
TriggerEvent('pl_printer:fetchImageLink', item_metadata.metadata.type, inventory.id)
|
||||
if item_metadata and item_metadata.metadata and item_metadata.metadata.type then
|
||||
TriggerEvent('pl_printer:fetchImageLink', item_metadata.metadata.type, inventory.id)
|
||||
else
|
||||
print("[DEBUG] No metadata type found in ox_inventory item")
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
@ -86,13 +129,7 @@ local WaterMark = function()
|
|||
print('^1['..resourceName..'] ^2If you encounter any issues please Join the discord https://discord.gg/c6gXmtEf3H to get support..^0')
|
||||
print('^1['..resourceName..'] ^2Enjoy a secret 20% OFF any script of your choice on https://pulsescripts.tebex.io/freescript^0')
|
||||
print('^1['..resourceName..'] ^2Using the coupon code: SPECIAL20 (one-time use coupon, choose wisely)^0')
|
||||
|
||||
end)
|
||||
end
|
||||
|
||||
WaterMark()
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue