Skip to content

Server Database

File: server/database.lua

All MySQL table creation and database access functions.

Tables (32 total)

Group Core

TablePurpose
wtf_groupsGroup data (id, leader, type, data, locked, cooldown)
wtf_group_membersMember list (group_id, citizenid, name, role, pending)
wtf_group_rolesRole assignments (group_id, citizenid, role)
wtf_group_activity_logCompleted task history
wtf_group_reputationGroup XP, level, stats
wtf_group_spawnsCustom spawn points

Features

TablePurpose
wtf_tasksActive/completed tasks
wtf_global_cooldownsPer-player activity cooldowns
wtf_group_alliancesAlliance/war relationships
wtf_turfsClaimed territories
wtf_turf_challengesPending turf challenges
wtf_bountiesBounty board entries
wtf_mailboxInternal group mail
wtf_garageGroup vehicle storage

Tablet

TablePurpose
wtf_tablet_app_dataPer-player app data (key-value)
wtf_tablet_notificationsNotification log
wtf_tablet_settingsPer-player tablet settings
wtf_tablet_installed_appsPer-player installed apps

VPN

TablePurpose
wtf_vpn_proxiesVPN proxy definitions (seeded from config)
wtf_vpn_license_keysLicense keys for premium proxy access

Auction

TablePurpose
auction_listingsAuction listings (items, vehicles, shops)
auction_bidsBid history per auction
auction_watchlistPlayer watchlist
auction_balancesPlayer auction balances
auction_accountsAuth accounts (username/password)
auction_sessionsSession tokens
auction_settingsKey-value settings

Contracts

TablePurpose
wtf_contract_stockGlobal stock per contract type
wtf_contract_activeGlobal lock (one active per type)
wtf_contract_inventoryPlayer-owned contracts
wtf_contract_start_queueFIFO start queue for locked types
wtf_contract_historyPurchase/start/complete log

Key Functions

Group CRUD

lua
DB.CreateGroup(groupId, leaderCid, groupType, data) → insertId
DB.DeleteGroup(groupId)
DB.GetGroup(groupId) → row|nil
DB.UpdateGroupData(groupId, key, value)
DB.SetLeader(groupId, citizenid)
DB.SetLocked(groupId, locked)
DB.SetCooldown(groupId, seconds)
DB.GetCooldown(groupId) → seconds

Members

lua
DB.AddMember(groupId, citizenid, name, role, pending)
DB.RemoveMember(groupId, citizenid)
DB.GetMembers(groupId) → rows
DB.GetMemberCount(groupId) → count
DB.IsMember(groupId, citizenid) → boolean
DB.IsPending(groupId, citizenid) → boolean
DB.SetPending(groupId, citizenid, pending)
DB.GetPlayerGroup(citizenid) → row|nil
DB.UpdateMemberRole(groupId, citizenid, role)
DB.UpdateMemberName(citizenid, name)

Tasks

lua
DB.CreateTask(groupId, taskType, title, description, instructions, data) → insertId
DB.GetGroupTasks(groupId) → rows
DB.UpdateTaskStatus(taskId, status)
DB.DeleteTask(taskId)
DB.GetActiveTask(groupId) → row|nil

Reputation

lua
DB.GetReputation(groupId) → row
DB.UpdateReputation(groupId, xp, level, totalTasks, totalFailed)
DB.AddXP(groupId, amount)

Tablet

lua
-- Settings
DB.LoadSettings(citizenid) → table|nil
DB.SaveSettings(citizenid, settings)

-- Installed Apps
DB.LoadInstalledApps(citizenid) → array|nil
DB.SaveInstalledApps(citizenid, apps)

-- App Data
DB.SetAppData(citizenid, appId, key, value)
DB.GetAppData(citizenid, appId, key) → any|nil
DB.DeleteAppData(citizenid, appId, key)
DB.GetAllAppData(citizenid, appId) → table
DB.ClearAppData(citizenid, appId)

VPN

lua
-- Proxies
DB.SeedProxies(proxies)
DB.GetAllProxies() → rows
DB.GetProxyById(proxyId) → row|nil

-- License Keys
DB.GetLicenseKey(keyCode) → row|nil
DB.UseLicenseKey(keyCode)
DB.CreateLicenseKey(keyCode, proxyId, permanent, duration, maxUses, createdBy)
DB.GetPlayerActivatedKeys(citizenid) → array

AIFAZI — FiveM Resources