0.1.1 • Published 6 months ago

@infernus/query v0.1.1

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

@infernus/query

npm npm npm bundle size

Getting started

pnpm add @infernus/query

Simple API for send SA-MP queries with TypeScript Language.

Special thanks to sampquery-c.

Example

import { RequestPacket, sendQuery } from "@infernus/query";

async function main() {
  try {
    const serverInfo = await sendQuery({
      address: "127.0.0.1",
      port: 7777,
      opcode: RequestPacket.INFORMATION,
    });

    if (!serverInfo) {
      console.error("No response received from the server.");
      return;
    }

    console.log(`Server ${serverInfo.hostname}`);
    console.log(`GameMode: ${serverInfo.gameMode}`);
    console.log(`Language: ${serverInfo.language}`);
    console.log(`Max players: ${serverInfo.maxPlayers}`);
    console.log(`Online players: ${serverInfo.playerCount}`);
  } catch (err) {
    if (err instanceof Error) {
      console.error(`Error: ${err.message}`);
    }
  }
}

main();
0.1.1

6 months ago

0.1.0

8 months ago

0.0.3

8 months ago

0.0.2

8 months ago

0.0.1

9 months ago