Koja Scripts

Admin tools

The in-game location editor, location photos, temporary events and spawn statistics of Koja Spawn Selector.

Admin tools

Admins get two extra tabs in the panel — Editor and Stats — whenever they open the selector with /spawneditor. Who is an admin is decided by ServerEditable.IsAdmin (by default KOJA.Server.IsAdmin with Config.Admin.Groups / Config.Admin.Ace), and every save is checked on the server again.

CommandWhat it does
/spawneditorOpens the selector with the Editor tab
/spawnevent <minutes> <name>Creates a temporary event where you stand
/spawnselector [id]Opens the normal selector for you or a player, with ESC enabled

Command names are set in Config.Command (Name, Editor, Event).

Location editor

The list shows the locations created in game (editable) and the ones from Config.Spawns or other resources (only the photo can be changed for those).

FieldNotes
Name, description, category, iconIcon from the list, or a GTA blip icon such as radar_police_station (image from Config.Map.BlipImageUrl)
PositionUse my position takes where you stood when you opened the editor. Pick on the map lets you click the 3D map — the height then comes from the terrain scan, so check it in game
HeadingDirection the player faces after spawning
Jobspolice:0, sheriff:2 — job name and minimum grade
ACE permission, lock label, on duty only, hide when lockedSame as the spawn definition
Spawn in vehicleA vehicle model; the player spawns in the driver seat with keys
Temporary eventMinutes until the location is removed, 0 = permanent
EnabledOff hides the location without deleting it

Locations are saved in koja_spawnselector_points and appear for everyone the next time they open the selector.

Photos

Take photo hides the UI, flies a camera to the location (7.5 m behind, 2.6 m up, facing the heading), waits for the area to load and takes a screenshot with screenshot-basic. The image is scaled to 640 × 360 JPEG in the UI and stored in koja_spawnselector_images, so nothing is uploaded anywhere and nothing needs a restart. Photos work for config and API locations too (stored by spawn id).

Without a photo the card shows the live preview or the map.

Temporary events

An event is a location with an end time: a pulsing pin on the map, an Event group at the top of the list and a countdown on the card. Create one from the editor (minutes field), with /spawnevent 45 Airport street race, or from code:

local id = exports['koja-spawnselector']:AddEvent({
    label = 'Airport street race',
    description = 'Starts at 21:00',
    coords = vec4(-1336.0, -3044.0, 13.9, 330.0),
    vehicle = 'sultan',
}, 45 * 60)
exports['koja-spawnselector']:RemoveEvent(id)

Expired events are removed every minute.

Stats

Every spawn is logged in koja_spawnselector_log (Config.Stats.Enabled) and kept for Config.Stats.KeepDays. The Stats tab shows the last 7, 30 or 90 days: total spawns, unique players, the share of "Last location", spawns per day and the most picked locations.

local stats = exports['koja-spawnselector']:GetStats(30)
-- { bySpawn = { { spawn_id, category, total } }, byDay = { { day, total } }, players = 184 }

Points API

The same storage the editor uses:

local id = exports['koja-spawnselector']:SavePoint({ label = 'Pink Cage Motel', category = 'property', coords = vec4(312.3, -218.6, 54.2, 160.0) })
exports['koja-spawnselector']:DeletePoint(id)
local points = exports['koja-spawnselector']:GetPoints()

SavePoint with an existing id updates it. Ids of Config.Spawns cannot be used. The server event koja-spawnselector:server:pointsChanged (id, point or nil) fires after every change.