Client exports
Camera and photos
Client exports that open the phone camera and save media to the player's Photos.
How the camera works for players is described in Camera.
#OpenCamera
Opens the phone's camera, optionally returning the next shot to your script.
lua---@param opts? { mode?: 'photo'|'video', selfie?: boolean }
---@param cb? fun(url: string|nil, kind: string|nil)
---@return boolean opened whether the phone opened
exports['fx-phone']:OpenCamera(opts, cb)
luaexports['fx-phone']:OpenCamera({ mode = 'photo' }, function(url)
if url then TriggerServerEvent('my-evidence:photo', url) end
end)
- With
cb, the camera closes after one shot and callscb(url, kind)once with the uploaded link. cb(nil)is called when the player backs out, or when the phone could not open.- A new
OpenCameracall ends a pending callback of an earlier one withnil.
#IsCameraOpen
Returns whether the camera view is open.
lua---@return boolean open
exports['fx-phone']:IsCameraOpen()
luaif exports['fx-phone']:IsCameraOpen() then return end
#SaveToGallery
Adds a picture or a video to this player's Photos.
lua---@param url string media link
---@param kind? 'photo'|'video' default 'photo'
---@param thumbnail? string image link
---@return boolean ok
---@return string|nil err
exports['fx-phone']:SaveToGallery(url, kind, thumbnail)
lualocal ok, err = exports['fx-phone']:SaveToGallery('https://example.com/photo.jpg')
- The link must be
https://on a host allowed inServerConfig.Upload.AllowedHosts. See Upload. - The export waits for the server's answer.