ai-robberies for developers
The GlobalState keys of robbed targets, the house metadata, the alerts and ledger reasons of ai-robberies, and its private events.
ai-robberies has no exports. Places and targets are panel data, and rewards, tools, alerts and doors go through AI Core. What another script can read is listed below.
GlobalState rob:<targetId>
true while a target is robbed and waits for its place's cooldown, false after the cooldown. The server writes it; every client can read it. At resource start every key is reset. Target ids are the record ids of the Targets tab (store_1_register_1, store_1_safe, vangelico_vitrine_1...).
Side: Server and client (read) · Waits: no
GlobalState[`rob:${targetId}`]: boolean | undefinedlocal emptied = GlobalState['rob:' .. targetId] == trueReturns
true while emptied. false after the cooldown ended, undefined / nil when the target was not robbed since the resource started.
Example
Show a "robbed" mark in your own store script while the safe is emptied:
// client
const SAFE = "store_1_safe";
AddStateBagChangeHandler(`rob:${SAFE}`, "global", (_bag: string, _key: string, value: unknown) => {
const emptied = value === true;
// ... show or hide your mark
});
const emptiedNow = GlobalState[`rob:${SAFE}`] === true;Read these keys, never write them: ai-robberies owns them and sets them from its own timers. A value written by another script leaves the server's checks and the clients' labels out of step.
Character metadata robbery_house
The id of the house place a character is inside (house_12), or null when outside. ai-robberies sets it when the robber breaks in and clears it when they leave. A character who left the game inside a house is put back at the house door on their next load.
Police alerts
Sent through the lib's dispatch.alert, so they reach whichever alert script runs:
| When | Code | Title | Icon | Priority |
|---|---|---|---|---|
| The first robbery of a visit (by the place's alert chance) | 10-90 | Robbery alert text, with the place's name as the message and the place's alert point as coords | sack-dollar | high |
| An armored truck job starts | 10-90 | Armored truck alert text, at the robber's position, blip sprite 67 red | truck | high |
Money
Stolen money goes to the panel's Money account with the ledger reason robbery:<placeId> (for example robbery:store_1).
Doors
A door target with a Doorlock door id is unlocked through AI Core's door layer (lib doors.setLocked) and locked again when the place's cooldown ends.
Private events and callbacks
The script's own contract (resource/common/robbery.ts). The server checks police count, distance, items and claims on every call. They may change between versions: do not trigger or listen to them from other resources.
| Name | Direction | What it carries |
|---|---|---|
ai-robberies:start | client callback | (targetId): start robbing a target; answers { ok, entered? }. The server runs the progress bar and the reward. |
ai-robberies:exit | client callback | (): leave the house the player is inside. |
ai-robberies:client:inside | server -> player | (placeId | null, to): the player is inside this house now (or left); teleport to to. |
ai-robberies:truckStart | client callback | (): pay for an armored truck job at the giver. |
ai-robberies:client:truckJob | server -> player | (netId, x, y, z): the truck to rob and its rear doors. |
ai-robberies:truckPlant | client callback | (): plant the charge (server-run progress bar; the doors blow after the fuse). |
ai-robberies:client:truckOpen | server -> players near the truck | (netId): the rear doors are open. |
ai-robberies:truckLoot | client callback | (): grab the cash (server-run progress bar). |
ai-robberies:client:truckEnd | server -> players who knew the truck | (): the truck job is over. |