Koja Scripts

Database

The Koja Spawn Selector tables: last location, drop records and restrictions per character, editor locations, photos and the spawn log.

Database

Koja Spawn Selector creates its tables when the resource starts (and adds the state column to an older koja_spawnselector table). sql/koja_spawnselector.sql has the main table if you prefer to import it.

TableWhat it holds
koja_spawnselectorOne row per character: last position, remembered choice, drop record and restrictions
koja_spawnselector_pointsLocations made in the editor or with SavePoint / AddEvent
koja_spawnselector_imagesLocation photos (640 × 360 JPEG as a data URI), by spawn id
koja_spawnselector_logOne row per spawn, for the Stats tab

koja_spawnselector

ColumnWhat it holds
identifierCharacter identifier from koja-lib: ESX identifier (with the char1: prefix on multicharacter), QBCore citizenid
x, y, z, headingLast saved position
last_choiceId of the location picked last time, for Config.Open.RememberChoice
updated_atUnix time of the last position save; 0 = no position yet
stateJSON: drop (the last disconnect: kind, reason, time, dead, combat, coords), lastLock (from LockLastLocation) and restrictions (from SetRestriction)

koja_spawnselector_points

ColumnWhat it holds
idSpawn id
dataJSON spawn definition
expires_atUnix time an event ends, NULL = permanent
created_byIdentifier of the admin or the resource that created it
created_atUnix time

koja_spawnselector_images

ColumnWhat it holds
spawn_idSpawn id (config, API or editor)
datadata:image/jpeg;base64,... (max 400 kB)
updated_atUnix time, used to refresh cached images

koja_spawnselector_log

ColumnWhat it holds
identifier, spawn_id, category, originWho spawned where
created_atUnix time (indexed). Rows older than Config.Stats.KeepDays are removed on start

Framework fallback

A character without a saved position gets "Last location" from the framework when Config.LastLocation.FrameworkFallback is on: users.position (ESX) or players.position (QBCore / QBox). Nothing is ever written to the framework tables.

Resetting

-- one character
DELETE FROM `koja_spawnselector` WHERE `identifier` = 'char1:abc123';
-- clear every combat / death lock but keep positions
UPDATE `koja_spawnselector` SET `state` = NULL;
-- empty the stats
TRUNCATE `koja_spawnselector_log`;