Skip to content

Latest commit

 

History

History
280 lines (220 loc) · 18.1 KB

database.md

File metadata and controls

280 lines (220 loc) · 18.1 KB

Database

Every table the Framework defines, grouped by feature. Use it to look up a table or column.

The code for these tables lives in three places:

  • the models in Database/Models/;
  • the DbSets in BaseDataContext;
  • the rules (keys, lengths, relationships) in each feature's Models/Configuration(s) folder.

Common columns. Every model inherits BaseModel:

Column Type Meaning
Id ulong Primary key, auto-increment
CreatedOn DateTime (UTC) Set on insert
UpdatedOn DateTime (UTC) Set on insert and update

The BaseManager sync relies on CreatedOn and UpdatedOn.

Notation. "→ X" means a foreign key to table X. "cascade" or "set null" is what happens to the row when X is deleted.

The host owns the actual schema and its migrations; see Seed data and migrations.

Accounts

Accounts (AccountModel)

Column Type Meaning
Username string Login name
Password string BCrypt hash
Level, Experience uint Account level (not used by Framework features yet)
IsOnline bool Logged in on some server right now (one login per account)
LastSeenAt DateTime? Last time the server holding the login confirmed it

AccountSettings (AccountSettingsModel)

One row per account, → Accounts (cascade).

Column Type Meaning
AccountId ulong The account
AccountGraphicPreset enum Low, Medium, High, VeryHigh, Ultra
GlobalChatEnabled bool Default true
NewbieChatEnabled bool Default true

Characters

Characters (CharacterModel)

Column Type Meaning
FirstName, LastName string(35) Name
MiddleName string(30)? Optional middle name
DateOfBirth DateTime
Accent string(30)? Shown in talk messages, for example "[French accent]"
Skin int Skin model, default 26
InventoryId ulong? → Inventories (cascade). Every new character gets one automatically.
AccountId ulong? → Accounts

CharacterPreferences (CharacterPreferencesModel)

Column Type Meaning
CharacterId ulong → Characters
HardcoreMode bool Consents to everything; can't be turned off
AllowCharacterKill, AllowRape, AllowSlavery, AllowWorldEvents bool Consent settings
DefaultCurrencyId ulong The currency shown as GTA money

Skills (SkillModel) and CharacterSkills (CharacterSkillModel)

  • Skills has Name and Description. The skills themselves are seeded by the host. Fishing looks for a skill named Fishing.
  • CharacterSkills has CharacterId and SkillId, plus Level, Experience and LastUsedDate.

Permissions

Table Columns Notes
Permissions (PermissionModel) Name (unique), Description cmd.<command>, faction.*, …
PermissionGroups (PermissionGroupModel) Name (max 100) Seeded: Default, Admin, Tester, Faction
PermissionGroupPermissions (PermissionGroupPermissionModel) PermissionGroupId → groups (cascade), PermissionId → permissions (cascade), GamemodeManaged GamemodeManaged links are synced from [ServerCommand] attributes
CharacterPermissionGroups (CharacterPermissionGroupModel) CharacterId → characters (cascade), PermissionGroupId → groups (cascade)

See Permissions.

Factions

Table Columns Notes
Factions (FactionModel) Name, ParentFactionId → Factions, Type (None, Government) Factions form a tree
FactionRanks (FactionRankModel) FactionId → factions (cascade), ParentRankId → ranks (cascade), Name (max 64) The rank without a parent is the top (leader) rank
FactionMembers (FactionMemberModel) CharacterId → characters (cascade), FactionId → factions (cascade), FactionRankId → ranks (cascade), IsActive Unique per character + faction. IsActive marks the faction that faction chat goes to
FactionPermissions (FactionPermissionModel) FactionId → factions (cascade), PermissionId → permissions (cascade) A faction's grants. Unique per faction + permission
FactionRankPermissions (FactionRankPermissionModel) FactionRankId → ranks (cascade), PermissionId → permissions (cascade) A rank's grants. Unique per rank + permission

See Factions.

Phones

Table Columns Notes
Phones (PhoneModel) Number (unique), IsOn, IsSilent, BatteryLevel (percent), BatteryUpdatedAt (nullable) Random 7-digit numbers; below 1000 is reserved for the server
PhoneContacts (PhoneContactModel) PhoneId → phones (cascade), Name (24), Number The phone book. Unique per phone + number; at most 50 per phone
PhoneMessages (PhoneMessageModel) PhoneId → phones (cascade), OtherNumber, Text (160), IsIncoming, IsRead, SentAt Each phone keeps its own copy; the last 20 per phone
PhoneCallLogs (PhoneCallLogModel) PhoneId → phones (cascade), OtherNumber, Type (Incoming, Outgoing, Missed), StartedAt, DurationSeconds, IsSeen The last 20 per phone

See Phones.

Radios

Table Columns Notes
Radios (RadioModel) Frequency, IsOn, UsesEarpiece, BatteryLevel (percent), BatteryUpdatedAt (nullable), VehicleId → Vehicles (cascade, unique) A handheld (its item points to it) or, with VehicleId, a vehicle radio
RadioFrequencies (RadioFrequencyModel) Number (unique), Name (32), Mode (Protected, Encrypted) Only frequencies with their own rules; others follow the defaults
RadioFrequencyFactions (RadioFrequencyFactionModel) RadioFrequencyId → frequencies (cascade), FactionId → factions (cascade) The factions on a frequency. Unique per frequency + faction

See Radios.

Banking

Table Columns Notes
Banks (BankModel) Name (32), Code (4, unique), JurisdictionId → jurisdictions (restrict), RunByFactionId → factions (set null), MonthlyFee decimal(18,2) The code and the jurisdiction's tag are part of every OBAN
BankAccounts (BankAccountModel) Oban (18, unique), BankId (restrict), CurrencyId (restrict), Balance decimal(18,2), OwnerType (Character, Faction, Property, Bank), OwnerId, Name (32), ClosedAt, NextFeeAt The balance only changes through single updates. Owner type Bank is the bank's own account, without a fee
BankAccountAccess (BankAccountAccessModel) BankAccountId (cascade), CharacterId (cascade), Level (View, Full) Unique per account + character
BankTransactions (BankTransactionModel) BankAccountId (cascade), Amount (signed), BalanceAfter, Type, OtherOban, CharacterId (set null), BankCardId (set null), Description (64), CreatedOn An account's history. BankCardId marks ATM and card use; the ATM limit adds up a card's withdrawals by it
BankBranches (BankBranchModel) BankId (cascade), PropertyId (cascade, unique) Tellers only work inside their bank's branches
BankTellers (BankTellerModel) ActorId (cascade, unique), BankId (cascade)
BankCards (BankCardModel) BankAccountId (cascade), CharacterId (cascade), Digits (4), Name (32), PinHash (BCrypt), WrongPinAttempts, BlockedAt, CancelledAt A debit card; its item stores [BANK_CARD_ID=n]
BankPendingDeposits (BankPendingDepositModel) BankAccountId (restrict), BankCardId (set null), CharacterId (set null), Amount, CreditAt, CreditedAt, AtmX, AtmY, AtmZ, AtmInterior, AtmVirtualWorld Cash put into an ATM, credited at CreditAt; the ATM's position says where the cash sits until then

See Banking.

Jurisdictions

Table Columns Notes
Jurisdictions (JurisdictionModel) Name (64), TwoLetterTag (2), ThreeLetterTag (3), FourLetterTag (4), ParentJurisdictionId → Jurisdictions (restrict), CurrencyId → Currencies (set null), GovernmentFactionId → Factions (set null) A tree; no parent = a country. Each tag is required and unique. Null currency or government = the parent's
FactionTaxRegistrations (FactionTaxRegistrationModel) FactionId → factions (cascade), JurisdictionId → jurisdictions (cascade) Where a faction pays taxes. Unique per faction + jurisdiction
JurisdictionSettings (JurisdictionSettingModel) JurisdictionId → jurisdictions (cascade), Key (64), Value (64, null = inherits), BindsSubJurisdictions One row per jurisdiction and setting key. A row with neither a value nor a binding is removed. Unique per jurisdiction + key

See Jurisdictions and Jurisdiction settings.

Items, inventories and money

Items (ItemModel)

The item types (definitions), not the items players own.

Column Type Meaning
Name string(255)
Description string?
UseType ItemType Skin, Wallet, Currency, Attachment, VehicleKey, Misc, Fish, Phone, Radio, RadioEarpiece
UseValue string? Meaning depends on UseType, for example the skin id or currency unit id
Weight uint Grams per unit
MaxUses uint? Uses before it's used up
KeepOnDeath, CanDrop, CanDestroy, Stackable bool
DropModelId int? Object model shown when dropped

The Framework seeds 68 items:

  • a uniform (skin);
  • a wallet;
  • the bills and coins of the San Andreas Dollar and the Caeroyna Ruble;
  • a vehicle key;
  • the hotwire tools (rusty paperclip, worn-out screwdriver, roll of electrical tape);
  • a chicken egg;
  • twelve fish species;
  • a mobile phone (item 49, UseType Phone). Each phone item points to its row in Phones with [PHONE_ID=x];
  • a handheld radio (item 50, UseType Radio), pointing to its row in Radios with [RADIO_ID=x], and a radio earpiece (item 51);
  • fishing gear (rod 52, bait 53, net 54), junk (55 to 57), treasures (58 to 61), four net-only fish (62 to 65) and two small saltwater fish (66 and 67);
  • a debit card (item 68, UseType BankCard), pointing to its row in BankCards with [BANK_CARD_ID=x].

Inventories (InventoryModel)

Name, MaxWeight (grams, null = unlimited). Seeded: "World Inventory", which holds items lying on the ground.

InventoryItems (InventoryItemModel)

An item someone or something owns.

Column Type Meaning
ItemId ulong → Items (cascade)
InventoryId ulong → Inventories
Amount uint Stack size
UsesRemaining uint?
KeepOnDeath, CanDrop, CanDestroy bool Copied from the item, can differ per stack
AdditionalData string? Key/value data, for example DEFAULT_WALLET, WEARING or the vehicle id of a key. See Inventories
Weight uint? Overrides the item weight, for example for a fish

An item that holds an inventory (a wallet) links to that inventory through its additional data.

DroppedInventoryItems (DroppedInventoryItemModel)

InventoryItemId → InventoryItems (cascade, one-to-one), PosX/Y/Z, RotX/Y/Z. The inventory item itself sits in the world inventory.

Currencies (CurrencyModel) and CurrencyUnits (CurrencyUnitModel)

  • Currencies has CurrencyCode and Name (max 100). Seeded: SAD (San Andreas Dollar), CRU (Caeroyna Ruble), USD (United States Dollar).
  • CurrencyUnits has CurrencyId → Currencies (cascade) and UnitValue (decimal), for example 20.00. 29 units are seeded. Each bill or coin is an item whose UseValue points to its unit.

World

PropertyDoors

Table PropertyDoors (PropertyDoorModel).

Column Type Meaning
Name string
PropertyId ulong? → Properties (cascade)
LinkedToPropertyDoorId ulong? → PropertyDoors (set null). The door this one leads to. Not unique: several doors may lead to one door
X, Y, Z, Angle float Position and facing
Interior int? The GTA interior; null or 0 = the open world's
InsidePropertyId ulong? → Properties (set null). The property whose virtual world the door is in; null = outside, in the shared world

Properties

Table Properties (PropertyModel): Name, JurisdictionId → Jurisdictions (set null; null = none).

Vehicles (VehicleModel)

Persistent vehicles.

Column Type Meaning
ModelId ulong? → VehicleModels (set null). The Id of the model row, not the GTA model id (that is VehicleModels.ModelId)
ModelSpawnTypeId ulong? → VehicleModelSpawnTypes (set null). Spawn with a random model of this type
X, Y, Z, Rotation float Parking spot
Color1, Color2 int
IsEngineOn, AreLightsOn, IsAlarmOn, AreDoorsLocked, IsBonnetOpen, IsBootOpen bool State
Is…DoorOpen, Is…WindowClosed bool Per door and window
CurrentHealth, MaxHealth float
ServerVehicle bool Belongs to the server, not a player. Database default false: an older Framework leaves the column out of an insert when it's false. Before, the default was true, so vehicles saved then may be marked as server vehicles by mistake
OwnerCharacterId ulong? → Characters
VirtualWorld, Interior int The virtual world and the GTA interior the vehicle is in. Default 0
JurisdictionId ulong? → Jurisdictions (set null). Where it's registered; its plate starts with that country's tag. Null = none, an SA plate
LoadedAs int?

Vehicle model lookups

Table Columns
VehicleModels (VehicleModelModel) ModelId (GTA model id), Name
VehicleModelDefaultColors (VehicleModelDefaultColorModel) VehicleModelId → VehicleModels (cascade), Color1, Color2
VehicleModelSpawnTypes (VehicleModelSpawnTypeModel) Name
VehicleModelSpawnTypeModels (VehicleModelSpawnTypeModelModel) VehicleSpawnTypeId (restrict), VehicleModelId (restrict)

Actors and the main menu

Table Columns
Actors (ActorModel) Name (64), Skin, X/Y/Z/Angle, Interior, AnimLibrary and AnimName (null = no animation), AnimSpeed (default 4.1), Prompt (the AI prompt, null = doesn't talk), InsidePropertyId → Properties (set null; null = outside), ActorLinkedToMainMenuSceneId → MainMenuScenes (cascade). No longer read: ActorCharacterId → Characters and ActorPromptId → ActorPrompts, to be dropped later
ActorPrompts (ActorPromptModel) Prompt. No longer read: prompts moved to Actors.Prompt
ActorPermissions (ActorPermissionModel) ActorId → actors (cascade), Permission (64); unique per actor + permission. What an actor may do, such as bank.deposit
MainMenuScenes (MainMenuSceneModel) Name

Fishing

Table FishLoot, with the DbSet named FishSpecies (FishLootModel). Columns:

  • Name (255);
  • FishLootType: Saltwater, Freshwater, Murkywater or Misc;
  • LootKind: Fish, Junk or Treasure;
  • SizeClass: None, Small, Medium, Large or Huge;
  • RequiredFishingLevel: the fishing level needed to catch it;
  • IsNetOnly: true for fish only a trawl net brings up;
  • MinWeightInGrams and MaxWeightInGrams;
  • CatchWeight: how likely it is, relative to the other possible catches;
  • ItemId → Items.

LootKind, SizeClass, RequiredFishingLevel and IsNetOnly have database defaults (Fish, None, 0, false), so servers on an older Framework sharing the database can still insert rows.

The Framework seeds ids 1 to 26. Hosts can add their own:

  • Ids from 1000 up. The Framework may seed more of the low ids later.
  • Remove your own seeds of ids 1 to 26. Hosts used to seed the fish themselves, and EF refuses two seeds with the same id.
  • Set SizeClass on your fish. A trawl net only brings up Small, Medium and Large fish, so a row left at None is never caught by a net.

CatchWeight used to be OddsToCatch, with the opposite meaning: "1 in N", so a higher number was rarer. Now a higher number is more common. A migration that only renames the column turns rare fish into common ones. Convert your own rows, for example with UPDATE FishLoot SET CatchWeight = GREATEST(1, ROUND(100 / CatchWeight)), or set new weights.

Table VehicleFishingNets (VehicleFishingNetModel) holds the nets fitted to Reefers:

  • VehicleId → Vehicles (cascade, unique);
  • StorageInventoryId → Inventories (cascade): the inventory holding the catch.

Maps

Table Columns Notes
Maps (MapModel) Name (64, unique), IsLoaded Loaded maps come back after a restart. Only a loaded map's objects are in the game
MapObjects (MapObjectModel) MapId → Maps (cascade), ModelId (negative = custom model), X/Y/Z, RotX/RotY/RotZ, VirtualWorld, Interior (-1 = everywhere), Description (64), StreamDistance (float, nullable: null = the default 300 m) Each object has its own world and interior. The columns have no database default: new objects get -1 from the model. A null stream distance means the default
MapObjectMaterials (MapObjectMaterialModel) MapObjectId → MapObjects (cascade), MaterialIndex (0 to 15), Type (Texture or Text), ModelId, TxdName (64), TextureName (64), Color (ARGB, 0 = original colour), Text (256), MaterialSize, FontFace (64), FontSize, Bold, FontColor, BackColor, Alignment (0 left, 1 centre, 2 right) Unique per object + material index. Texture columns are used for textures, text columns for text
MapRemovedBuildings (MapRemovedBuildingModel) MapId → Maps (cascade), ModelId, X/Y/Z, Radius A GTA building removed for the players of a map

See Maps.

Want more? → Persistence · Glossary