Repository navigation
GameDb
Bartholomew Ho edited this page Nov 15, 2026
·
1 revision
The game's database and string lookups while it runs: rewrite the SQL the game sends to gamedb, and answer string keys no string table has. With Mod.AddSql (new rows) and Mod.SetFile (icons), these make a custom upgrade part, as FnFNitro's NOS kit and FH2 Underglow's kit are made.
New in 0.12.0.
Thread: add and remove from any thread. Your functions run on whichever thread the game asked from, often the game's own.
protected override void OnInit()
{
// a part of our own, in rows added with AddSql, named through a string key no table has
GameDb.AddStringAnswer((table, key) => key == 60001 ? "Turbo kit" : null);
// and a query seen (or changed) as the game runs it: null leaves it as it is
GameDb.AddQueryRewriter(sql =>
{
if (sql.Contains("Profile0_Career_PurchasedParts")) Log(sql);
return null;
});
}| Member | What it does |
|---|---|
AddQueryRewriter(Func<string, string?> rewriter) |
Gets each SQL statement the game runs on gamedb and gives back the one to run instead, or null to leave it. |
RemoveQueryRewriter(Func<string, string?> rewriter) |
Stops it. |
AddStringAnswer(Func<int, int, string?> answer) |
Gets the table (as the game numbers it while it runs) and the key of a string the game looked up and found nothing for, and gives back the text, or null. |
RemoveStringAnswer(Func<int, int, string?> answer) |
Stops it. |
- Every query goes through your rewriter, often many a frame in the garage. Keep it fast, and give back null for the ones you leave alone.
- A string answer is only asked for when the game found nothing, so use keys the game doesn't have.
- The hooks go in the first time you add one. The database query is found a moment after the game starts; until then statements run as they are.
- A hosted mod's functions go when it's reloaded.
- For text the game already has,
Mod.SetStringedits the string tables instead. For text in every language, see Translations.
Playing
Getting started
Writing mods
- Hosted or NativeAOT?
- Threads
- Reloading and debugging
- Reading game memory safely
- Pop-ups, tips and message boxes
- Translations
The FH2 classes
- Game
- Player
- Vehicle
- World
- Garage, CarCatalog, Profile
- UI and Hud
- Camera
- Audio
- ANNA
- Skills
- Radio
- Livery
- GameDb
- DebugOverlay
- Controller
- GameInput
- GameWindow
- Menus and UiElement
- SettingsTile
- ButtonIcons and Picture
- MapView, PhotoCamera, GarageCamera
More