GIG ScriptsGIG Scripts

Smart Glasses

Wearable glasses with photo and video capture, a flashlight, spatial music and a persistent album.

Dependencies

  • ox_lib
  • oxmysql
  • gig-smartGlasses-assets (the glasses models, 14 frame colours)
  • screenshot-basic for photos and the video fallback
  • Qbox, QB-Core or ESX
  • A Fivemanage account. Photos and clips are uploaded there and only the URL is stored.
server.cfg
ensure gig-smartGlasses-assets
ensure gig-smartGlasses

Create an API key in the Fivemanage dashboard under Media, API keys, and put it in cfg_sv.lua:

cfg_sv.lua
cfg.fivemanageToken = 'your key'

Without it every capture fails with an error in the server console.

Items

Every frame colour is its own item. Using the item puts the glasses on, using it again takes them off. Names are set per colour in cfg.items.

ColourItem
blacksmartglasses_black
havanasmartglasses_havana
navysmartglasses_navy
bordeauxsmartglasses_bordeaux
whitesmartglasses_white
graysmartglasses_gray
greensmartglasses_green
silversmartglasses_silver
goldsmartglasses_gold
pinksmartglasses_pink
bluesmartglasses_blue
redsmartglasses_red
orangesmartglasses_orange
purplesmartglasses_purple
ox_inventory/data/items.lua
['smartglasses_black']    = { label = 'Smart Glasses (Black)',    weight = 100, stack = false, close = true },
['smartglasses_havana']   = { label = 'Smart Glasses (Havana)',   weight = 100, stack = false, close = true },
['smartglasses_navy']     = { label = 'Smart Glasses (Navy)',     weight = 100, stack = false, close = true },
['smartglasses_bordeaux'] = { label = 'Smart Glasses (Bordeaux)', weight = 100, stack = false, close = true },
['smartglasses_white']    = { label = 'Smart Glasses (White)',    weight = 100, stack = false, close = true },
['smartglasses_gray']     = { label = 'Smart Glasses (Gray)',     weight = 100, stack = false, close = true },
['smartglasses_green']    = { label = 'Smart Glasses (Green)',    weight = 100, stack = false, close = true },
['smartglasses_silver']   = { label = 'Smart Glasses (Silver)',   weight = 100, stack = false, close = true },
['smartglasses_gold']     = { label = 'Smart Glasses (Gold)',     weight = 100, stack = false, close = true },
['smartglasses_pink']     = { label = 'Smart Glasses (Pink)',     weight = 100, stack = false, close = true },
['smartglasses_blue']     = { label = 'Smart Glasses (Blue)',     weight = 100, stack = false, close = true },
['smartglasses_red']      = { label = 'Smart Glasses (Red)',      weight = 100, stack = false, close = true },
['smartglasses_orange']   = { label = 'Smart Glasses (Orange)',   weight = 100, stack = false, close = true },
['smartglasses_purple']   = { label = 'Smart Glasses (Purple)',   weight = 100, stack = false, close = true },
qb-core/shared/items.lua
['smartglasses_black']    = { name = 'smartglasses_black',    label = 'Smart Glasses (Black)',    weight = 100, type = 'item', image = 'smartglasses_black.png',    unique = true, useable = true, shouldClose = true, description = 'Smart glasses with a camera, a light and a speaker.' },
['smartglasses_havana']   = { name = 'smartglasses_havana',   label = 'Smart Glasses (Havana)',   weight = 100, type = 'item', image = 'smartglasses_havana.png',   unique = true, useable = true, shouldClose = true, description = 'Smart glasses with a camera, a light and a speaker.' },
['smartglasses_navy']     = { name = 'smartglasses_navy',     label = 'Smart Glasses (Navy)',     weight = 100, type = 'item', image = 'smartglasses_navy.png',     unique = true, useable = true, shouldClose = true, description = 'Smart glasses with a camera, a light and a speaker.' },
['smartglasses_bordeaux'] = { name = 'smartglasses_bordeaux', label = 'Smart Glasses (Bordeaux)', weight = 100, type = 'item', image = 'smartglasses_bordeaux.png', unique = true, useable = true, shouldClose = true, description = 'Smart glasses with a camera, a light and a speaker.' },
['smartglasses_white']    = { name = 'smartglasses_white',    label = 'Smart Glasses (White)',    weight = 100, type = 'item', image = 'smartglasses_white.png',    unique = true, useable = true, shouldClose = true, description = 'Smart glasses with a camera, a light and a speaker.' },
['smartglasses_gray']     = { name = 'smartglasses_gray',     label = 'Smart Glasses (Gray)',     weight = 100, type = 'item', image = 'smartglasses_gray.png',     unique = true, useable = true, shouldClose = true, description = 'Smart glasses with a camera, a light and a speaker.' },
['smartglasses_green']    = { name = 'smartglasses_green',    label = 'Smart Glasses (Green)',    weight = 100, type = 'item', image = 'smartglasses_green.png',    unique = true, useable = true, shouldClose = true, description = 'Smart glasses with a camera, a light and a speaker.' },
['smartglasses_silver']   = { name = 'smartglasses_silver',   label = 'Smart Glasses (Silver)',   weight = 100, type = 'item', image = 'smartglasses_silver.png',   unique = true, useable = true, shouldClose = true, description = 'Smart glasses with a camera, a light and a speaker.' },
['smartglasses_gold']     = { name = 'smartglasses_gold',     label = 'Smart Glasses (Gold)',     weight = 100, type = 'item', image = 'smartglasses_gold.png',     unique = true, useable = true, shouldClose = true, description = 'Smart glasses with a camera, a light and a speaker.' },
['smartglasses_pink']     = { name = 'smartglasses_pink',     label = 'Smart Glasses (Pink)',     weight = 100, type = 'item', image = 'smartglasses_pink.png',     unique = true, useable = true, shouldClose = true, description = 'Smart glasses with a camera, a light and a speaker.' },
['smartglasses_blue']     = { name = 'smartglasses_blue',     label = 'Smart Glasses (Blue)',     weight = 100, type = 'item', image = 'smartglasses_blue.png',     unique = true, useable = true, shouldClose = true, description = 'Smart glasses with a camera, a light and a speaker.' },
['smartglasses_red']      = { name = 'smartglasses_red',      label = 'Smart Glasses (Red)',      weight = 100, type = 'item', image = 'smartglasses_red.png',      unique = true, useable = true, shouldClose = true, description = 'Smart glasses with a camera, a light and a speaker.' },
['smartglasses_orange']   = { name = 'smartglasses_orange',   label = 'Smart Glasses (Orange)',   weight = 100, type = 'item', image = 'smartglasses_orange.png',   unique = true, useable = true, shouldClose = true, description = 'Smart glasses with a camera, a light and a speaker.' },
['smartglasses_purple']   = { name = 'smartglasses_purple',   label = 'Smart Glasses (Purple)',   weight = 100, type = 'item', image = 'smartglasses_purple.png',   unique = true, useable = true, shouldClose = true, description = 'Smart glasses with a camera, a light and a speaker.' },
ESX without ox_inventory
INSERT INTO `items` (`name`, `label`, `weight`) VALUES
('smartglasses_black', 'Smart Glasses (Black)', 1),
('smartglasses_havana', 'Smart Glasses (Havana)', 1),
('smartglasses_navy', 'Smart Glasses (Navy)', 1),
('smartglasses_bordeaux', 'Smart Glasses (Bordeaux)', 1),
('smartglasses_white', 'Smart Glasses (White)', 1),
('smartglasses_gray', 'Smart Glasses (Gray)', 1),
('smartglasses_green', 'Smart Glasses (Green)', 1),
('smartglasses_silver', 'Smart Glasses (Silver)', 1),
('smartglasses_gold', 'Smart Glasses (Gold)', 1),
('smartglasses_pink', 'Smart Glasses (Pink)', 1),
('smartglasses_blue', 'Smart Glasses (Blue)', 1),
('smartglasses_red', 'Smart Glasses (Red)', 1),
('smartglasses_orange', 'Smart Glasses (Orange)', 1),
('smartglasses_purple', 'Smart Glasses (Purple)', 1);

Item use goes through the framework's usable-item bridge, so no client.event entries are needed. To change an item name, edit cfg.items.

Icons

The icons/ folder has one icon per colour, named gig_smartglasses_<colour>.png. Copy them into your inventory's image folder and drop the gig_ prefix so the file name matches the item name:

# from the icons folder
for f in gig_*.png; do cp "$f" "/path/to/inventory/images/${f#gig_}"; done
Get-ChildItem gig_*.png | ForEach-Object { Copy-Item $_ "C:\path\to\inventory\images\$($_.Name -replace '^gig_','')" }

Music

Tracks come from the musics/ folder inside the resource; players cannot paste links. Drop .ogg, .mp3 or .wav files in, then run refresh and restart the resource. .ogg is the safest format; if a track does not play, the reason is printed in the player's F8 console. The file name without its extension is the title players see and search, and underscores are shown as spaces, so Artist - Title.ogg works well.

Only add music you have the rights to use on your server.

Commands and keys

CommandDefault keyWhat it does
/glassesmenuF7 (cfg.menuKey)opens the interface while the glasses are worn (cfg.menuCommand)

Inside the photo viewfinder: mouse aims, the wheel zooms, the left button shoots, Backspace leaves. While recording, X stops.

How it works

The interface floats in front of the character on a world plane, so other players see it too. It has six sections:

  • Photo opens a first-person viewfinder. The character and the glasses are hidden locally so the shot is clean. Photos are downscaled to 1280 px wide and uploaded as JPEG.
  • Video records up to 20 seconds at 854 px wide. A built-in live GameView captures at about 30 fps; if WebGL is unavailable it falls back to 5 fps screenshot-basic frames. The local microphone is mixed in when the player allows it. Other players' voices go through the game audio engine and cannot be captured.
  • Light switches a flashlight beam on the glasses, visible to everyone.
  • Music opens a player with a searchable list of the tracks in the resource's musics/ folder. The wearer can pause, seek, skip to the previous or next track and set the volume; when a track ends the next one starts. It plays as spatial sound. Nearby players hear it within cfg.musicRange, quieter through vehicle bodies and interior walls. Only the wearer can start, stop and set the volume.
  • Album keeps every capture per character, newest first. A capture can be viewed with sound, its link copied, or deleted. A photo can be shown above the character's head as a small polaroid that nearby players see.
  • Theme recolours the interface. Players pick a swatch or type a hex colour; cfg.theme.allowColorChange = false locks everyone to cfg.theme.color.

Photos and clips cannot be taken from inside a vehicle. Uploads go to Fivemanage from the server, not from the player's browser, so no key ever reaches a client.

Config

FileContents
cfg.luaframework, inventory, notify, the 14 items, menu command and key, music range, theme
cfg_sv.luathe Fivemanage API key

Per colour in cfg.items:

black = { item = 'smartglasses_black', useItem = true, command = 'glasses_black', requireItem = false },
  • useItem: using the inventory item wears the glasses.
  • command: the chat command for this colour, or false for none.
  • requireItem: the command also needs the item in the inventory. With false the command works without one, which suits a shop or job that hands the glasses out differently.

cfg.musicRange is the speaker range in metres. cfg.theme sets the default interface colour and whether players may change it.

Notes

  • Runtime state (worn colour, light, music) is synced to nearby players on join, so someone who connects later still sees the glasses and hears the music.
  • If a video fails to build or upload, the reason is printed in the player's F8 console.

On this page