Koja Scripts
FREE

Database

Full reference for every table created by koja-carmarket.

Database

Full reference for every table created by koja-carmarket.


How tables are created

Two paths, both produce the same schema:

MethodWhenWhere
AutoFirst start when Config.Database.AutoCreateTable = trueserver/database.lua
ManualYou run the SQL yourselfdatabase.sql

Tables

koja_carmarket

Vehicles currently physically spawned in market zones (the eye-candy parked car you walk up to).

ColumnTypeNote
idINT PKauto-increment
zone_idVARCHAR(50)references Config.Zones[*].id
slot_idVARCHAR(64)references a CarMarketBoxes[*].id
ownerVARCHAR(50)seller identifier
vehicleJSONfull vehicle properties
plateVARCHAR(8)
coordsJSON{x, y, z}
headingFLOAT

koja_carmarket_listings

The logical listing — what shows up in the market UI. One row per active offer.

ColumnTypeNote
idINT PK
nameVARCHAR(100)shown in UI
respnameVARCHAR(100)spawn model name
ownerVARCHAR(50)seller identifier
car_typeVARCHAR(50)sedan, coupe, suv, ...
drive_typeVARCHAR(50)2x4, 4x4, rear-2x4
fuel_typeVARCHAR(50)gasoline, electric
offert_typeVARCHAR(50)buy or auction
tagsJSONarray of strings
priceINTlive auction price = highest bid
mileageINTkm
descriptionTEXT
plateVARCHAR(20)
vehicle_dataJSONfull vehicle properties snapshot
owned_vehicle_idINTFK to ESX owned_vehicles.id / QBCore equivalent
seller_nameVARCHAR(100)denormalized for offline-seller display
zone_idVARCHAR(50)NULL if not parked anywhere
auction_starts_atTIMESTAMPNULL for buy-now
auction_ends_atTIMESTAMPNULL for buy-now
listing_fee_paid_untilTIMESTAMPnext listing fee due
created_atTIMESTAMP

koja_carmarket_offers

Individual auction bids.

ColumnTypeNote
idINT PK
listing_idINTFK → koja_carmarket_listings.id
buyer_identifierVARCHAR(64)
buyer_nameVARCHAR(100)
amountINT
statusVARCHAR(20)always 'pending' currently
created_atTIMESTAMP

koja_carmarket_history

Audit trail of every sale/listing/auction event.

ColumnTypeNote
idINT PK
listing_idINTFK (logical, not enforced — listings can be deleted)
typeVARCHAR(20)listing, auction, purchase
priceINT
seller_identifierVARCHAR(64)
seller_nameVARCHAR(100)
buyer_identifierVARCHAR(64)NULL for non-purchase rows
buyer_nameVARCHAR(100)
vehicle_infoJSONsnapshot at sale time
created_atTIMESTAMP

koja_carmarket_slot_owners

Per-player owned slot inside zones.

ColumnTypeNote
slot_idVARCHAR(64) PK
zone_idVARCHAR(50)
owner_identifierVARCHAR(64)
weekly_feeINT
next_payment_atTIMESTAMP
created_atTIMESTAMP

koja_carmarket_exchange

Per-zone ownership & business settings.

ColumnTypeNote
zone_idVARCHAR(50) PK
owner_identifierVARCHAR(64)NULL = server-owned
listing_fee_per_weekINT
max_listingsINT
commission_percentINT0–100
created_atTIMESTAMP

koja_carmarket_parkings & koja_carmarket_parking_slots

External player-owned parkings (not inside market zones). Reserved for future expansion.

koja_carmarket_garage_slots

Garage slot ↔ vehicle bindings. Reserved.


Common queries

How much commission did Z earn last week?

SELECT SUM(price * 0.05) AS commission_estimate
FROM koja_carmarket_history h
JOIN koja_carmarket_listings l ON l.id = h.listing_id
JOIN koja_carmarket_exchange e ON e.zone_id = l.zone_id
WHERE h.type = 'purchase'
  AND e.owner_identifier = 'license:abc123'
  AND h.created_at > NOW() - INTERVAL 7 DAY;

Top 10 sellers by revenue:

SELECT seller_identifier, seller_name, SUM(price) AS revenue, COUNT(*) AS sales
FROM koja_carmarket_history
WHERE type = 'purchase'
GROUP BY seller_identifier, seller_name
ORDER BY revenue DESC
LIMIT 10;

Release a zone owner (admin SQL):

UPDATE koja_carmarket_exchange
SET owner_identifier = NULL
WHERE zone_id = 'zone1';
  • Configuration — Configure zones, parking, exchange rules, test drives, and custom images.
  • Features — Player-facing flows and core marketplace features.
  • Installation — Welcome to Koja-Carmarket, a player-driven car market with auctions, exchange zones, rentable parking slots and test drives.
  • Exports & Commands — All public API surface of koja-carmarket.
  • Zones — Market zones define where players can list and buy vehicles.
  • CarMarket — back to the section overview