# Troubleshooting

## Troubleshooting

Common issues and how to resolve them.

## The Boss NPC Does Not Appear

* Verify the resource is started and there are no Lua errors in the server console.
* Check that the coordinates in `bossNPC.coords` are accurate. Use an in-game coordinate tool to verify.
* Confirm your target resource (qb-target or ox\_target) is started before this resource.
* If the store has a `job` restriction, make sure your character has that job assigned in the database.

## No Target Interaction on the NPC

* Confirm the target resource is running. Check `Config.TargetResource` in `config.lua`.
* If using `'auto'`, check the server console — the detected target resource is printed on startup.
* Try setting `Config.TargetResource` to your target resource name explicitly instead of `'auto'`.
* Make sure you are within interaction range of the NPC (default: 2.0 units).

## Item Images Are Broken

* Check `Config.InventoryResource`. Try setting it explicitly instead of using `'auto'`.
* Verify the image path in `Config.ItemImagePaths` for your inventory is correct.
* Make sure the item name in your store config matches the PNG filename in your inventory's image folder exactly (case-sensitive on Linux servers).
* Add a custom path entry to `Config.ItemImagePaths` if your inventory is not in the default list.

## Database Tables Not Found / oxmysql Errors

* Confirm you have run the `sql.sql` file against your database.
* Make sure oxmysql is started before this resource in `server.cfg`.
* If upgrading from v1.0, run the ALTER TABLE migration statements from the bottom of `sql.sql`.
* Check for typos in the table names if you modified the SQL file manually.

## Players Cannot Place an Order

* Check that the item names in `Config.Stores[n].items` exist in your QBCore items list.
* Check that the player has enough cash for the order total.
* Check that the player does not already have an active mission in progress.
* Check that the cooldown has expired (default: 10 minutes since the last order).
* Check the maximum items per order limit — the player may have selected more item types than allowed.

## Supplier NPC Does Not Spawn

* Confirm the `supplierNPCs` list for the store has at least one entry.
* Check that the model name is a valid GTA ped model string.
* Verify the coordinates are accessible (not inside a building at a position that would block the ped).
* Check server console for Lua errors triggered after the order is confirmed.

## Auto-Sell NPC Is Not Visible to Other Players

* The auto-sell NPC is spawned client-side by broadcasting `RES:spawnAutoSellNPC` to all clients. If another player joined after the NPC was spawned, they may miss the event. This is a known limitation — consider restarting the resource or relogging as a workaround until a persistence fix is in place.
* Verify the `autoSellNPC.coords` are correct and the NPC model is valid.

## Payment Is Not Being Received

* Check `Config.UseManagement`. If `true`, revenue goes to the management fund, not directly to cash.
* Check `Config.PaymentAccount`. The buyer pays from this account type (`'cash'` or `'bank'`).
* Confirm the store owner's citizen ID is being stored correctly as the active store owner (check the `ammo_autosell_status` table).

## Stash Password Prompt Loops / Cannot Access Stash

* If the password is forgotten, the player can use the Reset Password button in the password modal.
* Admins can manually delete the row from `ammo_stash_passwords` for the affected player and store: `DELETE FROM ammo_stash_passwords WHERE citizenid = 'CITIZENID' AND store_id = 'STOREID';`

## Resource Name Mismatch Errors

If you see errors referencing an event or NUI callback that does not match your folder name, it means the resource was cached under a different name. Fully restart the server (not just the resource) after renaming the folder to ensure FiveM picks up the new resource name.

## Enabling Debug Logging

There is no built-in debug flag. To troubleshoot server-side logic, add temporary `print()` statements in `server.lua` and monitor the server console. For client-side issues, use `print()` in `client.lua` and view the output in the FiveM client F8 console.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://mohssins.gitbook.io/mohscriptsdocs/moh-businesssystem/troubleshooting.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
