Server Database
File: server/database.lua
All MySQL table creation and database access functions.
Tables (32 total)
Group Core
| Table | Purpose |
|---|---|
wtf_groups | Group data (id, leader, type, data, locked, cooldown) |
wtf_group_members | Member list (group_id, citizenid, name, role, pending) |
wtf_group_roles | Role assignments (group_id, citizenid, role) |
wtf_group_activity_log | Completed task history |
wtf_group_reputation | Group XP, level, stats |
wtf_group_spawns | Custom spawn points |
Features
| Table | Purpose |
|---|---|
wtf_tasks | Active/completed tasks |
wtf_global_cooldowns | Per-player activity cooldowns |
wtf_group_alliances | Alliance/war relationships |
wtf_turfs | Claimed territories |
wtf_turf_challenges | Pending turf challenges |
wtf_bounties | Bounty board entries |
wtf_mailbox | Internal group mail |
wtf_garage | Group vehicle storage |
Tablet
| Table | Purpose |
|---|---|
wtf_tablet_app_data | Per-player app data (key-value) |
wtf_tablet_notifications | Notification log |
wtf_tablet_settings | Per-player tablet settings |
wtf_tablet_installed_apps | Per-player installed apps |
VPN
| Table | Purpose |
|---|---|
wtf_vpn_proxies | VPN proxy definitions (seeded from config) |
wtf_vpn_license_keys | License keys for premium proxy access |
Auction
| Table | Purpose |
|---|---|
auction_listings | Auction listings (items, vehicles, shops) |
auction_bids | Bid history per auction |
auction_watchlist | Player watchlist |
auction_balances | Player auction balances |
auction_accounts | Auth accounts (username/password) |
auction_sessions | Session tokens |
auction_settings | Key-value settings |
Contracts
| Table | Purpose |
|---|---|
wtf_contract_stock | Global stock per contract type |
wtf_contract_active | Global lock (one active per type) |
wtf_contract_inventory | Player-owned contracts |
wtf_contract_start_queue | FIFO start queue for locked types |
wtf_contract_history | Purchase/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) → secondsMembers
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|nilReputation
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