Menan AK47
MENAN AK47DOCS
DiscordStore
Navigation
Menu
Welcome
FAQ
ak47_lib
Framework
Integration
Interface
Events
Imports
Callback
Screenshot & Upload
ak47_target
ak47_ambulancejob
ak47_banking
ak47_business
ak47_carboosting
ak47_cardealer
ak47_clothingshop
ak47_crafting
ak47_crime
ak47_crutch
ak47_deliveryjob
ak47_drugdealerv2
ak47_drugmanagerv3
ak47_drugmissions
ak47_ecommerce
ak47_farming
ak47_fishing
ak47_fraudsystem
ak47_fuelstations
ak47_gangs
ak47_garage
ak47_garbagejob
ak47_hookahloungev2
ak47_housing
ak47_hud
ak47_iclothingv3
ak47_idcardv2
ak47_inventory
ak47_jobgarage
ak47_khusbites
ak47_khusland
ak47_leafnlatte
ak47_mafiasupply
ak47_mechanic
ak47_moneywash
ak47_multicharacter
ak47_npcmed
ak47_outfitbag
ak47_playershop
ak47_policejob
ak47_prospecting
ak47_radio
ak47_rentalcar
ak47_safezone
ak47_sitchair
ak47_smokingv2
ak47_supermarket
ak47_switch
ak47_territories
ak47_vehiclekeys
ak47_vipshop
Loaf
DocsPluginsScreenshot & Upload

Screenshot & Upload

Lib47.TakeScreenshot

Captures the current game screen on-demand directly from GPU texture memory using the built-in WebGL GameRenderer. This operates entirely within ak47_lib and does not require screenshot-basic or any external capture resources. Minimap and HUD can be hidden automatically during the capture frame.

--- @param options table|nil Optional capture settings
--- @return string|nil dataUrl Base64 image data URL (e.g., 'data:image/jpeg;base64,...')
--- @return string|nil error Error message if the capture failed
local dataUrl, err = Lib47.TakeScreenshot({
    encoding = 'jpg',   -- 'jpg' or 'png' (default: 'jpg')
    quality = 0.92,     -- Image compression between 0.1 and 1.0 (default: 0.92)
    hideRadar = true,   -- Temporarily hide minimap/radar during capture (default: true)
    crop = nil,         -- Optional crop: { x = 0, y = 0, width = 1280, height = 720 }
})

if dataUrl then
    print("Screenshot captured successfully!")
    -- Use dataUrl locally or send to upload API
else
    print("Failed to capture screenshot:", err)
end

Lib47.UploadToFiveManage

Uploads a single media file to FiveManage through the NUI bridge. Supports image, video, and audio formats as base64 data URLs or raw base64 strings. Requests are assigned unique upload IDs, allowing multiple concurrent uploads from different scripts without blocking.

--- @param fileData string Base64 data URL or raw Base64 string
--- @param token string Your FiveManage API authorization token
--- @param path string|nil Destination folder name in FiveManage (default: 'ak47_uploads')
--- @param mediaType string|nil File type: 'image' | 'video' | 'audio' (default: 'image')
--- @return string|nil url The public FiveManage hosted file URL
--- @return string|nil error Error message if the upload failed
local url, err = Lib47.UploadToFiveManage(imageData, 'YOUR_FIVEMANAGE_TOKEN', 'ak47_housing', 'image')

if url then
    print("File uploaded successfully to:", url)
else
    print("Failed to upload to FiveManage:", err)
end

Lib47.UploadMultipleToFiveManage

Uploads an array of files to FiveManage simultaneously in parallel. Each item is converted and uploaded asynchronously via Promise.all in NUI, returning a list of hosted URLs in the same order. Ideal for uploading galleries, document attachments, or multiple property angles.

--- @param filesList table Array of base64 strings or { file = ..., mediaType = ... } tables
--- @param token string Your FiveManage API authorization token
--- @param path string|nil Destination folder name in FiveManage (default: 'ak47_uploads')
--- @param mediaType string|nil Default media type for string items: 'image' | 'video' | 'audio' (default: 'image')
--- @return table|nil urls Array of public FiveManage hosted URLs
--- @return string|nil error Error message if the upload failed

-- Example 1: Batch upload multiple image strings
local images = {
    photo1_dataUrl,
    photo2_dataUrl,
    photo3_dataUrl,
}

local urls, err = Lib47.UploadMultipleToFiveManage(images, 'YOUR_FIVEMANAGE_TOKEN', 'ak47_housing', 'image')

if urls then
    for index, fileUrl in ipairs(urls) do
        print(string.format("Image #%d URL: %s", index, fileUrl))
    end
else
    print("Batch upload failed:", err)
end

-- Example 2: Mixed media batch upload
local mixedMedia = {
    { file = photoDataUrl, mediaType = 'image' },
    { file = videoDataUrl, mediaType = 'video' },
    { file = audioDataUrl, mediaType = 'audio' },
}

local urls, err = Lib47.UploadMultipleToFiveManage(mixedMedia, 'YOUR_FIVEMANAGE_TOKEN', 'ak47_records')

Lib47.TakeScreenshotAndUpload

An all-in-one convenience function that captures a screenshot on-demand and immediately uploads it to FiveManage in a single awaitable call. Handles the full capture, WebGL unmounting, blob conversion, and cloud upload lifecycle.

--- @param token string Your FiveManage API authorization token
--- @param path string|nil Destination folder name in FiveManage (default: 'ak47_uploads')
--- @param options table|nil Optional capture settings (passed to TakeScreenshot)
--- @return string|nil url The public FiveManage hosted image URL
--- @return string|nil error Error message if capture or upload failed
local imageUrl, err = Lib47.TakeScreenshotAndUpload('YOUR_FIVEMANAGE_TOKEN', 'ak47_housing', {
    encoding = 'jpg',
    quality = 0.90,
    hideRadar = true,
})

if imageUrl then
    print("Property screenshot uploaded to FiveManage:", imageUrl)
    -- Example: Save to house data or database
    housedata.image = imageUrl
else
    print("Screenshot & upload failed:", err)
end
Previous
Callback
Next
ak47_target