npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@arbytez/cod4-rcon-commands

v0.1.1

Published

A simple wrapper library to the rcon commands you can send to a cod4 server. Response data for commands '_status_', '_rconStatus_' and '_info_' is parsed into custom type object, so it is possible to easily manage the server status/info.

Downloads

12

Readme

Cod4 Rcon Commands

A simple wrapper library to the rcon commands you can send to a cod4 server. Response data for commands 'status', 'rconStatus' and 'info' is parsed into custom type object, so it is possible to easily manage the server status/info.

Installation

$ yarn add @arbytez/cod4-rcon-commands
# or
$ npm install --save @arbytez/cod4-rcon-commands

Usage

import { createRconCommands } from '@arbytez/cod4-rcon-commands';
// const { createRconCommands } = require('@arbytez/cod4-rcon-commands');

const cod4ServerIp = '127.0.0.1';
const cod4ServerPort = 28960;
const cod4ServerRcon = 'myrconpass';

const rconCmds = createRconCommands(
  cod4ServerIp,
  cod4ServerPort,
  // you can omit the rcon pass but you will be only be able
  // to execute the 'status' and 'info' commands
  cod4ServerRcon
);

const status = await rconCmds.status();

// commands are sent using the udp protocol so we can not track the connection state (start/end)
// each command has its predefined timeout (in ms) already set
// but you can specify a custom timeout for each of them
// useful if you get truncated results from the rcon requests
// timeout default values are different for each command.

// maxTimeOut of 1500ms instead of the default value (for rconStatus cmd is 500ms)
const rconStatus = await rconCmds.rconStatus(1500);

// if you need to send a custom command
const customCmd = await rconCmds.execRconCmd('custom command');

Examples

status

const status = await rconCmds.status();
console.log(status);
{
  online: true,
  ip: '127.0.0.1',
  port: '28960',
  sv_hostname: 'hostname',
  g_gametype: 'sd',
  sv_maxclients: '32',
  uptime: '42 hours',
  g_mapStartTime: date,
  sv_privateClients: '0',
  fs_game: '',
  version: '...',
  mapname: 'mp_crash',
  onlinePlayers: [
    { score: 68, ping: '51', name: 'player2' },
    { score: 33, ping: '42', name: 'player1' },
    { score: 13, ping: '135', name: 'player3' },
    { score: 5, ping: '28', name: 'player4' }
  ],
  branch: '',
  build: '...',
  g_compassShowEnemies: '0',
  gamename: 'Call of Duty 4',
  protocol: '17',
  revision: '',
  shortversion: '1.8',
  sv_disableClientConsole: '0',
  sv_floodprotect: '4',
  sv_maxPing: '0',
  sv_maxRate: '25000',
  sv_minPing: '0',
  sv_pure: '1',
  sv_voice: '0',
  type: '1'
}

rconStatus

const rconStatus = await rconCmds.rconStatus();
console.log(rconStatus);
{
  ... // same as the status cmd response
  onlinePlayers: [
    {
      num: 3,
      score: 15,
      ping: 135,
      id: '1234567890123456789',
      steamId: '12345678901234567',
      name: 'player1',
      lastmsg: 0,
      ip: 'xx.xxx.x.xxx',
      port: 28960,
      qport: 3717,
      rate: 25000
    },
    {
      num: 1,
      score: 10,
      ping: 25,
      id: '1234567890123456789',
      steamId: '12345678901234567',
      name: 'player2',
      lastmsg: 0,
      ip: 'xx.xxx.x.xxx',
      port: 36785,
      qport: 28790,
      rate: 25000
    },
    {
      num: 5,
      score: 5,
      ping: 26,
      id: '1234567890123456789',
      steamId: '0',
      name: 'player3',
      lastmsg: 0,
      ip: 'xx.xxx.x.xxx',
      port: 28960,
      qport: 12999,
      rate: 25000
    },
    ...
  ],
  ...
}

info

const info = await rconCmds.info();
console.log(info);
{
  build: '...',
  clients: '6',
  ff: '0',
  g_humanplayers: '6',
  game: '...',
  gametype: 'sd',
  hc: '1',
  hostname: 'hostname',
  hw: '1',
  ki: '1',
  mapname: 'mp_crossfire',
  mod: '1',
  od: '1',
  protocol: '6',
  pswrd: '0',
  pure: '1',
  shortversion: '1.8',
  sv_maxclients: '32',
  type: '1',
  voice: '0'
}

List of all wrapped commands

AdminAddAdmin
AdminChangeCommandPower
AdminChangePassword
AdminListAdmins
AdminListCommands
AdminRemoveAdmin
ChangePassword
XAssetUsage
addCommand
cmdlist
cvarlist
dumpbanlist
dumpuser
echo
exec
fast_restart
gametype
getmodules
getss
info
kick
killserver
loadPlugin
map
map_restart
map_rotate
meminfo
ministatus
net_restart
path
permban
pluginInfo
plugins
quit
rconStatus
record
reset
say
screensay
screentell
serverinfo
set
seta
setcvartotime
setfromcvar
sets
setu
status
stoprecord
systeminfo
tell
tempban
toggle
unban
undercover
unloadPlugin
vstr
which
writeconfig
writenvcfg
zonememinfo