Config = {}Config.Framework ='qbcore' -- 'esx' or 'qbcore'Config.Database ='oxmysql' -- 'oxmysql' or 'mysql-async' or 'ghmattimysql'Config.DebugCommand =trueConfig.PrintingTime =8000Config.ShowTime =5000Config.ScreenShotBasicResourceName ='screenshot-basic'Config.aspectRatio =1--0 to 16:9 / 1 to 1:1 dont change if you dont know what you are doingConfig.Lang = { InVehicle ='You can\'t use this in a vehicle', YouPrintPhoto ='You printed a photo', YouDigitalizePhoto ='You digitalized a photo',}Config.ProgressbarPrinting=function()-- exports['progressBars']:startUI(Config.PrintingTime, "Printing...") --You can use your own progressbar (this progressbar is from https://github.com/EthanPeacock/progressBars/releases/tag/1.0) exports['progressbar']:Progress({ --this progressbar is from here https://github.com/Project-Sloth/progressbar name ="idk", duration = Config.PrintingTime, label ="Printing...", icon ="fa-solid fa-print", useWhileDead =false, canCancel =false, controlDisables = { disableMovement =false, disableCarMovement =false, disableMouse =false, disableCombat =false, }, })endConfig.NotificationFunction=function(msg)--set your notification function hereprint(msg)end
ServerConfig = {}
ServerConfig.DiscordWebHook = '' --DISCORD WEBHOOK URL
Citizen.CreateThread(function()
lib.callback.register('ps-polaroid:server:getWebhook', function(source, item, metadata, target)
return ServerConfig.DiscordWebHook
end)
if Config.Framework == 'esx' then
ESX = exports['es_extended']:getSharedObject()
ESX.RegisterUsableItem('album', function(src)
TriggerClientEvent("ps:openAlbum", src)
end)
ESX.RegisterUsableItem('polaroid', function(src)
TriggerClientEvent("ps:openPolaroid", src)
end)
ESX.RegisterUsableItem('printerpolaroid', function(src)
TriggerClientEvent("ps-polaroid:openPrinter", src)
end)
RegisterNetEvent('ps_polaroid:add')
AddEventHandler('ps_polaroid:add', function(src, link, date)
local Player = ESX.GetPlayerFromId(src)
AddToDB(Player.identifier, link, date)
TriggerClientEvent('ps-polaroid-uploadPhoto', src, link, date)
end)
RegisterNetEvent('ps_polaroid:GivePlayer')
AddEventHandler('ps_polaroid:GivePlayer', function(data)
local Player = ESX.GetPlayerFromId(source)
local Player2 = ESX.GetPlayerFromId(tonumber(data.id))
if Player ~= nil and Player2 ~= nil then
DelateFromDB(Player.identifier, data.img)
AddToDB(Player2.identifier, data.img, data.date, data.msg or '')
TriggerClientEvent('ps-polaroid-uploadPhoto', tonumber(data.id), data.img, data.date, data.msg)
else
TriggerClientEvent('ps-polaroid-uploadPhoto', source, data.img, data.date, data.msg)
end
end)
RegisterNetEvent('ps-polaroid:removeitem')
AddEventHandler('ps-polaroid:removeitem', function(item)
local Player = ESX.GetPlayerFromId(source)
if Player ~= nil then
Player.removeInventoryItem(item, 1)
end
end)
AddEventHandler('esx:playerLoaded', function(player)
TriggerEvent("polaroid:init", player)
end)
ESX.RegisterServerCallback('ps-polaroid:ui:haveitem', function(source, cb, item)
local Player = ESX.GetPlayerFromId(source)
local HasItem = Player.getInventoryItem(item)
if Player and HasItem ~= nil then
if HasItem.count >= 1 then
cb(true)
else
cb(false)
end
else
print('[ps-polaroid ERROR] [ESX] [HaveItem] [Dont have item]')
end
end)
if Config.DebugCommand then
RegisterCommand('respawn', function(source, args, rawCommand)
TriggerEvent('polaroid:init', source)
end)
end
function GetIdentifier(src)
local Player = ESX.GetPlayerFromId(src)
if Player ~= nil then
local id = Player.identifier
return id
else
return nil
end
end
elseif Config.Framework == 'qbcore' then
QBCore = exports['qb-core']:GetCoreObject()
QBCore.Functions.CreateUseableItem('album', function(src)
TriggerClientEvent("ps:openAlbum", src)
end)
QBCore.Functions.CreateUseableItem('photo', function(src, item)
local photo = item.info.photo
local Player = QBCore.Functions.GetPlayer(src)
if Player ~= nil then
Player.Functions.RemoveItem('photo', 1, item.slot)
AddToDB(Player.PlayerData.citizenid, photo.img, photo.date, photo.msg)
TriggerClientEvent('ps-polaroid-uploadPhoto', src, photo.img, photo.date, photo.msg)
end
end)
QBCore.Functions.CreateUseableItem('polaroid', function(src)
TriggerClientEvent("ps:openPolaroid", src)
end)
QBCore.Functions.CreateUseableItem('printerpolaroid', function(src)
TriggerClientEvent("ps-polaroid:openPrinter", src)
end)
RegisterNetEvent('ps_polaroid:add')
AddEventHandler('ps_polaroid:add', function(src, link, date)
local Player = QBCore.Functions.GetPlayer(src)
if Player ~= nil then
Player.Functions.AddItem("photo", 1, false, {photo = {img = link, date = date}})
end
end)
RegisterNetEvent('ps_polaroid:GetFromAlbum')
AddEventHandler('ps_polaroid:GetFromAlbum', function(link, date, msg)
local Player = QBCore.Functions.GetPlayer(source)
if Player ~= nil then
Player.Functions.AddItem("photo", 1, false, {photo = {img = link, date = date, msg = msg}})
DelateFromDB(Player.PlayerData.citizenid, link)
end
end)
RegisterNetEvent('ps-polaroid:removeitem')
AddEventHandler('ps-polaroid:removeitem', function(item)
local Player = QBCore.Functions.GetPlayer(source)
if Player ~= nil then
Player.Functions.RemoveItem(item, 1)
end
end)
AddEventHandler('QBCore:Server:PlayerLoaded', function(player)
local src = player.PlayerData.source
TriggerEvent("polaroid:init", src)
end)
if Config.DebugCommand then
RegisterCommand('respawn', function(source, args, rawCommand)
TriggerEvent('polaroid:init', source)
end)
end
function GetIdentifier(src)
local Player = QBCore.Functions.GetPlayer(src)
if Player ~= nil then
local id = Player.PlayerData.citizenid
return id
else
return nil
end
end
end
end)
local ESX, QBCore = nil, nil
Citizen.CreateThread(function()
function GetDiscordWebhook()
local result = lib.callback.await('ps-polaroid:server:getWebhook', false)
return result
end
if Config.Framework == 'esx' then
ESX = exports['es_extended']:getSharedObject()
RegisterNUICallback('ps-polaroid:ui:haveitem', function(data, cb)
ESX.TriggerServerCallback('ps-polaroid:ui:haveitem', function(HaveItemCB)
cb({haveitem = HaveItemCB})
end, 'paperpolaroid')
end)
elseif Config.Framework == 'qbcore' then
QBCore = exports['qb-core']:GetCoreObject()
RegisterNUICallback('ps-polaroid:ui:haveitem', function(data, cb)
local hasItem = QBCore.Functions.HasItem('paperpolaroid')
cb({haveitem = hasItem})
end)
end
end)