Notes and limits

Script lifetime and subscriptions

  • Clean up in onUnload. Stopping a script automatically removes its leet.packets subscriptions, but not its other subscriptions, RAGE event handlers or timers. Only your onUnload handler does. A script using only packet subscriptions gets automatic Stop cleanup; other subscriptions need your onUnload handler or live until reconnect.
  • Reconnect resets everything. On reconnect, all leet.events subscriptions (browser, admins, drawing), all leet.packets subscriptions (RPC selectors included) and all onUnload handlers 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, onBrowserExecute and onBrowserCall; and at most 32 onUnload handlers per script. Going over a limit throws leet: too many subscriptions. Keep off() 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.name is the readable name when the client knows it, otherwise call.wireName. Use call.name for display and call.wireName for exact wire matching.
  • Browser calls are never blocked. onBrowserExecute / onBrowserCall can only rewrite the code or the arguments. Keep their callbacks short.

Packets

  • Use leet.packets for synchronous incoming/outgoing edits and raw.on for 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.set changes the same state the menu shows, and it is saved if the user saves their config. Read previous values with get and restore them in onUnload. Pressing Stop does not undo feature changes; only your onUnload handler does.
  • Feature names are case-insensitive. Only the listed names are available. get returns undefined for anything else, and set / trigger throw.

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.notify every 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 mp player object or a remote id (integer 0 to 65535). Anything else throws leet: invalid player. Unknown or absent players are simply not admins or friends; get returns null for 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 every onDraw.
  • Distances are null for players too far away to be visible.
  • In admins() and onAdminNearby, hidden admins (close but invisible) always have distance 0 and always count as inside any onAdminNearby radius. get() and all() show them like any invisible player (distance null).
  • Every onAdminNearby event about a hidden admin, the leave event included, has hidden: true and distance: 0. A non-hidden admin who left the server comes with distance: null and dimension: 0, and keeps the last known name.
  • onAdminNearby is 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 until off() or reconnect, and must be removed in onUnload.

Drawing

  • Drawing works only inside leet.events.onDraw handlers. What the handlers draw stays on screen until their next call. Remove your onDraw subscription in onUnload, or the drawing stays.
  • Coordinates are screen pixels from the top-left corner, colors are 0xAARRGGBB. Write the alpha: 0xFF0000 is invisible.
  • Limits: 4096 draw calls per frame for all scripts together, 65536 polyline points per frame, 2 to 1024 points per drawPolyline, 256 characters per drawText, coordinates within ±100000, corner rounding 0 to 100000, thickness 0.5 to 50, text size 6 to 128.
  • At most 32 onDraw subscriptions exist in the whole client.
  • leet.ui.screen() and leet.ui.textSize() work anywhere. textSize width 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.driveTo cancels the drive in progress ("cancelled"). Arrival counts height too, so give a z near the ground. Switching off vehicle.autopilot stops the drive; do it in onUnload. 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.setVariable exist 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.
Next: Code editor