TorqueScript Reference

- Main Page
- Related Pages
- Modules
- Classes

Functions
Server Query
Function Categories

## Functions
void | cancelServerQuery ()
int | getServerCount ()
void | queryLanServers (port, flags, gametype, missiontype, minplayers, maxplayers, maxbots, regionmask, maxping, mincpu, filterflags)
void | queryMasterServer (flags, gametype, missiontype, minplayers, maxplayers, maxbots, regionmask, maxping, mincpu, filterflags)
void | querySingleServer (address[, flags])
Boolean | setServerInfo (index)
void | startHeartbeat ()
void | stopHeartbeat ()
void | stopServerQuery ()

## Detailed Description

## Function Documentation

void cancelServerQuery | ( |  | ) |

Use the cancelServerQuery function to cancel a previous query*() call.

Returns
  No return value.

See also
  queryLANServers, queryMasterServer, querySingleServer

int getServerCount | ( |  | ) |

Use the getServerCount function to determine the number of game servers found on the last queryLANServers() or queryMasterServer() call. This value is important because it allows us to properly index when calling setServerInfo().

Returns
  Returns a numeric value equal to the number of game servers found on the last queryLANServers() or queryMasterServer() call. Returns 0 if the function was not called, or none were found.

See also
  queryLANServers, queryMasterServer, setServerInfo

void queryLanServers | ( | port | ,
|  | flags | ,
|  | gametype | ,
|  | missiontype | ,
|  | minplayers | ,
|  | maxplayers | ,
|  | maxbots | ,
|  | regionmask | ,
|  | maxping | ,
|  | mincpu | ,
|  | filterflags |
| ) |  |

Use the queryLANServers function to establish whether any game servers of the required specification(s) are available on the local area network (LAN).

Parameters

  port | Look for any game servers advertising at this port. Set to 0 if you don't care what port the game server is using.
  flags | Look for any game servers with these special flags set. Set to 0 for no flags.
  gametype | Look for any game servers playing a game type that matches this string. Set to the NULL string to look for any game type.
  missiontype | Look for any game servers playing a mission type that matches this string. Set to the NULL string to look for any mission type.
  minplayers | Look for any game servers with this number of players or more. Set to 0 for no lower limit.
  maxplayers | Look for any game servers with this number of players or fewer. Set to 0 for no upper limit.
  maxbots | Look for any game servers with this number of AI controlled players or fewer. Set to 0 for no limit.
  regionmask | Look for any master servers, on our master server list, in this region. Set to 0 to examine all regions.
  maxping | Look for any game servers with a PING rate equal to or lower than this. Set to 0 for no upper PING limit.
  mincpu | Look for any game servers with a CPU (clock speed) equal or greater than this. Set to 0 for no CPU (clock speed) limit.
  filterflags | Look for any game servers with this game version number or higher. Set to 0 to find all versions.

Returns
  No return value.

See also
  getServerCount, queryMasterServer, setServerInfo, stopServerQuery

void queryMasterServer | ( | flags | ,
|  | gametype | ,
|  | missiontype | ,
|  | minplayers | ,
|  | maxplayers | ,
|  | maxbots | ,
|  | regionmask | ,
|  | maxping | ,
|  | mincpu | ,
|  | filterflags |
| ) |  |

Use the queryMasterServer function to query all master servers in the master server list and to establish if they are aware of any game servers that meet the specified requirements, as established by the arguments passed to this function. In order for this function to do anything, a list of master servers must have been previously specified. This list may contain one or more server addresses. A call to this function will search all servers in the list. To specify a list, simply create a set of array entries like this:$pref::Master[0] = \2:192.168.123.15:28002\;$pref::Master[1] = \2:192.168.123.2:28002\;The format of these values is ==> Region Number : IP Address : Port NumberThese values should be specified in either the client's or the server's preferences file (prefs.cs). You may specifiy it elsewhere, however be sure that it is specified prior to this function being called and before any other functions that rely on it.

Parameters

  flags | Look for any game servers with these special flags set. Set to 0 for no flags.
  gametype | Look for any game servers playing a game type that matches this string. Set to the NULL string to look for any game type.
  missiontype | Look for any game servers playing a mission type that matches this string. Set to the NULL string to look for any mission type.
  minplayers | Look for any game servers with this number of players or more. Set to 0 for no lower limit.
  maxplayers | Look for any game servers with this number of players or fewer. Set to 0 for no upper limit.
  maxbots | Look for any game servers with this number of AI controlled players or fewer. Set to 0 for no limit.
  regionmask | Look for any master servers, on our master server list, in this region. Set to 0 to examine all regions.
  maxping | Look for any game servers with a PING rate equal to or lower than this. Set to 0 for no upper PING limit.
  mincpu | Look for any game servers with a CPU (clock speed) equal or greater than this. Set to 0 for no CPU (clock speed) limit.
  filterflags | Look for any game servers with this game version number or higher. Set to 0 to find all versions.

Returns
  No return value.

See also
  getServerCount, queryLANServers, setServerInfo, startHeartbeat, stopServerQuery

void querySingleServer | ( | address | [, flags] | ) |

Use the querySingleServer function to re-query a previously queried lan server, OR a game server found with queryLANServers or with queryMasterServer and selected with setServerInfo. This will refresh the information stored by TGE about this server. It will not however modify the values of the $ServerInfo::* global variables.

Parameters

  address | The IP address and Port to re-query, i.e. \192.168.123.2:28000.
  flags | No longer used.

Returns
  No return value.

See also
  getServerCount, queryLANServers, queryMasterServer, setServerInfo, stopServerQuery

Boolean setServerInfo | ( | index |  | ) |

Use the setServerInfo function to set the values of the $ServerInfo::* global variables with information for a server found with queryLANServers or with queryMasterServer.

Parameters

  index | The index of the server to get information about.

Returns
  Will return true if the information was successfully set, false otherwise.

See also
  getServerCount, queryLANServers, queryMasterServer, querySingleServer

void startHeartbeat | ( |  | ) |

Use the startHeartbeat function to start advertising this game serer to any master servers on the master server list. In order for this function to do anything, a list of master servers must have been previously specified. This list may contain one or more server addresses. Once this function is called, the game server will re-advertise itself to all the master servers on its master server lits every two minutes. To specify a list, simply create a set of array entries like this:$pref::Master[0] = \2:192.168.123.15:28002\;$pref::Master[1] = \2:192.168.123.2:28002\;The format of these values is ==> Region Number : IP Address : Port NumberThese values should be specified in either the client's or the server's preferences file (prefs.cs). You may specifiy it elsewhere, however be sure that it is specified prior to this function being called and before any other functions that rely on it.

Returns
  No return value.

See also
  queryMasterServer, stopHeartbeat

void stopHeartbeat | ( |  | ) |

Use the startHeartbeat function to stop advertising this game serer to any master servers on the master server list.

Returns
  No return value.

See also
  queryMasterServer, startHeartbeat

void stopServerQuery | ( |  | ) |

Use the stopServerQuery function to cancel any outstanding server queries.

Returns
  No return value.

See also
  queryLANServers, queryMasterServer, querySingleServer