# qb-newsjob

`qb-newsjob` equips the `reporter` job. It provides a newsroom, a liveried van, and three pieces of
equipment: a camera, a handheld microphone, and a boom microphone. Using an item toggles the
corresponding client-side view or prop.

It grants no money and holds no persistent state. Reporter income is expected to come from your own
roleplay economy rather than from this resource.

The manifest at the commit linked above declares version `1.5.0`.

## Dependencies and start order

The manifest declares no dependencies and loads `config.lua`, `@qb-core/shared/locale.lua`, and
locales as shared scripts, then `client/main.lua`, `client/spawner.lua`, `client/camera.lua`, and
`server/main.lua`.

The implementation requires more than the manifest admits:

| Resource | Used for | Consequence if missing |
| --- | --- | --- |
| `qb-core` | Core object, commands, usable items | Resource does not load |
| [qb-vehiclekeys](/docs/resources/qb-vehiclekeys) | `exports['qb-vehiclekeys']:HasKeys(src, plate)` | Trunk stocking always refuses |
| [qb-inventory](/docs/resources/qb-inventory) | `CreateInventory`, `AddItem` | Trunk stocking fails |
| [qb-menu](/docs/resources/qb-menu) | `exports['qb-menu']:openMenu` in the spawner | Vehicle menu does not open |
| `LegacyFuel` | `exports['LegacyFuel']:SetFuel` in the spawner | Client error on vehicle spawn |

`LegacyFuel` is the one to watch. If you run [qb-fuel](/docs/resources/qb-fuel) or another fuel
resource instead, edit `client/spawner.lua` before starting this resource.

Start order: `qb-core`, `qb-inventory`, `qb-vehiclekeys`, `qb-menu`, your fuel resource, then
`qb-newsjob`.

## Configuration

| Key | Default | Meaning |
| --- | --- | --- |
| `Config.UseableItems` | `true` | `true` registers the equipment as usable items. `false` registers `/newscam`, `/newsmic`, and `/newsbmic` chat commands instead |
| `Config.Locations` | table | `main`, `inside`, `outside`, and the `vehicle` spawn with its liveried `rumpo` |
| `Config.VehicleItems` | three entries | Items placed into a spawned van's trunk, keyed by inventory slot |

`Config.VehicleItems` at this commit places `newscam`, `newsmic`, and `newsbmic` into slots 1, 2,
and 3. All three must exist in your shared items list.

## Item and command surface

Both modes carry the same job check. The handler resolves the player from `source` and requires
`PlayerData.job.name == 'reporter'` before firing the client event.

| Item or command | Client event triggered |
| --- | --- |
| `newscam` | `Cam:ToggleCam` |
| `newsmic` | `Mic:ToggleMic` |
| `newsbmic` | `Mic:ToggleBMic` |

The `Cam:` and `Mic:` event names are not namespaced to this resource. Check for collisions before
adding another camera or microphone script.

## Trunk stocking

```lua
RegisterNetEvent('qb-newsjob:server:addVehicleItems', function(plate)
```

The one server event. It requires the caller to hold the `reporter` job and to hold keys for the
supplied plate through `exports['qb-vehiclekeys']:HasKeys(src, plate)`, then creates a
`trunk-<plate>` inventory and fills it from `Config.VehicleItems`.

The key check is what stops a client from stocking an arbitrary plate, so it is load bearing. It also
means the whole feature silently does nothing on a server that does not run `qb-vehiclekeys`.

Nothing prevents the same plate from being stocked repeatedly. Each call rewrites the configured
slots, so a reporter can refill a van by re-triggering the flow rather than by finding new equipment.

## Integration example

Reacting to a reporter going live from your own client resource:

```lua
-- client side
AddEventHandler('Cam:ToggleCam', function()
    -- your own broadcast state, overlay, or voice channel switch
end)
```

## Troubleshooting

| Symptom | Likely cause |
| --- | --- |
| Items do nothing | The player's job is not exactly `reporter` |
| Items are not usable in the inventory | `Config.UseableItems` is `false`, so the commands are registered instead |
| Trunk is empty after spawning the van | `qb-vehiclekeys` is not started, or the player does not hold keys for that plate |
| Client error on van spawn | `LegacyFuel` is not installed. Edit `client/spawner.lua` |
| Vehicle menu never opens | `qb-menu` is not started |
| Item names missing | `newscam`, `newsmic`, or `newsbmic` is absent from your shared items |

## Proposed manual smoke test

Not yet executed. On staging:

1. Confirm the three items exist in your shared items list.
2. Take the `reporter` job, spawn the van, and confirm the trunk is stocked.
3. Use each item and confirm the matching client toggle.
4. Attempt the same without the job and confirm nothing happens.
5. Set `Config.UseableItems = false`, restart, and confirm the three commands work instead.

## Sources

- [fxmanifest.lua](https://github.com/qbcore-fivem/qb-newsjob/blob/894aa69ff592f1b424e8671a467f232e40d328da/fxmanifest.lua)
- [config.lua](https://github.com/qbcore-fivem/qb-newsjob/blob/894aa69ff592f1b424e8671a467f232e40d328da/config.lua)
- [server/main.lua](https://github.com/qbcore-fivem/qb-newsjob/blob/894aa69ff592f1b424e8671a467f232e40d328da/server/main.lua)
- [client/spawner.lua](https://github.com/qbcore-fivem/qb-newsjob/blob/894aa69ff592f1b424e8671a467f232e40d328da/client/spawner.lua)
