Skip to content

Instantly share code, notes, and snippets.

@ultraviolet-jordan
Created February 4, 2024 03:59
Show Gist options
  • Save ultraviolet-jordan/e493189bab84218dff89aa3521c8006e to your computer and use it in GitHub Desktop.
Save ultraviolet-jordan/e493189bab84218dff89aa3521c8006e to your computer and use it in GitHub Desktop.
// // main
if (GameShell.getParameter('world').length === 0) {
GameShell.setParameter('world', '1');
}
if (GameShell.getParameter('detail').length === 0) {
GameShell.setParameter('detail', 'high');
}
if (GameShell.getParameter('method').length === 0) {
GameShell.setParameter('method', '0');
}
type WorldList = {
id: number;
region: string;
address: string;
portOffset: number;
players: number;
members?: boolean;
}
const worldlist: WorldList[] = JSON.parse(await downloadText('http://2004scape.org/api/v1/worldlist'));
const id: number = parseInt(GameShell.getParameter('world'), 10);
const lowmem: boolean = GameShell.getParameter('detail') === 'low';
const world: WorldList | undefined = worldlist.find((x): boolean => x.id === id);
const protocol: string = window.location.protocol;
const hostname: string = window.location.hostname;
const secured: boolean = hostname.startsWith('https');
Client.nodeId = 10 + (world?.id ?? 1) - 1;
if (hostname === 'localhost') {
Client.serverAddress = protocol + '//' + hostname;
Client.portOffset = 0;
} else {
Client.serverAddress = world?.address ?? 'https://w1.225.2004scape.org';
if (!secured) {
Client.serverAddress = Client.serverAddress.replace('https', 'http');
}
Client.portOffset = world?.portOffset ?? 0;
}
if (lowmem) {
Client.setLowMemory();
} else {
Client.setHighMemory();
}
console.log('RS2 user client - release #225');
new Client().run().then((): void => {});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment