tgiann-npc-guide
A story-telling guide NPC for your server. Players walk up to a configured NPC (by default a wise old man downtown for the legal side and a retired robber under the bridge for the illegal side), press the interaction key and a dialogue UI opens. Every visit the NPC tells the player one story about the server: how to find a job, how licenses work, where the workbenches are, how the robbery queue works, and so on. Stories are written by you in the config, so the NPC explains your server.
Features
Any number of NPCs, each with its own model, position, scenario, lines, stories, cooldown and voice.
One new story per visit, told in config order or randomly. A per-NPC cooldown (1 hour by default) decides when the player can ask for the next one.
Everything the player has heard is saved to the database. The What you remember tab lists every story that was told and lets the player replay it at any time.
Dialogue UI with a typewriter effect, a skip button and a mute button.
Voice: pre-generated audio files (made with the included generator, see Voice Generator), browser text to speech, or silent. Missing files can fall back to browser TTS automatically.
Cinematic camera that frames the NPC while the conversation is open.
Every text (name, title, lines, stories) can be a plain string or a language table (
{ tr = "...", en = "..." }). The player's language picks the text; a missing language falls back to the default language.NPC peds are only spawned when a player is close, so they cost nothing while nobody is around.
How a conversation works
The player walks to the NPC. Inside
maxDistancean interaction prompt appears; insidepressDistancethe player can press the key to start talking.The camera moves to the configured offset and the NPC greets the player with a random line from
lines.greetings(or fromlines.waitGreetingswhile the player is still on cooldown).Tell me something asks for a new story. If the cooldown is over and untold stories remain, the NPC says a
thinkingline, then the story. The story is saved for the player and the cooldown starts. Otherwise the NPC answers with thecooldownline (the remaining time replaces%s) or thenothingLeftline when every story has been told.What you remember opens the list of stories already heard (
told / total). Clicking one makes the NPC tell it again, without touching the cooldown.Goodbye plays a random
goodbyesline and closes the dialogue.
Installation
Make sure
tgiann-core,ox_libandoxmysqlare installed and started before this resource.Put the resource in your resources folder and add
ensure tgiann-npc-guideto your server.cfg aftertgiann-core.The database table
tgiann_npc_guide_playeris created automatically on the first start (tgiann-core database creator). No SQL to import.Edit config.lua to place your NPCs and configTips.lua to write the stories.
Optional: generate the voice files for your texts with the Voice Generator, or switch the NPC voice to
browser/off.
Commands
Both commands are restricted to the group.admin ace.
/npcguidereset [npc] [playerId]
Clears the story cooldown. npc is an NPC id from the config (leave empty for every NPC), playerId is the target player (leave empty for yourself).
/npcguidevoices
Prints the browser TTS voices installed on your client to the F8 console. Use a part of a voice name as tts.voiceHint.
Adding a new NPC
Add a new entry to
config.npcGuide.npcsin config.lua with a uniqueid. Theidis saved per player, so do not rename it once the script is live.Add
config.npcGuideTips.<id>in configTips.lua with the stories of this NPC. Every story needs a unique, stableid.If the NPC should speak with audio files, add a block for its
idingenerator/voices.json(otherwise thedefaultvoices are used) and run the generator.Restart the resource.
Folder overview
configs/config.lua
NPCs: model, coords, lines, cooldown, camera, voice and TTS settings.
configs/configTips.lua
The stories, keyed by NPC id.
languages/*.lua
Notification and UI texts.
client/editable.lua, server/editable.lua
Open (non-escrow) hooks, see Editable Files.
sounds/<npc id>/
Voice files, one per line / story / language.
generator/
Voice generator (Python + edge-tts), see Voice Generator.