Skip to content

Login server (platform) clientside ​

Platform-only: the privileged client API available to Login Server weapons (session, server list, friends, PMs). Game-server scripts cannot use it (loginserver weapons/system.client.d.ts).

Source

Generated from GServer/bin/Debug/net8.0/loginserver/data/scripts/weapons/system.client.d.ts. To change this page, edit the JSDoc in that file.

Overview ​

Ambient declarations for LOGIN SERVER weapons. Every weapon this server grants runs on the client in the privileged SYSTEM runtime — a V8 engine of its own, separate from game servers' weapons — which the client only uses for a server proving the pinned Login Server identity key.

Weapons listed in serveroptions.json persistentWeapons are PERSISTENT: they keep running (state, timers, open windows) for the whole client session, across every server switch, until sign-out. The rest unload when the player leaves the Login Server. Returning here re-sends the weapon list; an unchanged persistent weapon keeps running (no second onCreated).

There is no world here: no findimg, flags, collections, classes, tiles or camera. What there is: the GUI (gui.client.d.ts), input, timers, player, and the privileged API below — the server list and switching, friends, and the global PM system.

Batched calls (echo, sendPM, servers.connect, ...) queue JS-side and apply at the end of the current handler; calls that return values are direct.

Declarations ​

echo function ​

ts
declare function echo(msg: string): void

Prints to the client console. Batched.

sleep function ​

ts
declare function sleep(seconds: number): Promise<void>

Cooperatively pauses the calling async script (seconds, frame resolution).

setTimeout function ​

ts
declare function setTimeout(handler: (...args: any[]) => void, ms?: number, ...args: any[]): number

Cooperatively pauses the calling async script (seconds, frame resolution).

clearTimeout function ​

ts
declare function clearTimeout(id: number): void

Cooperatively pauses the calling async script (seconds, frame resolution).

setInterval function ​

ts
declare function setInterval(handler: (...args: any[]) => void, ms?: number, ...args: any[]): number

Cooperatively pauses the calling async script (seconds, frame resolution).

clearInterval function ​

ts
declare function clearInterval(id: number): void

Cooperatively pauses the calling async script (seconds, frame resolution).

keydown function ​

ts
declare function keydown(key: string): boolean

Whether a key is held this frame ("a".."z", "0".."9", "f1".."f12", "up", "space", "leftshift", ...). False while typing in a text box or while the window is inactive. Direct call.

mousex function ​

ts
declare function mousex(): number

Mouse position in window pixels. Direct call.

mousey function ​

ts
declare function mousey(): number

Mouse position in window pixels. Direct call.

mousedown function ​

ts
declare function mousedown(button: 'left' | 'right' | 'middle'): boolean

Mouse position in window pixels. Direct call.

mouseonui function ​

ts
declare function mouseonui(): boolean

Whether the cursor is over any GUI control.

ScreenWidth global ​

ts
declare const ScreenWidth: number

Live viewport size in pixels.

ScreenHeight global ​

ts
declare const ScreenHeight: number

Live viewport size in pixels.

TextMeasurement interface ​

ts
interface TextMeasurement

Result of measuretext().

TextMeasurement.width ​

ts
width: number

TextMeasurement.height ​

ts
height: number

TextMeasurement.lineheight ​

ts
lineheight: number

TextMeasurement.lines ​

ts
lines: string[]

measuretext function ​

ts
declare function measuretext(
    text: string,
    opts?: { font?: string, fontsize?: number, style?: string, width?: number }
): TextMeasurement

Measures text the way a GuiTextCtrl renders it (width > 0 word-wraps). Direct call.

triggerServer function ​

ts
declare function triggerServer(scriptType: 'weapon' | 'script', scriptName: string, ...params: any[]): void

Asks the LOGIN SERVER to run onActionServerSide on a serverside script. Only delivered while the player is on the Login Server; elsewhere it is dropped (and logged) — persistent weapons can't reach it from game servers.

WeaponThis interface ​

ts
interface WeaponThis

this inside a system weapon's handlers.

WeaponThis.name ​

ts
name: string

WeaponThis.[key] ​

ts
[key: string]: any

WeaponHandle interface ​

ts
interface WeaponHandle

A handle on another loaded SYSTEM weapon (game servers' weapons aren't visible).

WeaponHandle.name ​

ts
readonly name: string

WeaponHandle.trigger ​

ts
trigger(event: string, ...params: any[]): boolean

findweapon function ​

ts
declare function findweapon(name: string): WeaponHandle | null

A handle on another loaded SYSTEM weapon (game servers' weapons aren't visible).

findWeapon function ​

ts
declare function findWeapon(name: string): WeaponHandle | null

A handle on another loaded SYSTEM weapon (game servers' weapons aren't visible).

player global ​

ts
declare const player: { … }

The local player on whichever server the client is on. On the Login Server (no world) only id/name/account/nick are meaningful; on a game server x/y/dir/chat/ani/level are live and writes to x/y/dir/chat apply there (batched, like game weapons').

player.id ​

ts
readonly id: number

player.name ​

ts
readonly name: string

Account name.

player.account ​

ts
readonly account: string

Account name (same as name).

player.nick ​

ts
readonly nick: string

Account name (same as name).

player.x ​

ts
x: number

Account name (same as name).

player.y ​

ts
y: number

Account name (same as name).

player.dir ​

ts
dir: "up" | "down" | "left" | "right"

Account name (same as name).

player.chat ​

ts
chat: string

Account name (same as name).

player.ani ​

ts
readonly ani: string

Account name (same as name).

player.level ​

ts
readonly level: string

Current level (or gmap) name; '' on the Login Server.

player.hasWeapon ​

ts
hasWeapon(name: string): boolean

Whether a SYSTEM weapon with this name is loaded.

ChatPlayer interface ​

ts
interface ChatPlayer

Frozen view of the local player handed to onPlayerChats.

ChatPlayer.id ​

ts
readonly id: number

ChatPlayer.name ​

ts
readonly name: string

ChatPlayer.account ​

ts
readonly account: string

ChatPlayer.nick ​

ts
readonly nick: string

ChatPlayer.x ​

ts
readonly x: number

ChatPlayer.y ​

ts
readonly y: number

ChatPlayer.dir ​

ts
readonly dir: "up" | "down" | "left" | "right"

ChatPlayer.chat ​

ts
readonly chat: string

ChatPlayer.level ​

ts
readonly level: string

Privileged: session & servers ​

ServerInfo interface ​

ts
interface ServerInfo

A server from the list (GLister), or where the player / a friend is.

ServerInfo.name ​

ts
readonly name: string

ServerInfo.host ​

ts
readonly host: string

ServerInfo.port ​

ts
readonly port: number

ServerInfo.players ​

ts
readonly players?: number

Players online (server list only).

session global ​

ts
declare const session: { … }

The signed-in session.

session.account ​

ts
readonly account: string

The signed-in account.

session.onLoginServer ​

ts
readonly onLoginServer: boolean

True while connected to the Login Server itself.

session.server ​

ts
readonly server: ServerInfo & { readonly login: boolean }

The server the player is on (or connecting from). login marks the Login Server.

servers global ​

ts
declare const servers: { … }

The game-server list and server switching (Login Server only).

servers.list ​

ts
list(): Promise<ServerInfo[]>

Fetches the public server list (sorted by players, then name). Rejects when the lister is unreachable.

servers.connect ​

ts
connect(server: { host: string, port: number, name?: string }): void

Sends the player to a game server: leaves the current server (Login Server weapons that aren't persistent unload), connects, and on success fires onServerChanged. On failure fires onServerSwitchFailed and the client returns to the Login Server. Batched; applies next frame.

servers.returnToLogin ​

ts
returnToLogin(): void

Leaves the current game server and returns to the Login Server.

logout function ​

ts
declare function logout(): void

Signs out: forgets the saved session and returns to the login form.

Privileged: friends & PMs ​

Friend interface ​

ts
interface Friend

A friends-list entry. Plain data: a fresh copy on every read.

Friend.account ​

ts
account: string

Friend.online ​

ts
online: boolean

Friend.server ​

ts
server: ServerInfo | null

Where they are while online (the Login Server counts); null while offline.

friends global ​

ts
declare const friends: { … }

Your cross-server friends list (GSocial). Changes are async: the result arrives as onFriendsChanged / onFriendRemoved / onFriendError.

friends.connected ​

ts
readonly connected: boolean

friends.account ​

ts
readonly account: string

friends.list ​

ts
list(): Friend[]

Sorted online-first, then by name.

friends.get ​

ts
get(account: string): Friend | null

Sorted online-first, then by name.

friends.has ​

ts
has(account: string): boolean

Sorted online-first, then by name.

friends.add ​

ts
add(account: string): void

Sorted online-first, then by name.

friends.remove ​

ts
remove(account: string): void

Sorted online-first, then by name.

PMSender interface ​

ts
interface PMSender

Who a PM came from.

PMSender.account ​

ts
readonly account: string

Sender's account, or the sending server's name for system PMs.

PMSender.server ​

ts
readonly server: string

Name of the server the sender is on ('' if unknown).

PMSender.system ​

ts
readonly system: boolean

True for PMs sent by a serverside script (sendPM on a GServer).

PMMessage interface ​

ts
interface PMMessage

One received message, from openPM.

PMMessage.text ​

ts
readonly text: string

PMMessage.at ​

ts
readonly at: number

Receive time, ms since the Unix epoch.

PMMessage.system ​

ts
readonly system: boolean

Receive time, ms since the Unix epoch.

PMPending interface ​

ts
interface PMPending extends PMSender

A sender with unread messages, from pendingPMs.

PMPending.count ​

ts
readonly count: number

sendPM function ​

ts
declare function sendPM(account: string, text: string): void

Sends a private message to a player on ANY server. Online-only: failures come back as onPMFailed(account, reason). Max 200 characters; 10 per 10s.

openPM function ​

ts
declare function openPM(sender: PMSender | string): PMMessage[]

Returns — and marks read — the messages received from sender since the last openPM for them, oldest first. The ONLY way to read PM text: game servers' weapons just get onPMReceived(sender). Held for this session only (up to 200 per sender). Direct call.

pendingPMs function ​

ts
declare function pendingPMs(): PMPending[]

Senders with unread messages, oldest first. Direct call.