Skip to main content

save_photo

Saves a photo to a player’s gallery.
---@param owner_identifier string The player's identifier
---@param url string The photo URL
---@param location string? Optional location where the photo was taken
---@return number? photo_id The ID of the saved photo, or nil on failure
local photo_id = exports["no-camera"]:save_photo("license:abc123", "https://example.com/photo.jpg", "Vinewood Hills")

get_photo

Gets a photo by its ID.
---@class GalleryItem
---@field id number
---@field owner_identifier string
---@field url string
---@field location string
---@field created_at number

---@param photo_id number The photo ID
---@return GalleryItem? photo The photo data or nil if not found
local photo = exports["no-camera"]:get_photo(1)

get_photos_by_owner

Gets a list of photos for a player with pagination.
---@class GalleryItemPaginationResults
---@field total number
---@field page number
---@field page_size number
---@field has_more boolean
---@field results table<GalleryItem>

---@param owner_identifier string The player's identifier
---@param page number Page number (1-based)
---@param page_size number Number of photos per page
---@param search string? Optional search term to filter by location
---@return GalleryItemPaginationResults results Paginated photo results
local results = exports["no-camera"]:get_photos_by_owner("license:abc123", 1, 10, nil)

-- Example response:
-- {
--     total = 25,
--     page = 1,
--     page_size = 10,
--     has_more = true,
--     results = { ... }
-- }

delete_photo

Deletes a photo from the gallery.
---@param photo_id number The photo ID to delete
---@param owner_identifier string? Optional owner identifier (if provided, only deletes if owned by this player)
---@return boolean success True if deleted
local success = exports["no-camera"]:delete_photo(1, "license:abc123")

share_photo

Shares a photo with another player (copies it to their gallery).
---@param photo_id number The photo ID to share
---@param target_identifier string The target player's identifier
---@param owner_identifier string? Optional owner identifier for verification
---@return boolean success True if shared successfully
local success = exports["no-camera"]:share_photo(1, "license:xyz789", "license:abc123")

Inventory Integration

give_photo_item

Adds a physical photo item to a player’s inventory.
---@param source number The player server ID
---@param image string The photo URL
---@param location string? Optional location string
---@param timestamp number? Optional timestamp when photo was taken
---@return boolean success True if item was added
---@return string? error Error message if failed
local success, error = exports["no-camera"]:give_photo_item(1, "https://example.com/photo.jpg", "Vinewood Hills", 1738656000000)

is_inventory_enabled

Checks if inventory integration is enabled.
---@return boolean enabled
local enabled = exports["no-camera"]:is_inventory_enabled()

Player Camera State

is_player_camera_active

Checks if a player has their camera active (via state bag).
---@param source number The player server ID
---@return boolean is_active True if camera is active
local is_active = exports["no-camera"]:is_player_camera_active(1)

get_player_camera_state

Gets a player’s current camera state (via state bag).
---@enum CAMERA_STATE
CAMERA_STATE = {
    DEACTIVE = 0,
    HOLDING = 1,
    VIEWING = 2,
    PHOTO_MODE = 3
}

---@param source number The player server ID
---@return CAMERA_STATE? state The camera state or nil if player not found
local state = exports["no-camera"]:get_player_camera_state(1)