Crysis Server Toolkit API

From CryWiki

Jump to: navigation, search


About
Author Not specified.
Skill Level Intermediate
Compatibility All
Requirements Not specified.
Date Added Not specified.
Last Modified Not specified.

This is a reference document the Crysis Server Toolkit API. For an introductory tutorial, please read Controlling the Crysis Dedicated Server

Contents

CrysisServerSession Class

This is the main class of the toolkit.

Constructor

public CrysisServerSession(string ip, int port, string password, bool cacheConnection)
ip
The IP of the game server
port
The port of the http server
password
The password for the http server
cacheConnection
If this is turned on, all subsequent requests following an initial request will use the initial requests' connection. This can be much faster, as there is no re-connect or re-authentication for each command. If the ip, port, password, or cacheConnection property is changed, the connection is reestablished.

Properties

public string IP

The IP of the game server

public int Port

The port of the http server

public string Password

The password for the http server

public bool CacheConnection

If this is turned on, all subsequent requests following an initial request will use the initial requests' connection. This can be much faster, as there is no re-connect or re-authentication for each command. If the ip, port, password, or cacheConnection property is changed, the connection is reestablished.

Connection Methods

public void Reset()

This forces a reconnect if CacheConnection is turned on.

public void Close()

This closes the connection.

public bool TestConnection()

This method will see if the connection can be established by sending a test status command.

General Server Methods

public string ExecuteCommand(string command)
public Result ExecuteCommandAsync(string command)

Execute a command denoted by the command parameter.

public string GetCurrentMap()
public void SetCurrentMap(string value)
public Result GetCurrentMapAsync()
public Result SetCurrentMapAsync(string value)

Gets and sets the current map.

public double GetFriendlyFireRatio()
public void SetFriendlyFireRatio(double value)
public Result GetFriendlyFireRatioAsync()
public Result SetFriendlyFireRatioAsync(double value)

Sets / Gets friendly damage ratio [0-1]. 0 will disable friendly fire.

public string GetServerName()
public void SetServerName(string value)
public Result GetServerNameAsync()
public Result SetServerNameAsync(string value)

Sets / Gets the name of the server.

public int GetTeamBalanceValue()
public void SetTeamBalanceValue(int value)
public Result GetTeamBalanceValueAsync()
public Result SetTeamBalanceValueAsync(int value)

Number of players one team needs to have over the other to not allow joining this team anymore. Modifies / gets g_teamlock

public bool GetTKPunish()
public void SetTKPunish(bool value)
public Result GetTKPunishAsync()
public Result SetTKPunishAsync(bool value)

Allows team kill punishment.

public int GetTKPunishLimit()
public void SetTKPunishLimit(int value)
public Result SetTKPunishLimitAsync(int value)
public Result GetTKPunishLimitAsync()

Number of team kills a user will be banned for.

Get Players Method

public List<Player> GetPlayers()
public Result GetPlayersAsync()

This gets a list of players current in the server using status. This will return a list of players.

Example

The following code gets all the players and prints each player's name.

List<Player> players = css.GetPlayers(); //css is a crysis server session
foreach(Player p in players)
{
     Console.WriteLine("Player name:" + p.Name);
}

See Crysis_Server_Toolkit_API#Player Class for more details.

Kick

public void Kick(Player p)
public Result KickAsync(Player p)

This will kick the player using their player id.

Example

The following will kick anyone with a ping greater than 200.

List<Player> players = css.GetPlayers(); //css is a configured CrysisServerSession
foreach(Player p in players)
{
     if(p.Ping > 200)
     {
           css.Ban(p);
     }
}

Ban

public void Ban (Player player)
public Result Ban (Player player)

This will ban the player using their profile.

Example

The following will ban anyone with "banme" in their name.

List<Player> players = css.GetPlayers(); //css is a configured CrysisServerSession
foreach(Player p in players)
{
     if(p.Name.Contains("banme"))
     {
           css.Ban(p);
     }
}
Personal tools