Notes and limits
Script lifetime and subscriptions
- Clean up in
onUnload. Stopping a script automatically removes itsleet.packetssubscriptions, but not its other subscriptions, RAGE event handlers or timers. Only youronUnloadhandler does. A script using only packet subscriptions gets automatic Stop cleanup; other subscriptions need youronUnloadhandler or live until reconnect. - Reconnect resets everything. On reconnect, all
leet.eventssubscriptions (browser, admins, drawing), allleet.packetssubscriptions (RPC selectors included) and allonUnloadhandlers are dropped, and the scripts' rows return to Execute. Handlers do not fire in that case. - Subscription limits. At most 32 subscriptions of each kind at a time across the whole client: per physical packet filter, per RPC selector,
onBrowserExecuteandonBrowserCall; and at most 32onUnloadhandlers per script. Going over a limit throwsleet: too many subscriptions. Keepoff()and call it for subscriptions you no longer need. - Callbacks run synchronously. RPC selector callbacks run before the call is sent, so slow work in them delays the call. Keep callbacks short and defer heavy work (for example with
setTimeout). - Errors in callbacks are swallowed.
Remote calls and the browser
- Event names. On servers that encode event names,
call.nameis the readable name when the client knows it, otherwisecall.wireName. Usecall.namefor display andcall.wireNamefor exact wire matching. - Browser calls are never blocked.
onBrowserExecute/onBrowserCallcan only rewrite the code or the arguments. Keep their callbacks short.
Packets
- Use
leet.packetsfor synchronous incoming/outgoing edits andraw.onfor exact bits. Keep callbacks short and check carried fields before writing. - Only returned synchronous edits apply. Packet size, ID, unused tail bits, read-only headers and opaque data must be preserved; stats are diagnostics, not a universal delivery guarantee.
Menu features (leet.features)
- Feature changes are real menu changes.
leet.features.setchanges the same state the menu shows, and it is saved if the user saves their config. Read previous values withgetand restore them inonUnload. Pressing Stop does not undo feature changes; only youronUnloadhandler does. - Feature names are case-insensitive. Only the listed names are available.
getreturnsundefinedfor anything else, andset/triggerthrow.
Notifications
- A notification holds up to 160 Latin or 80 Cyrillic characters. Identical ones posted at the same moment are shown once, and only a few get through per frame. Do not call
leet.ui.notifyevery frame.
Teleports and saved points
- One teleport at a time. Starting a teleport from a script, the menu, or a friend's teleport cancels the one in progress; its callback receives
"cancelled". Chain teleports through the callback instead of starting them in a loop. - A teleport callback fires once, after the teleport finishes, never during the
teleport...call. Errors thrown by it are swallowed. On reconnect, callbacks of unfinished teleports are dropped and never fire. - Saved point names are matched exactly and case-sensitively. The first point with that name is used.
Players and admins
- Player arguments are an
mpplayer object or a remote id (integer 0 to 65535). Anything else throwsleet: invalid player. Unknown or absent players are simply not admins or friends;getreturnsnullfor them. leet.players.all()builds an object for every player on the server. Call it occasionally (for example once a second) and reuse the result, not on everyonDraw.- Distances are
nullfor players too far away to be visible. - In
admins()andonAdminNearby, hidden admins (close but invisible) always havedistance0and always count as inside anyonAdminNearbyradius.get()andall()show them like any invisible player (distancenull). - Every
onAdminNearbyevent about a hidden admin, the leave event included, hashidden: trueanddistance: 0. A non-hidden admin who left the server comes withdistance: nullanddimension: 0, and keeps the last knownname. onAdminNearbyis checked about 4 times per second, so enter and leave events can come slightly after the admin crosses the radius. At most 32 subscriptions exist in the whole client. Like other subscriptions they last untiloff()or reconnect, and must be removed inonUnload.
Drawing
- Drawing works only inside
leet.events.onDrawhandlers. What the handlers draw stays on screen until their next call. Remove youronDrawsubscription inonUnload, or the drawing stays. - Coordinates are screen pixels from the top-left corner, colors are
0xAARRGGBB. Write the alpha:0xFF0000is invisible. - Limits: 4096 draw calls per frame for all scripts together, 65536 polyline points per frame, 2 to 1024 points per
drawPolyline, 256 characters perdrawText, coordinates within ±100000, corner rounding 0 to 100000, thickness 0.5 to 50, text size 6 to 128. - At most 32
onDrawsubscriptions exist in the whole client. leet.ui.screen()andleet.ui.textSize()work anywhere.textSizewidth may be off by a pixel.- Drawing appears under the client's menu and HUD.
Vehicle
- One drive at a time. A new
leet.vehicle.driveTocancels the drive in progress ("cancelled"). Arrival counts height too, so give aznear the ground. Switching offvehicle.autopilotstops the drive; do it inonUnload. A drive callback fires once, errors in it are swallowed, and on reconnect it is dropped and never fires.
Entity variables
- Entity variables set by
leet.entities.setVariableexist only on your client. The server and other players do not see them, and the next value from the server replaces yours. - The entity must exist on the server. Locally created entities give
leet: unknown entity. - Names are up to 128 characters, string values up to 4096 characters. Non-integer numbers keep about 7 significant digits. Variables cannot be removed.
- Pressing Stop does not undo the changes. Restore old values in
onUnload.