forked from Simnation/Main
fix
This commit is contained in:
parent
f653901eb9
commit
6a11ec41ca
3 changed files with 198 additions and 265 deletions
|
@ -1,158 +1,79 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<html lang="en">
|
||||||
|
<head>
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
|
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
||||||
|
<title></title>
|
||||||
|
<style>
|
||||||
|
body {
|
||||||
|
margin: 0;
|
||||||
|
padding: 0;
|
||||||
|
overflow: hidden;
|
||||||
|
background-color: rgba(0, 0, 0, 0.7);
|
||||||
|
}
|
||||||
|
#image-container {
|
||||||
|
position: absolute;
|
||||||
|
top: 50%;
|
||||||
|
left: 50%;
|
||||||
|
transform: translate(-50%, -50%);
|
||||||
|
max-width: 90%;
|
||||||
|
max-height: 90%;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
#image {
|
||||||
|
max-width: 100%;
|
||||||
|
max-height: 100%;
|
||||||
|
}
|
||||||
|
#document-id {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 10px;
|
||||||
|
left: 10px;
|
||||||
|
color: white;
|
||||||
|
background-color: rgba(0, 0, 0, 0.5);
|
||||||
|
padding: 5px;
|
||||||
|
border-radius: 3px;
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
|
}
|
||||||
|
</style>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<div id="image-container">
|
||||||
|
<img id="image" src="" alt="Document">
|
||||||
|
<div id="document-id"></div>
|
||||||
|
</div>
|
||||||
|
<script>
|
||||||
|
window.addEventListener('message', function(event) {
|
||||||
|
if (event.data.action === 'show') {
|
||||||
|
// Zeige das spezifische Dokument basierend auf der ID oder URL
|
||||||
|
document.getElementById('image').src = event.data.imageUrl;
|
||||||
|
|
||||||
local spawnedObjects = {}
|
// Zeige optional die Dokument-ID an
|
||||||
|
if (event.data.documentId) {
|
||||||
|
document.getElementById('document-id').textContent = "Dokument: " + event.data.documentId;
|
||||||
|
}
|
||||||
|
|
||||||
local imageDisplayed = false
|
document.getElementById('image-container').style.display = 'block';
|
||||||
|
|
||||||
RegisterNetEvent('pl_printer:notification')
|
// Logge die Dokument-Informationen zur Fehlersuche
|
||||||
AddEventHandler('pl_printer:notification', function(message, type)
|
console.log("Dokument angezeigt:", event.data);
|
||||||
|
} else if (event.data.action === 'hide') {
|
||||||
if Config.Notify == 'ox' then
|
document.getElementById('image-container').style.display = 'none';
|
||||||
TriggerEvent('ox_lib:notify', {description = message, type = type or "success"})
|
|
||||||
elseif Config.Notify == 'esx' then
|
|
||||||
Notification(message)
|
|
||||||
elseif Config.Notify == 'okok' then
|
|
||||||
TriggerEvent('okokNotify:Alert', message, 6000, type)
|
|
||||||
elseif Config.Notify == 'qb' then
|
|
||||||
Notification(message, type)
|
|
||||||
elseif Config.Notify == 'wasabi' then
|
|
||||||
exports.wasabi_notify:notify('Printer', message, 6000, type, false, 'fas fa-ghost')
|
|
||||||
elseif Config.Notify == 'custom' then
|
|
||||||
-- Add your custom notifications here
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
function disableControls()
|
|
||||||
SetEntityInvincible(PlayerPedId(), true)
|
|
||||||
FreezeEntityPosition(PlayerPedId(), true)
|
|
||||||
end
|
|
||||||
|
|
||||||
function enableControls()
|
|
||||||
SetEntityInvincible(PlayerPedId(), false)
|
|
||||||
FreezeEntityPosition(PlayerPedId(), false)
|
|
||||||
end
|
|
||||||
|
|
||||||
RegisterNetEvent("pl_printer:showImageQB")
|
|
||||||
AddEventHandler("pl_printer:showImageQB", function(imageName)
|
|
||||||
TriggerServerEvent('pl_printer:fetchImageLink',imageName)
|
|
||||||
end)
|
|
||||||
|
|
||||||
RegisterNetEvent("pl_printer:showImage")
|
|
||||||
AddEventHandler("pl_printer:showImage", function(imageName)
|
|
||||||
if not imageDisplayed then
|
|
||||||
imageDisplayed = true
|
|
||||||
SetNuiFocus(true, true)
|
|
||||||
SendNUIMessage({
|
|
||||||
action = "show",
|
|
||||||
imageUrl = imageName
|
|
||||||
})
|
|
||||||
disableControls()
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
RegisterNUICallback('hideFrame', function(data, cb)
|
|
||||||
imageDisplayed = false
|
|
||||||
SetNuiFocus(false, false)
|
|
||||||
enableControls()
|
|
||||||
end)
|
|
||||||
|
|
||||||
RegisterNetEvent("pl_printer:openprinter")
|
|
||||||
AddEventHandler("pl_printer:openprinter", function()
|
|
||||||
|
|
||||||
local input = lib.inputDialog('Print Menu', {
|
|
||||||
{type = 'input', label = Locale("image_link"), description = Locale("image_url"), required = true},
|
|
||||||
{type = 'number', label = Locale("copies"), description = Locale("image_url"),required = true,placeholder='1', icon = 'hashtag'},
|
|
||||||
|
|
||||||
})
|
|
||||||
if input then
|
|
||||||
if input[1] and input[2] then
|
|
||||||
TriggerServerEvent('pl_printer:insertImageData', input[1], input[2])
|
|
||||||
else
|
|
||||||
_debug('[DEBUG] '..'Invalid Input'..'')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
for _, model in ipairs(Config.PrinterModel) do
|
|
||||||
if GetResourceState('qb-target') == 'started' then
|
|
||||||
exports['qb-target']:AddTargetModel(model, {
|
|
||||||
options = {
|
|
||||||
{
|
|
||||||
icon = 'fa-solid fa-print',
|
|
||||||
label = Locale("prints"),
|
|
||||||
action = function(data)
|
|
||||||
TriggerEvent('pl_printer:openprinter')
|
|
||||||
end,
|
|
||||||
},
|
|
||||||
},
|
|
||||||
distance = 2
|
|
||||||
})
|
|
||||||
elseif GetResourceState('qtarget') == 'started' or GetResourceState('ox_target') == 'started'then
|
|
||||||
exports.ox_target:addModel(model, {
|
|
||||||
{
|
|
||||||
name = 'printer_interaction',
|
|
||||||
label = Locale("prints"),
|
|
||||||
icon = 'fa-solid fa-print',
|
|
||||||
onSelect = function(data)
|
|
||||||
TriggerEvent('pl_printer:openprinter')
|
|
||||||
end,
|
|
||||||
distance = 2,
|
|
||||||
}
|
}
|
||||||
})
|
});
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
document.addEventListener("keydown", function(event) {
|
||||||
local function spawnObject(object, coords, heading)
|
if (event.key === "Escape") {
|
||||||
lib.requestModel(object)
|
document.getElementById('image-container').style.display = 'none';
|
||||||
|
axios.post(`https://${GetParentResourceName()}/hideFrame`, {})
|
||||||
if not HasModelLoaded(object) then
|
.then(function (response) {
|
||||||
_debug('[DEBUG] '..object..' failed to load.'..'')
|
console.log("Frame versteckt");
|
||||||
return
|
})
|
||||||
end
|
.catch(function (error) {
|
||||||
local entity = CreateObject(object, coords.x, coords.y, coords.z, true, true, true)
|
console.error("Fehler beim Verstecken des Frames:", error);
|
||||||
|
});
|
||||||
if DoesEntityExist(entity) then
|
}
|
||||||
SetEntityHeading(entity, heading)
|
});
|
||||||
FreezeEntityPosition(entity, true)
|
</script>
|
||||||
table.insert(spawnedObjects, entity)
|
</body>
|
||||||
else
|
</html>
|
||||||
_debug('[DEBUG] '..' Failed to spawn object: '..object..'')
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
local function deleteSpawnedObjects()
|
|
||||||
for _, obj in ipairs(spawnedObjects) do
|
|
||||||
if DoesEntityExist(obj) then
|
|
||||||
DeleteObject(obj)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
spawnedObjects = {}
|
|
||||||
end
|
|
||||||
|
|
||||||
|
|
||||||
AddEventHandler('onResourceStart', function(resourceName)
|
|
||||||
if GetCurrentResourceName() ~= resourceName then return end
|
|
||||||
for _, location in ipairs(Config.Locations) do
|
|
||||||
spawnObject(location.object, location.coords, location.heading)
|
|
||||||
end
|
|
||||||
end)
|
|
||||||
|
|
||||||
|
|
||||||
AddEventHandler('onResourceStop', function(resourceName)
|
|
||||||
if GetCurrentResourceName() ~= resourceName then return end
|
|
||||||
deleteSpawnedObjects()
|
|
||||||
end)
|
|
||||||
|
|
||||||
function onPlayerLoaded()
|
|
||||||
Wait(3000)
|
|
||||||
for _, location in ipairs(Config.Locations) do
|
|
||||||
spawnObject(location.object, location.coords, location.heading)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
||||||
function _debug(...)
|
|
||||||
if Config.Debug then
|
|
||||||
print(...)
|
|
||||||
end
|
|
||||||
end
|
|
||||||
|
|
|
@ -1,98 +1,79 @@
|
||||||
if GetResourceState('qb-core') == 'started' then
|
<!DOCTYPE html>
|
||||||
QBCore = exports['qb-core']:GetCoreObject()
|
<html lang="en">
|
||||||
elseif GetResourceState('es_extended') == 'started' then
|
<head>
|
||||||
ESX = exports['es_extended']:getSharedObject()
|
<meta charset="UTF-8">
|
||||||
end
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
local resourceName = 'pl_printer'
|
<script src="https://cdn.jsdelivr.net/npm/axios/dist/axios.min.js"></script>
|
||||||
lib.versionCheck('pulsepk/pl_printer')
|
<title></title>
|
||||||
|
<style>
|
||||||
RegisterServerEvent('pl_printer:insertImageData')
|
body {
|
||||||
AddEventHandler('pl_printer:insertImageData', function(imageUrl, amount)
|
margin: 0;
|
||||||
local Player = getPlayer(source)
|
padding: 0;
|
||||||
local account = Config.Print.Account
|
overflow: hidden;
|
||||||
local TotalBill = Config.Print.Price*amount
|
background-color: rgba(0, 0, 0, 0.7);
|
||||||
if GetPlayerAccountMoney(Player,account,TotalBill) then
|
}
|
||||||
local imageName = imageUrl:match(".*/(.*)$")
|
#image-container {
|
||||||
AddItem(source,amount, imageName)
|
position: absolute;
|
||||||
if imageUrl and amount then
|
top: 50%;
|
||||||
MySQL.Async.execute('INSERT INTO printer (image_name, image_link) VALUES (@image_name, @image_link)', {
|
left: 50%;
|
||||||
['@image_name'] = tostring(imageName),
|
transform: translate(-50%, -50%);
|
||||||
['@image_link'] = imageUrl
|
max-width: 90%;
|
||||||
}, function(rowsChanged)
|
max-height: 90%;
|
||||||
|
display: none;
|
||||||
end)
|
}
|
||||||
RemovePlayerMoney(Player,account,TotalBill)
|
#image {
|
||||||
TriggerClientEvent('pl_printer:notification',source,Locale("Money_Removed") .. TotalBill,'success')
|
max-width: 100%;
|
||||||
else
|
max-height: 100%;
|
||||||
_debug('[DEBUG] '..' Invalid data received for image. '..'')
|
}
|
||||||
end
|
#document-id {
|
||||||
else
|
position: absolute;
|
||||||
TriggerClientEvent('pl_printer:notification',source,Locale("not_enough"),'error')
|
bottom: 10px;
|
||||||
end
|
left: 10px;
|
||||||
end)
|
color: white;
|
||||||
|
background-color: rgba(0, 0, 0, 0.5);
|
||||||
|
padding: 5px;
|
||||||
RegisterServerEvent('pl_printer:fetchImageLink')
|
border-radius: 3px;
|
||||||
AddEventHandler('pl_printer:fetchImageLink', function(imageName,playerSource)
|
font-family: Arial, sans-serif;
|
||||||
local hasItem = HasItem(playerSource)
|
}
|
||||||
if not hasItem then return end
|
</style>
|
||||||
MySQL.Async.fetchScalar('SELECT image_link FROM printer WHERE image_name = @imageName', {
|
</head>
|
||||||
['@imageName'] = imageName
|
<body>
|
||||||
}, function(imageLink)
|
<div id="image-container">
|
||||||
if imageLink then
|
<img id="image" src="" alt="Document">
|
||||||
TriggerClientEvent('pl_printer:showImage',playerSource,imageLink)
|
<div id="document-id"></div>
|
||||||
else
|
</div>
|
||||||
_debug('[DEBUG] '..' No Image Link Found for '..imageName..'')
|
<script>
|
||||||
end
|
window.addEventListener('message', function(event) {
|
||||||
end)
|
if (event.data.action === 'show') {
|
||||||
end)
|
// Zeige das spezifische Dokument basierend auf der ID oder URL
|
||||||
|
document.getElementById('image').src = event.data.imageUrl;
|
||||||
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()
|
|
||||||
|
|
||||||
|
|
||||||
|
// Zeige optional die Dokument-ID an
|
||||||
|
if (event.data.documentId) {
|
||||||
|
document.getElementById('document-id').textContent = "Dokument: " + event.data.documentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('image-container').style.display = 'block';
|
||||||
|
|
||||||
|
// Logge die Dokument-Informationen zur Fehlersuche
|
||||||
|
console.log("Dokument angezeigt:", event.data);
|
||||||
|
} else if (event.data.action === 'hide') {
|
||||||
|
document.getElementById('image-container').style.display = 'none';
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
document.addEventListener("keydown", function(event) {
|
||||||
|
if (event.key === "Escape") {
|
||||||
|
document.getElementById('image-container').style.display = 'none';
|
||||||
|
axios.post(`https://${GetParentResourceName()}/hideFrame`, {})
|
||||||
|
.then(function (response) {
|
||||||
|
console.log("Frame versteckt");
|
||||||
|
})
|
||||||
|
.catch(function (error) {
|
||||||
|
console.error("Fehler beim Verstecken des Frames:", error);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
|
|
|
@ -10,39 +10,70 @@
|
||||||
margin: 0;
|
margin: 0;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
|
background-color: rgba(0, 0, 0, 0.7);
|
||||||
}
|
}
|
||||||
#image {
|
#image-container {
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top: 50%;
|
top: 50%;
|
||||||
left: 50%;
|
left: 50%;
|
||||||
transform: translate(-50%, -50%);
|
transform: translate(-50%, -50%);
|
||||||
max-width: 90%;
|
max-width: 90%;
|
||||||
max-height: 90%;
|
max-height: 90%;
|
||||||
|
display: none;
|
||||||
|
}
|
||||||
|
#image {
|
||||||
|
max-width: 100%;
|
||||||
|
max-height: 100%;
|
||||||
|
}
|
||||||
|
#document-id {
|
||||||
|
position: absolute;
|
||||||
|
bottom: 10px;
|
||||||
|
left: 10px;
|
||||||
|
color: white;
|
||||||
|
background-color: rgba(0, 0, 0, 0.5);
|
||||||
|
padding: 5px;
|
||||||
|
border-radius: 3px;
|
||||||
|
font-family: Arial, sans-serif;
|
||||||
}
|
}
|
||||||
</style>
|
</style>
|
||||||
</head>
|
</head>
|
||||||
<body>
|
<body>
|
||||||
<img id="image" src="" alt="Image" style="display:none;">
|
<div id="image-container">
|
||||||
|
<img id="image" src="" alt="Document">
|
||||||
|
<div id="document-id"></div>
|
||||||
|
</div>
|
||||||
<script>
|
<script>
|
||||||
window.addEventListener('message', function(event) {
|
window.addEventListener('message', function(event) {
|
||||||
if (event.data.action === 'show') {
|
if (event.data.action === 'show') {
|
||||||
|
// Zeige das spezifische Dokument basierend auf der ID oder URL
|
||||||
document.getElementById('image').src = event.data.imageUrl;
|
document.getElementById('image').src = event.data.imageUrl;
|
||||||
document.getElementById('image').style.display = 'block';
|
|
||||||
|
// Zeige optional die Dokument-ID an
|
||||||
|
if (event.data.documentId) {
|
||||||
|
document.getElementById('document-id').textContent = "Dokument: " + event.data.documentId;
|
||||||
|
}
|
||||||
|
|
||||||
|
document.getElementById('image-container').style.display = 'block';
|
||||||
|
|
||||||
|
// Logge die Dokument-Informationen zur Fehlersuche
|
||||||
|
console.log("Dokument angezeigt:", event.data);
|
||||||
} else if (event.data.action === 'hide') {
|
} else if (event.data.action === 'hide') {
|
||||||
document.getElementById('image').style.display = 'none';
|
document.getElementById('image-container').style.display = 'none';
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
document.addEventListener("keydown", function(event) {
|
document.addEventListener("keydown", function(event) {
|
||||||
if (event.key === "Escape") {
|
if (event.key === "Escape") {
|
||||||
document.getElementById('image').style.display = 'none';
|
document.getElementById('image-container').style.display = 'none';
|
||||||
axios.post(`https://${GetParentResourceName()}/hideFrame`, {})
|
axios.post(`https://${GetParentResourceName()}/hideFrame`, {})
|
||||||
.then(function (response) {
|
.then(function (response) {
|
||||||
})
|
console.log("Frame versteckt");
|
||||||
.catch(function (error) {
|
})
|
||||||
});
|
.catch(function (error) {
|
||||||
}
|
console.error("Fehler beim Verstecken des Frames:", error);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
</script>
|
</script>
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue