Skip to content
This repository has been archived by the owner on Jan 29, 2020. It is now read-only.

Functions

Tom Grobbe edited this page Sep 13, 2017 · 2 revisions

Functions

Here you can find a list of functions that you can use, note that if an error occurs each function will return a fitting error message describing the problem.


void LoadServerData(String serverAddress)

This function is used to load the server data for the specified serverAddress.

ServerAddress syntax is: "ip:port", example:

LoadServerData("149.210.238.117:30120")

String GetServerIcon()

Returns a String containing a full html tag including the server-icon img src data.

Example: <img src='data:image/png;base64,(base64-encoded-image-string)' id='server-icon'>


String GetServerHostname()

Returns a String containing the raw server hostname.


String GetServerAddress()

Returns a String containing the serverAddress.

Example: "149.210.238.117:30120"


Array(String) GetResources()

Returns an Array of type String containing all loaded server resources.


String GetResource(resourceId)

Returns a String containing the name of the specified resourceId. ResourceId should be an Int between 1 and the total amount of loaded resources (which can be acquired using: GetResourceCount()).


int GetResourceCount()

Returns an int representing the amount of resources, currently loaded on the server.


Array(Player) GetPlayers()

Returns an Array of type Player (object) containing all players currently online.


Player GetPlayer(playerId)

Returns the Player object for the specified PlayerId. PlayerId is a number between 0 - 31 (IT'S NOT THE SAME AS THE FIVEM SERVER PLAYER ID!) If you want to GET the ServerID of a player, use GetPlayerServerId(PlayerId). If you want to GET the PlayerID using a ServerID use GetPlayerIdFromServerId(PlayerServerID).


int GetPlayerIdFromServerId(playerServerId)

Returns an int representing the PlayerID (0-31) for the specified PlayerServerId.

Example: (PlayerId = 10, ServerId = 69)

GetPlayerIdFromServerId(69)
// Returns: 10

int GetPlayerServerId(PlayerId)

Returns an int representing the PlayerServerId for the specified PlayerId (0-31).

Example: (PlayerId = 10, ServerId = 69):

GetPlayerServerId(10)
// Returns: 69

String GetPlayerIp(PlayerID)

Returns a string containing one of the following things:

  • "<External IPv6>:<port>"
  • "<External IPv4>:<port>"
  • "private"

"private" is shown when the server owner used the sv_endpointprivacy true setting in their server.cfg file, or if the player is using localhost/127.0.0.1 to connect to their server.


int GetPlayerPing(PlayerID)

Returns an int representing the ping in ms between the player's client and the server.


String GetPlayerName(PlayerID)

Returns a String containing the player's username.


Array(String) GetPlayerIdentifiers(PlayerID)

Returns an Array of type String containing the playerIdentifiers for the specified PlayerID.


String GetPlayerIdentifierFromIndex(PlayerID, IdentifierIndex)

Returns a String containing the player identifier specified by the IdentifierIndex (0-something) for the specified PlayerID (0-31).


int GetPlayerCount()

Returns an int representing the amount of players currently online.


int GetMaxPlayerCount()

Returns an int representing the max amount of players allowed online. (Set by the sv_maxclients setting in the server.cfg file)


String GetGameType()

Returns a String containing the current GameType.


String GetMapName()

Returns a String containing the currrent MapName.


Boolean IsScriptHookEnabled()

Returns a Boolean; true means ScriptHook is enabled, false means ScriptHook is disabled.


String GetServerVersion()

Returns a String containing the server version. Looks something like this:

"FXServer-master SERVER v1.0.0.346 win32"