1
0
Fork 0
forked from Simnation/Main

neuer printer

This commit is contained in:
Nordi98 2025-06-26 02:08:42 +02:00
parent a1e9027648
commit c917371845
33 changed files with 476 additions and 665 deletions

View file

@ -1,50 +0,0 @@
local ESX = GetResourceState('es_extended'):find('start') and exports['es_extended']:getSharedObject() or nil
if not ESX then return end
function getPlayer(target)
local xPlayer = ESX.GetPlayerFromId(target)
return xPlayer
end
function RemovePlayerMoney(Player,account,TotalBill)
if account == 'bank' then
Player.removeAccountMoney('bank', TotalBill)
elseif account == 'money' then
Player.removeAccountMoney('money', TotalBill)
end
end
function GetPlayerAccountMoney(Player,account,TotalBill)
if account == 'bank' then
if Player.getAccount('bank').money >= TotalBill then
return true
else
return false
end
elseif account == 'money' then
if Player.getAccount('money').money >= TotalBill then
return true
else
return false
end
end
return false
end
function HasItem(playerSource)
if Config.CheckItem then
local xPlayer = ESX.GetPlayerFromId(playerSource)
if not xPlayer then return false end
local item = xPlayer.getInventoryItem(Config.ItemName)
if item and item.count >= 1 then
return true
else
return false
end
else
return true
end
end

View file

@ -1,47 +0,0 @@
local QBCore = GetResourceState('qb-core'):find('start') and exports['qb-core']:GetCoreObject() or nil
if not QBCore then return end
function getPlayer(target)
local Player = QBCore.Functions.GetPlayer(target)
return Player
end
function RemovePlayerMoney(Player,account,TotalBill)
if account == 'money' then
Player.Functions.RemoveMoney('cash', TotalBill)
elseif account == 'bank' then
Player.Functions.RemoveMoney('bank', TotalBill)
end
end
function GetPlayerAccountMoney(Player,account,TotalBill)
if account == 'bank' then
if Player.PlayerData.money.bank >= TotalBill then
return true
else
return false
end
elseif account == 'money' then
if Player.PlayerData.money.cash >= TotalBill then
return true
else
return false
end
end
return false
end
function HasItem(playerSource)
if Config.CheckItem then
return exports['qb-inventory']:HasItem(playerSource,Config.ItemName,1)
else
return true
end
end
QBCore.Functions.CreateUseableItem(Config.ItemName, function(source)
local Player = QBCore.Functions.GetPlayer(source)
local item = Player.Functions.GetItemByName(Config.ItemName)
TriggerEvent('pl_printer:fetchImageLink',item.info.id,Player.PlayerData.source)
end)

View file

@ -1,98 +0,0 @@
if GetResourceState('qb-core') == 'started' then
QBCore = exports['qb-core']:GetCoreObject()
elseif GetResourceState('es_extended') == 'started' then
ESX = exports['es_extended']:getSharedObject()
end
local resourceName = 'pl_printer'
lib.versionCheck('pulsepk/pl_printer')
RegisterServerEvent('pl_printer:insertImageData')
AddEventHandler('pl_printer:insertImageData', function(imageUrl, amount)
local Player = getPlayer(source)
local account = Config.Print.Account
local TotalBill = Config.Print.Price*amount
if GetPlayerAccountMoney(Player,account,TotalBill) then
local imageName = imageUrl:match(".*/(.*)$")
AddItem(source,amount, imageName)
if imageUrl and amount then
MySQL.Async.execute('INSERT INTO printer (image_name, image_link) VALUES (@image_name, @image_link)', {
['@image_name'] = tostring(imageName),
['@image_link'] = imageUrl
}, function(rowsChanged)
end)
RemovePlayerMoney(Player,account,TotalBill)
TriggerClientEvent('pl_printer:notification',source,Locale("Money_Removed") .. TotalBill,'success')
else
_debug('[DEBUG] '..' Invalid data received for image. '..'')
end
else
TriggerClientEvent('pl_printer:notification',source,Locale("not_enough"),'error')
end
end)
RegisterServerEvent('pl_printer:fetchImageLink')
AddEventHandler('pl_printer:fetchImageLink', function(imageName,playerSource)
local hasItem = HasItem(playerSource)
if not hasItem then return end
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)
else
_debug('[DEBUG] '..' No Image Link Found for '..imageName..'')
end
end)
end)
function AddItem(source, amount, imageName)
local src = source
local info = {
id = 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)
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)
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)
elseif GetResourceState('qs-inventory') == 'started' then
local itemMetadata ={ id = imageName }
exports['qs-inventory']:AddItem(src,Config.ItemName,amount,false,itemMetadata)
end
end
AddEventHandler('onServerResourceStart', function()
if GetResourceState('ox_inventory') == 'started' then
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)
end
end)
end
end)
local WaterMark = function()
SetTimeout(1500, function()
print('^1['..resourceName..'] ^2Thank you for Downloading the Script^0')
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()