Custom Query Protocol

Revision as of 13:47, 16 May 2017 by TCAWiki (talk | contribs) (Created page with "You can set a custom script that queries the game server. This is useful if you want to add query support for games that don't have a supported query protocol. * Create a cust...")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

You can set a custom script that queries the game server. This is useful if you want to add query support for games that don't have a supported query protocol.

  • Create a custom script. Set the script's event to "Custom query". You can have more than one custom query script with different operating systems.
  • Set the game's query protocol to custom script.


Examples

Iron Python Script

import clr
import System
from System import String

XmlFormat="<?xml version=\"1.0\" encoding=\"UTF-8\"?><qstat><server type=\"CUSTOM\" address=\"{0}:{1}\" status=\"{2}\"><hostname>{0}:{1}</hostname><name>{3}</name><gametype>{4}</gametype><map>{5}</map><numplayers>{6}</numplayers><maxplayers>{7}</maxplayers><numspectators>0</numspectators><maxspectators>0</maxspectators><ping>0</ping><retries>0</retries><rules>{8}</rules><players>{9}</players></server></qstat>"
Status="UP"
Name="Cool Game Server"
GameType="game mode"
Map="map name"
NumPlayers=2
MaxPlayers=8
Rules="<rule name=\"Rule 1\">rule value</rule><rule name=\"Rule 2\">rule value</rule>"
Players="<player><name>Player 1</name><ping>0</ping><score>100</score></player><player><name>Player 2</name><ping>0</ping><score>200</score></player>"
 
ReturnValue=String.Format(XmlFormat, ThisService.IpAddress, ThisService.QueryPort, Status, Name, GameType, Map, NumPlayers, MaxPlayers, Rules, Players)

Batch Script (Windows)

@echo off
set Status=UP
set Name=Cool Game Server
set GameType=game mode
set Map=map name
set NumPlayers=2
set MaxPlayers=8
set Rules=^^^<rule name="Rule 1"^^^>rule value^^^</rule^^^>^^^<rule name="Rule 2"^^^>rule value^^^</rule^^^>
set Players=^^^<player^^^>^^^<name^^^>Player 1^^^</name^^^>^^^<ping^^^>0^^^</ping^^^>^^^<score^^^>100^^^</score^^^>^^^</player^^^>^^^<player^^^>^^^<name^^^>Player 2^^^</name^^^>^^^<ping^^^>0^^^</ping^^^>^^^<score^^^>200^^^</score^^^>^^^</player^^^>

echo ^<?xml version="1.0" encoding="UTF-8"?^>^<qstat^>^<server type="CUSTOM" address="%ThisService_IpAddress%:%ThisService_QueryPort%" status="%Status%"^>^<hostname^>%ThisService_IpAddress%:%ThisService_QueryPort%^</hostname^>^<name^>%Name%^</name^>^<gametype^>%GameType%^</gametype^>^<map^>%Map%^</map^>^<numplayers^>%NumPlayers%^</numplayers^>^<maxplayers^>%MaxPlayers%^</maxplayers^>^<numspectators^>0^</numspectators^>^<maxspectators^>0^</maxspectators^>^<ping^>0^</ping^>^<retries^>0^</retries^>^<rules^>%Rules%^</rules^>^<players^>%Players%^</players^>^</server^>^</qstat^>

Shell Script (Linux)

Status="UP"
Name="Cool Game Server"
GameType="game mode"
Map="map name"
NumPlayers=2
MaxPlayers=8
Rules='<rule name="Rule 1">rule value</rule><rule name="Rule 2">rule value</rule>'
Players='<player><name>Player 1</name><ping>0</ping><score>100</score></player><player><name>Player 2</name><ping>0</ping><score>200</score></player>'

echo \<?xml version=\"1.0\" encoding=\"UTF-8\"?\>\<qstat\>\<server type=\"CUSTOM\" address=\"${ThisService_IpAddress}:${ThisService_QueryPort}\" status=\"${Status}\"\>\<hostname\>${ThisService_IpAddress}:${ThisService_QueryPort}\</hostname\>\<name\>${Name}\</name\>\<gametype\>${GameType}\</gametype\>\<map\>${Map}\</map\>\<numplayers\>${NumPlayers}\</numplayers\>\<maxplayers\>${MaxPlayers}\</maxplayers\>\<numspectators\>0\</numspectators\>\<maxspectators\>0\</maxspectators\>\<ping\>0\</ping\>\<retries\>0\</retries\>\<rules\>${Rules}\</rules\>\<players\>${Players}\</players\>\</server\>\</qstat\>
Retrieved from "https://help.tcadmin.com/index.php?title=Custom_Query_Protocol&oldid=1395"