AI Core

ai-streetraces for developers

ai-streetraces has no exports. Its police alert, ledger reasons and private events.

ai-streetraces has no exports or state bags. Races live in the server's memory only, and money, alerts and the menu item go through AI Core.

Police alert

When a race's countdown starts, it may send one alert (by the panel's Alert chance) through the lib's dispatch.alert: the "Street race" title, the "(count) vehicles lining up for an illegal race" message, at the start line, with the first racer as source, icon flag-checkered. It reaches whichever alert script runs.

Money

All money moves on the panel's Money account with these ledger reasons:

ReasonWhen
streetrace:<raceId>A buy-in is taken on create or join.
streetrace:refundA buy-in comes back (left before the start, cancelled, too few racers, resource stop).
streetrace:wonThe winner gets the pot.
streetrace:splitThe time limit ran out; each racer still in gets a share.

Opening the menu from another script

The server opens the race menu with the client event ai-streetraces:client:openMenu (what /race does). Use it to put the menu on your own phone app or interaction point.

Side: Server -> client · Arguments: none

// server
emitNet("ai-streetraces:client:openMenu", source);

The menu shows only what the player can do now (create to the waypoint, join an invitation, start, cancel, leave or give up), and every choice is checked on the server, so opening it for anyone is safe.

Private events and callbacks

The script's own contract (resource/common/race.ts). The server checks the vehicle, the distance, the money and the race state on every call. They may change between versions: do not trigger or listen to them from other resources.

NameDirectionWhat it carries
ai-streetraces:createclient callback(buyIn, finishX, finishY): create a race from the player's position to the finish.
ai-streetraces:joinclient callback(raceId): join a race the player was invited to (pays the buy-in).
ai-streetraces:leaveclient callback(): leave the race; the host leaving before the start cancels it.
ai-streetraces:beginclient callback(): the host ends the join time now.
ai-streetraces:finishclient callback(): the racer reached the finish.
ai-streetraces:client:stateserver -> racer(race, serverNow): a snapshot of the race the player is in.
ai-streetraces:client:racerserver -> racers(racer, pot): a racer joined.
ai-streetraces:client:racerLeftserver -> racers(racerId, pot): a racer left.
ai-streetraces:client:startserver -> racers(startAt, serverNow): the countdown runs; GO at startAt (server clock).
ai-streetraces:client:endedserver -> racer(): the race is over for this player.
ai-streetraces:client:inviteserver -> players near a new race(invite, serverNow).
ai-streetraces:client:uninviteserver -> invited players(raceId): the race no longer takes racers.

On this page