Functions | Game Server

Here is a list of all the functions available in the GodotSteam module. The descriptions are pulled from the official Steamworks SDK documentation with modifications made to fit GodotSteam's implementation of the functions. Naturally, any GodotSteam-specific functions will be noted as such.


associateWithClan( int clan_id ) associateWithClan( uint64_t clan_id )

  • Associate this game server with this clan for the purposes of computing player compatibility.
  • Triggers a associate_clan callback.
  • Returns nothing; void.

beginServerAuthSession( int auth_ticket, int steam_id ) beginServerAuthSession( int auth_ticket, uint64_t steam_id )

  • Authenticate the ticket from the entity Steam ID to be sure it is valid and isn't reused. The ticket is created on the entity with getAuthSessionTicket or getServerAuthSessionTicket and then needs to be provided over the network for the other end to validate. This registers for validate_auth_ticket_response callbacks if the entity goes offline or cancels the ticket. See EAuthSessionResponse for more information. When the multiplayer session terminates you must call endAuthSession.
  • Returns an int.

serverLoggedOn()

  • Status functions.
  • Returns a bool.

secure()

  • Checks whether the game server is in "Secure" mode.
  • Returns a bool.

cancelServerAuthTicket( int auth_ticket ) cancelServerAuthTicket( uint32 auth_ticket )

  • Cancel auth ticket from getServerAuthSessionTicket; called when no longer playing game with the entity you gave the ticket to.
  • Returns nothing; void.

clearAllKeyValues()

  • Call this to clear the whole list of key/values that are sent in rule queries.
  • Returns nothing; void.

computeNewPlayerCompatibility( int steam_id ) computeNewPlayerCompatibility( uint64_t steam_id )

  • Ask if any of the current players dont want to play with this new player - or vice versa.
  • Triggers a player_compat callback.
  • Returns nothing; void.

setAdvertiseServerActive( bool active )

  • Tells the Steam master servers whether or not you want to be active. If this is enabled then the server will talk to the master servers, if it's not then incoming messages are ignored and heartbeats will not be sent.
  • Noted: This function is called EnableHeartbeats in the Steamworks documentation but is called setAdvertiseServerAction in the SDK header file.
  • Returns nothing; void.

endServerAuthSession( int steam_id ) endServerAuthSession( uint64_t steam_id )

  • Stop tracking started by beginServerAuthSession; called when no longer playing game with this entity.
  • Returns nothing; void.

getServerAuthSessionTicket()

  • Retrieve a authentication ticket to be sent to the entity who wishes to authenticate you. After calling this you can send the ticket to the entity where they can then call beginAuthSession to verify this entities integrity. When creating a ticket for use by the ISteamUserAuth/AuthenticateUserTicket Web API, the calling application should wait for the get_auth_session_ticket_response callback generated by the API call before attempting to use the ticket to ensure that the ticket has been communicated to the server. If this callback does not come in a timely fashion (10 - 20 seconds), then your client is not connected to Steam, and the authenticateUserTicket call will fail because it can not authenticate the user.
  • Triggers a get_auth_session_ticket_response callback.
  • Returns a dictionary:
    • id (int)
    • buffer (PoolByteArray)
    • ticket_size (int)
    • id (uint32_t)
    • buffer (PoolByteArray)
    • ticket_size (uint32_t)

getNextOutgoingPacket()

  • Gets a packet that the master server updater needs to send out on UDP when in GameSocketShare mode. GameSocketShare mode can be enabled when calling serverInit.
  • Note: This should only ever be called after calling handleIncomingPacket for any packets that came in that frame.
  • Note: This must be called repeatedly each frame until it returns 0 when in GameSocketShare mode.
  • Returns a dictionary:
    • length (int)
    • out (PoolByteArray)
    • address (int)
    • port (int)
    • length (int)
    • out (PoolByteArray)
    • address (uint32)
    • port (uint16)

getPublicIP()

  • Gets the public IP of the server according to Steam. This is useful when the server is behind NAT and you want to advertise its IP in a lobby for other clients to directly connect to.
  • Returns a dictionary:
    • ipv4 (int)
    • ipv6 (int)
    • type (int)

getServerSteamID()

  • Gets the Steam ID of the game server.
  • Returns an int. Returns an uint64_t.

handleIncomingPacket( int packet, string ip, int port )

  • Handles a Steam master server packet when in GameSocketShare mode. When in GameSocketShare mode, instead of ISteamGameServer creating its own socket to talk to the master server on, it lets the game use its socket to forward messages back and forth. This prevents us from requiring server ops to open up yet another port in their firewalls. This should be called whenever a packet that starts with 0xFFFFFFFF comes in. That means it's for us. The IP and port parameters are used when you've elected to multiplex the game server's UDP socket rather than having the master server updater use its own sockets. Source engine games use this to simplify the job of the server admins, so they don't have to open up more ports on their firewalls. Only after calling this, you should call getNextOutgoingPacket. GameSocketShare mode can be enabled when calling initGameServer.
  • Returns a dictionary:
    • data (PoolByteArray)

initGameServer( dictionary connect_data, int app_id, string version_string ) initGameServer( dictionary connect_data, uint32_t app_id, string version_string )

  • This is called by serverInit and will usually not need to be called directly.
  • Note: The following, if set, must be set before calling logOn; they may not be changed after.
  • The connect_data dictionary should contain the following keys:
    • ip (string)
    • game_port (int)
    • query_port (int)
    • ip (string)
    • game_port (uint16)
    • query_port (uint16)
  • Returns a bool.

logOff()

  • Begin process of logging game server out of Steam.
  • Triggers a server_connect_failure, server_connected, or server_disconnected callbacks.
  • Returns nothing; void.

logOn( string token )

  • Begin process to login to a persistent game server account.
  • Triggers a server_connect_failure, server_connected, or server_disconnected callbacks.
  • Returns nothing; void.

logOnAnonymous()

  • Login to a generic, anonymous account.
  • Triggers a server_connect_failure, server_connected, or server_disconnected callbacks.
  • Returns nothing; void.

requestUserGroupStatus( int steam_id, int group_id ) requestUserGroupStatus( uint64_t steam_id, int group_id )

  • Ask if user is in specified group; results returned by client_group_status.
  • Triggers a client_group_status callback.
  • Returns a bool.

setBotPlayerCount( int bots )

  • Sets the number of bot/AI players on the game server. The default value is 0.
  • Returns nothing; void.

setDedicatedServer( bool dedicated )

  • Sets the whether this is a dedicated server or a listen server. The default is listen server.
  • Note: This only be set before calling logOn or logOnAnonymous.
  • Returns nothing; void.

setGameData( string data )

  • Sets a string defining the "gamedata" for this server, this is optional, but if set it allows users to filter in the matchmaking/server-browser interfaces based on the value. This is usually formatted as a comma or semicolon separated list. Don't set this unless it actually changes, its only uploaded to the master once; when acknowledged.
  • Returns nothing; void.

setGameDescription( string description )

  • Sets the game description. Setting this to the full name of your game is recommended.
  • Note: This is required for all game servers and can only be set before calling logOn or logOnAnonymous.
  • Returns nothing; void.

setGameTags( string tags )

  • Sets a string defining the "gametags" for this server, this is optional, but if set it allows users to filter in the matchmaking/server-browser interfaces based on the value. This is usually formatted as a comma or semicolon separated list. Don't set this unless it actually changes, its only uploaded to the master once; when acknowledged.
  • Returns nothing; void.

setHeartbeatInterval( int interval )

  • YChanges how often heartbeats are sent to the Steam master servers. You usually don't need to use this.
  • Returns nothing; void.

setKeyValue( string key, string value )

  • Add/update a rules key/value pair.
  • Returns nothing; void.

setMapName( string map )

  • Sets the name of map to report in the server browser.
  • Returns nothing; void.

setMaxPlayerCount( int players_max )

  • Max player count that will be reported to server browser and client queries.
  • Returns nothing; void.

setModDir( string modDir )

  • Sets the game directory. This should be the same directory game where gets installed into. Just the folder name, not the whole path. e.g. "Spacewar".
  • Note: This is required for all game servers and can only be set before calling logOn or logOnAnonymous.
  • Returns nothing; void.

setPasswordProtected( bool password_protected )

  • Set whether the game server will require a password once when the user tries to join.
  • Returns nothing; void.

setProduct( string product )

  • Sets the game product identifier. This is currently used by the master server for version checking purposes. Converting the game's app ID to a string for this is recommended.
  • Notes: This is required for all game servers and can only be set before calling logOn or logOnAnonymous.
  • Returns nothing; void.

setRegion( string region )

  • Region identifier. This is an optional field, the default value is an empty string, meaning the "world" region.
  • Returns nothing; void.

setServerName( string name )

  • Sets the name of server as it will appear in the server browser.
  • Returns nothing; void.

setSpectatorPort( int port )

  • Spectator server. Default is zero, meaning it is now used.
  • Returns nothing; void.

setSpectatorServerName( string name )

  • Sets the name of the spectator server. This is only used if spectator port is non-zero.
  • Returns nothing; void.

userHasLicenceForApp( int steam_id, int app_id ) userHasLicenceForApp( uint64_t steam_id, uint32 app_id )

  • Checks if the user owns a specific piece of Downloadable Content (DLC). This can only be called after sending the users auth ticket to beginServerAuthSession.
  • Returns an int.

wasRestartRequested()

  • Checks if the master server has alerted us that we are out of date. This reverts back to false after calling this function.
  • Returns a bool.