diff --git a/client/main.lua b/client/main.lua index 4bf3e121..49be3198 100644 --- a/client/main.lua +++ b/client/main.lua @@ -1389,11 +1389,34 @@ RegisterNUICallback('TakePhoto', function(_, cb) cb(json.encode({ url = nil })) break elseif IsControlJustPressed(1, 176) then -- TAKE.. PIC + if Config.Fivemerr == true then + -- Fivemerr uploads via the server using screenshot-basic to further guard your API key. + return QBCore.Functions.TriggerCallback('qb-phone:server:UploadToFivemerr', function(fivemerrData) + if fivemerrData == nil then + DestroyMobilePhone() + CellCamActivate(false, false) + takePhoto = false + return + end + + SaveToInternalGallery() + local imageData = json.decode(fivemerrData) + DestroyMobilePhone() + CellCamActivate(false, false) + TriggerServerEvent('qb-phone:server:addImageToGallery', imageData.url) + Wait(400) + TriggerServerEvent('qb-phone:server:getImageFromGallery') + cb(json.encode(imageData.url)) + takePhoto = false + end) + end + QBCore.Functions.TriggerCallback('qb-phone:server:GetWebhook', function(hook) if not hook then QBCore.Functions.Notify('Camera not setup', 'error') return end + exports['screenshot-basic']:requestScreenshotUpload(tostring(hook), 'files[]', function(data) SaveToInternalGallery() local image = json.decode(data) diff --git a/config.lua b/config.lua index cad86da6..822607da 100644 --- a/config.lua +++ b/config.lua @@ -7,6 +7,11 @@ Config.TweetDuration = 12 -- How many hours to load tweets (12 will load the pas Config.RepeatTimeout = 2000 Config.CallRepeats = 10 Config.OpenPhone = 'M' + +-- Set this to true if you wish to use Fivemerr (https://fivemerr.com/) for media uploads. +-- Ensure to add your API key to server/main.lua +Config.Fivemerr = false + Config.PhoneApplications = { ['phone'] = { app = 'phone', diff --git a/server/main.lua b/server/main.lua index 998505d4..0f2aef18 100644 --- a/server/main.lua +++ b/server/main.lua @@ -7,6 +7,7 @@ local Calls = {} local Adverts = {} local GeneratedPlates = {} local WebHook = '' +local FivemerrApiToken = 'API_KEY_HERE' local bannedCharacters = { '%', '$', ';' } local TWData = {} @@ -609,6 +610,32 @@ QBCore.Functions.CreateCallback('qb-phone:server:GetWebhook', function(_, cb) end end) +QBCore.Functions.CreateCallback('qb-phone:server:UploadToFivemerr', function(source, cb) + local src = source + + if Config.Fivemerr == '' then + print("^1--- Fivemerr is enabled but no API token has been specified. ---^7") + return cb(nil) + end + + exports['screenshot-basic']:requestClientScreenshot(src, { + encoding = 'png' + }, function(err, data) + if err then return cb(nil) end + PerformHttpRequest(WebHook, function(status, response) + if status ~= 200 then + print("^1--- ERROR UPLOADING IMAGE: " .. status .. " ---^7") + cb(nil) + end + + cb(response) + end, "POST", json.encode({ data = data }), { + ['Authorization'] = FivemerrApiToken, + ['Content-Type'] = 'application/json' + }) + end) +end) + -- Events RegisterNetEvent('qb-phone:server:AddAdvert', function(msg, url)