Steamworks документация
ISteamGameServer интерфейс
Provides the core of the Steam Game Servers API.

Member Functions

Member functions for ISteamGameServer are called through the global accessor function SteamGameServer().

AssociateWithClan

SteamAPICall_t AssociateWithClan( CSteamID steamIDClan );
ИмеТипОписание
steamIDClanCSteamIDThe Steam ID of the group you want to be associated with.

associate this game server with this clan for the purposes of computing player compatibility.

Връща: SteamAPICall_t to be used with a AssociateWithClanResult_t call result.

BeginAuthSession

EBeginAuthSessionResult BeginAuthSession( const void *pAuthTicket, int cbAuthTicket, CSteamID steamID );
ИмеТипОписание
pAuthTicketconst void *The auth ticket to validate.
cbAuthTicketintThe size in bytes of the auth ticket. This must be the pcbTicket size provided by the call that created this ticket.
steamIDCSteamIDThe entity's Steam ID that sent this ticket.

Удостоверете билета от Steam № на лицето, за да се уверите, че е валиден и не се употребява повторно. Обърнете внимание, че самоличността не се потвърждава, докато не бъде получено обратното повикване ValidateAuthTicketResponse_t и върнатата му стойност не е проверена.

The ticket is created on the entity with ISteamUser::GetAuthSessionTicket or GetAuthSessionTicket and then needs to be provided over the network for the other end to validate.

This registers for ValidateAuthTicketResponse_t callbacks if the entity goes offline or cancels the ticket. See EAuthSessionResponse for more information.

When the multiplayer session terminates you must call EndAuthSession.

Връща: EBeginAuthSessionResult


See Also: User Authentication and Ownership

BLoggedOn

bool BLoggedOn();
Checks if the game server is logged on.

Връща: bool
true if the game server is logged on; otherwise, false.

BSecure

bool BSecure();
Checks whether the game server is in "Secure" mode.

Връща: bool
true if the game server secure; otherwise, false.

See Also: EServerMode, GSPolicyResponse_t

BUpdateUserData

bool BUpdateUserData( CSteamID steamIDUser, const char *pchPlayerName, uint32 uScore );
ИмеТипОписание
steamIDUserCSteamIDThe Steam ID of the user.
pchPlayerNameconst char *The name of the user.
uScoreuint32Текущият резултат на потребителя.

Update the data to be displayed in the server browser and matchmaking interfaces for a user currently connected to the server.

ЗАБЕЛЕЖКА: This is part of the old user authentication API and should not be mixed with the new API.

Връща: bool
true if the call was successful; otherwise false if there was a failure (ie, steamIDUser is not a player on the current server.)

See Also: User Authentication and Ownership

CancelAuthTicket

void CancelAuthTicket( HAuthTicket hAuthTicket );
ИмеТипОписание
hAuthTicketHAuthTicketThe active auth ticket to cancel.

Cancels an auth ticket received from ISteamUser::GetAuthSessionTicket. This should be called when no longer playing with the specified entity.

See Also: User Authentication and Ownership

ClearAllKeyValues

void ClearAllKeyValues();
Clears the whole list of key/values that are sent in rules queries.

See Also: SetKeyValue, ISteamMatchmakingServers::ServerRules

ComputeNewPlayerCompatibility

SteamAPICall_t ComputeNewPlayerCompatibility( CSteamID steamIDNewPlayer );
ИмеТипОписание
steamIDNewPlayerCSteamIDThe Steam ID of the player that is attempting to join.

Checks if any of the current players don't want to play with this new player that is attempting to join - or vice versa; based on the frenemy system.

Връща: SteamAPICall_t to be used with a ComputeNewPlayerCompatibilityResult_t call result.

CreateUnauthenticatedUserConnection

CSteamID CreateUnauthenticatedUserConnection();
Creates a fake user (ie, a bot) which will be listed as playing on the server, but skips validation.

ЗАБЕЛЕЖКА: This is part of the old user authentication API and should not be mixed with the new API.

Връща: CSteamID
Returns the Steam ID for the bot to be tracked with.

You should call SendUserDisconnect when this user leaves the server just like you would for a real user.

EnableHeartbeats

void EnableHeartbeats( bool bActive );
ИмеТипОписание
bActiveboolEnable (true) or disable (false) the master server updater.

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.

See Also: SetHeartbeatInterval, ForceHeartbeat

EndAuthSession

void EndAuthSession( CSteamID steamID );
ИмеТипОписание
steamIDCSteamIDThe entity to end the active auth session with.

Ends an auth session that was started with BeginAuthSession. This should be called when no longer playing with the specified entity.

See Also: User Authentication and Ownership

ForceHeartbeat

void ForceHeartbeat();
Force a heartbeat to the Steam master servers at the next opportunity.

You usually don't need to use this.

See Also: EnableHeartbeats, SetHeartbeatInterval

GetAuthSessionTicket

HAuthTicket GetAuthSessionTicket( void *pTicket, int cbMaxTicket, uint32 *pcbTicket );
ИмеТипОписание
pTicketvoid *The buffer where the new auth ticket will be copied into if the call was successful.
cbMaxTicketintThe size of the buffer allocated for pTicket. This should be 1024.
pcbTicketuint32 *Returns the length of the actual ticket.

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 ISteamUser::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 GetAuthSessionTicketResponse_t 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.

Връща: HAuthTicket
Triggers a GetAuthSessionTicketResponse_t callback.
A handle to the auth ticket. When you're done interacting with the entity you must call CancelAuthTicket on the handle.

Returns k_HAuthTicketInvalid if the call fails.

See Also: User Authentication and Ownership

GetGameplayStats

void GetGameplayStats();
Deprecated - Will be removed in a future release of the SDK.

Връща: void
Triggers a GSGameplayStats_t callback.

GetNextOutgoingPacket

int GetNextOutgoingPacket( void *pOut, int cbMaxOut, uint32 *pNetAdr, uint16 *pPort );
ИмеТипОписание
pOutvoid *Returns the packet that needs to be sent by copying it into this buffer. The packet may be up to 16KiB so allocate accordingly.
cbMaxOutintThe size of the buffer provided to pOut, should be 16 * 1024.
pNetAdruint32 *Returns the The IP address that this packet needs to be sent to in host order, i.e 127.0.0.1 == 0x7f000001.
pPortuint16 *Returns the port that this packet needs to be sent through, in host order.

Gets a packet that the master server updater needs to send out on UDP when in GameSocketShare mode.

ЗАБЕЛЕЖКА: This should only ever be called AFTER calling HandleIncomingPacket for any packets that came in that frame!

ЗАБЕЛЕЖКА: This MUST be called repeatedly each frame until it returns 0 when in GameSocketShare mode.

GameSocketShare mode can be enabled when calling SteamGameServer_Init.

Връща: int
The length of the packet that needs to be to sent, or 0 if there are no more packets to send this frame.

GetPublicIP

uint32 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.

Връща: uint32
The public IP in host order, i.e 127.0.0.1 == 0x7f000001.

Returns 0 if the IP could not be determined.

GetServerReputation

SteamAPICall_t GetServerReputation();
Deprecated - Will be removed in a future release of the SDK.

Връща: SteamAPICall_t to be used with a GSReputation_t call result.

GetSteamID

CSteamID GetSteamID();
Gets the Steam ID of the game server.

Връща: CSteamID

HandleIncomingPacket

bool HandleIncomingPacket( const void *pData, int cbData, uint32 srcIP, uint16 srcPort );
ИмеТипОписание
pDataconst void *The data from the incoming packet.
cbDataintThe size of pData in bytes.
srcIPuint32The IP address that this packet was sent to in host order, i.e 127.0.0.1 == 0x7f000001.
srcPortuint16The port that this packet was sent through, in host order.

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 SteamGameServer_Init.

Връща: bool

InitGameServer

bool InitGameServer( uint32 unIP, uint16 usGamePort, uint16 usQueryPort, uint32 unFlags, AppId_t nGameAppId, const char *pchVersionString );
ИмеТипОписание
unIPuint32The IP address you are going to bind to. (This should be in host order, i.e 127.0.0.1 == 0x7f000001). You can use INADDR_ANY to bind to all local IPv4 addresses.
usGamePortuint16The port that clients will connect to for gameplay.
usQueryPortuint16The port that will manage server browser related duties and info pings from clients.
unFlagsuint32A union of one or more ServerFlags.
nGameAppIdAppId_tThe app id of the game this server is for.
pchVersionStringconst char *The version string is usually in the form x.x.x.x, and is used by the master server to detect when the server is out of date. (Only servers with the latest version will be listed.)

Initializes the instance of ISteamGameServer. This is called by SteamGameServer_Init, and you will usually not need to call it directly.

If you pass MASTERSERVERUPDATERPORT_USEGAMESOCKETSHARE into usQueryPort, then it causes the game server API to use "GameSocketShare" mode, which means that the game is responsible for sending and receiving UDP packets for the master server updater.

If GameSocketShare mode is used then you must use HandleIncomingPacket and GetNextOutgoingPacket to interact with the Steam Master Server.

Връща: bool
true if the game server was successfully able to bind to the provided IP/Port; otherwise, false indicating failure.

LogOff

void LogOff();
Begin process of logging the game server out of steam.

Връща: void
Triggers a SteamServerConnectFailure_t callback.
Triggers a SteamServersConnected_t callback.
Triggers a SteamServersDisconnected_t callback.

LogOn

void LogOn( const char *pszToken );
ИмеТипОписание
pszTokenconst char *

Begin process to login to a persistent game server account.

Връща: void
Triggers a SteamServerConnectFailure_t callback.
Triggers a SteamServersConnected_t callback.
Triggers a SteamServersDisconnected_t callback.


See Also: LogOnAnonymous

LogOnAnonymous

void LogOnAnonymous();
Login to a generic, anonymous account.

Връща: void
Triggers a SteamServerConnectFailure_t callback.
Triggers a SteamServersConnected_t callback.
Triggers a SteamServersDisconnected_t callback.


See Also: LogOn

RequestUserGroupStatus

bool RequestUserGroupStatus( CSteamID steamIDUser, CSteamID steamIDGroup );
ИмеТипОписание
steamIDUserCSteamIDThe user to check the group status of.
steamIDGroupCSteamIDThe group to check.

Checks if a user is in the specified Steam group.

Връща: bool
Triggers a GSClientGroupStatus_t callback.
true if the call was successfully sent out to the Steam servers; otherwise, false if we're not connected to the steam servers or an invalid user or group was provided.

SendUserConnectAndAuthenticate

bool SendUserConnectAndAuthenticate( uint32 unIPClient, const void *pvAuthBlob, uint32 cubAuthBlobSize, CSteamID *pSteamIDUser );
ИмеТипОписание
unIPClientuint32The IP address of the connecting client. This should be in host order, i.e 127.0.0.1 == 0x7f000001.
pvAuthBlobconst void *The authentication data provided by the user from a call to ISteamUser::InitiateGameConnection.
cubAuthBlobSizeuint32The size of pvAuthBlob in bytes.
pSteamIDUserCSteamID *Returns the Steam ID of the user. This must not be NULL.

Handles receiving a new connection from a Steam user. This will ask the Steam servers to validate the user's identity, app ownership, and VAC status.

If the Steam servers are off-line, then it will validate the cached ticket itself which will validate app ownership and identity.

ЗАБЕЛЕЖКА: This is part of the old user authentication API and should not be mixed with the new API.

Връща: bool
true if the users ticket passes basic checks; otherwise, false.

If this call is successful then you should expect a GSClientApprove_t or GSClientDeny_t callback which will tell you whether authentication for the user has succeeded or failed. The Steam ID in the callback will match the one returned by this call.

SendUserDisconnect

void SendUserDisconnect( CSteamID steamIDUser );
ИмеТипОписание
steamIDUserCSteamIDThe Steam ID of the user that has left the game server.

This should be called whenever a user leaves the game server.

This lets Steam internally track which users are currently on which servers for the purposes of preventing a single account being logged into multiple servers and showing who is currently on the server, etc.

ЗАБЕЛЕЖКА: This is part of the old user authentication API and should not be mixed with the new API.

SetBotPlayerCount

void SetBotPlayerCount( int cBotplayers );
ИмеТипОписание
cBotplayersintThe number of bot/AI players currently playing on the server.

Sets the number of bot/AI players on the game server. Стойността по подразбиране е 0.

SetDedicatedServer

void SetDedicatedServer( bool bDedicated );
ИмеТипОписание
bDedicatedboolIs this a dedicated server (true) or a listen server (false)?

Sets the whether this is a dedicated server or a listen server. The default is listen server.

ЗАБЕЛЕЖКА: This only be set before calling LogOn or LogOnAnonymous.

SetGameData

void SetGameData( const char *pchGameData );
ИмеТипОписание
pchGameDataconst char *The new "gamedata" value to set. Must not be NULL or an empty string (""). This can not be longer than k_cbMaxGameServerGameData.

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.

SetGameDescription

void SetGameDescription( const char *pszGameDescription );
ИмеТипОписание
pszGameDescriptionconst char *Описанието на играта Ви. Must not be NULL or an empty string (""). This can not be longer than k_cbMaxGameServerGameDescription.

Задава описанието на играта. Setting this to the full name of your game is recommended.

ЗАБЕЛЕЖКА: This is required for all game servers and can only be set before calling LogOn or LogOnAnonymous.

SetGameTags

void SetGameTags( const char *pchGameTags );
ИмеТипОписание
pchGameTagsconst char *The new "gametags" value to set. Must not be NULL or an empty string (""). This can not be longer than k_cbMaxGameServerTags.

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.

SetHeartbeatInterval

void SetHeartbeatInterval( int iHeartbeatInterval );
ИмеТипОписание
iHeartbeatIntervalintThe interval between sending heartbeats in milliseconds. Typically would range between 250-1000. Use -1 to use the default value.

Changes how often heartbeats are sent to the Steam master servers.

You usually don't need to use this.

See Also: EnableHeartbeats, ForceHeartbeat

SetKeyValue

void SetKeyValue( const char *pKey, const char *pValue );
ИмеТипОписание
pKeyconst char *
pValueconst char *

Add/update a rules key/value pair.

See Also: ClearAllKeyValues, ISteamMatchmakingServers::ServerRules

SetMapName

void SetMapName( const char *pszMapName );
ИмеТипОписание
pszMapNameconst char *The new map name to set. Must not be NULL or an empty string (""). This can not be longer than k_cbMaxGameServerMapName.

Sets the name of map to report in the server browser.

SetMaxPlayerCount

void SetMaxPlayerCount( int cPlayersMax );
ИмеТипОписание
cPlayersMaxintThe new maximum number of players allowed on this server.

Sets the maximum number of players allowed on the server at once.

This value may be changed at any time.

SetModDir

void SetModDir( const char *pszModDir );
ИмеТипОписание
pszModDirconst char *The game directory to set. Must not be NULL or an empty string (""). This can not be longer than k_cbMaxGameServerGameDir.

Sets the game directory.

This should be the same directory game where gets installed into. Just the folder name, not the whole path. (напр. „Spacewar“).

ЗАБЕЛЕЖКА: This is required for all game servers and can only be set before calling LogOn or LogOnAnonymous.

SetPasswordProtected

void SetPasswordProtected( bool bPasswordProtected );
ИмеТипОписание
bPasswordProtectedboolEnable (true) or disable (false) password protection.

Set whether the game server will require a password once when the user tries to join.

SetProduct

void SetProduct( const char *pszProduct );
ИмеТипОписание
pszProductconst char *The unique identifier for your game. Must not be NULL or an empty string ("").

Sets the game product identifier. This is currently used by the master server for version checking purposes.

Converting the games app ID to a string for this is recommended.

ЗАБЕЛЕЖКА: This is required for all game servers and can only be set before calling LogOn or LogOnAnonymous.

SetRegion

void SetRegion( const char *pszRegion );
ИмеТипОписание
pszRegionconst char *

Идентификатор на региона. This is an optional field, the default value is an empty string, meaning the "world" region.

SetServerName

void SetServerName( const char *pszServerName );
ИмеТипОписание
pszServerNameconst char *The new server name to set. Must not be NULL or an empty string (""). This can not be longer than k_cbMaxGameServerName.

Sets the name of server as it will appear in the server browser.

SetSpectatorPort

void SetSpectatorPort( uint16 unSpectatorPort );
ИмеТипОписание
unSpectatorPortuint16The port for spectators to join.

Set whether the game server allows spectators, and what port they should connect on. The default value is 0, meaning the service is not used.

SetSpectatorServerName

void SetSpectatorServerName( const char *pszSpectatorServerName );
ИмеТипОписание
pszSpectatorServerNameconst char *The spectator server name to set. Must not be NULL or an empty string (""). This can not be longer than k_cbMaxGameServerMapName.

Sets the name of the spectator server. This is only used if spectator port is nonzero.

UserHasLicenseForApp

EUserHasLicenseForAppResult UserHasLicenseForApp( CSteamID steamID, AppId_t appID );
ИмеТипОписание
steamIDCSteamIDThe Steam ID of the user that sent the auth ticket.
appIDAppId_tThe DLC App ID to check if the user owns it.

Checks if the user owns a specific piece of Сваляемо съдържание.

This can only be called after sending the users auth ticket to BeginAuthSession/

Връща: EUserHasLicenseForAppResult


See Also: User Authentication and Ownership

WasRestartRequested

bool WasRestartRequested();
Checks if the master server has alerted us that we are out of date.

This reverts back to false after calling this function.

Връща: bool
true if the master server wants this game server to update and restart; otherwise, false.

Callbacks

These are callbacks which can be fired by calling SteamAPI_RunCallbacks. Many of these will be fired directly in response to the member functions of ISteamGameServer.

AssociateWithClanResult_t

Sent when the game server attempted to be associated with a Steam Group.

ИмеТипОписание
m_eResultEResultРезултатът от операцията. Възможни стойности:

Associated Functions: AssociateWithClan

ComputeNewPlayerCompatibilityResult_t

Sent when the game server is checking if the new player is a good fit for the server based on the frenemy system.

ИмеТипОписание
m_eResultEResultРезултатът от операцията. Възможни стойности:
m_cPlayersThatDontLikeCandidateintThe number of current players that don't like playing with the specified player.
m_cPlayersThatCandidateDoesntLikeintThe number of players on the server that the specified player doesn't like playing with.
m_cClanPlayersThatDontLikeCandidateintThe number of players in the associated Steam group that don't like playing with the player.
m_SteamIDCandidateCSteamIDThe Steam ID of the specified player.

Associated Functions: ComputeNewPlayerCompatibility

GSClientAchievementStatus_t

Deprecated - Use ISteamGameServerStats instead.

ИмеТипОписание
m_SteamIDuint64Отживяло.
m_pchAchievementchar[128]Отживяло.
m_bUnlockedboolОтживяло.

GSClientApprove_t

A client has been approved to connect to this game server.

ИмеТипОписание
m_SteamIDCSteamIDThe Steam ID of the user that is wanting to connect.
m_OwnerSteamIDCSteamIDSteam № на притежателя на играта. Това ще е различно от m_SteamID, ако играта е достъпна чрез Steam „Семейно споделяне“.

GSClientDeny_t

Called when a user has been denied to connection to this game server.

ИмеТипОписание
m_SteamIDCSteamIDThe Steam ID of the user that attempted to connect.
m_eDenyReasonEDenyReasonThe reason the player was denied.
m_rgchOptionalTextchar[128]An optional text message explaining the deny reason. Typically unused except for logging.

GSClientGroupStatus_t

Извиква се, когато получим груповия статус на потребителя.

ИмеТипОписание
m_SteamIDUserCSteamIDThe user whose group status we queried.
m_SteamIDGroupCSteamIDThe group that we queried.
m_bMemberboolIs the user a member of the group (true) or not (false)?
m_bOfficerboolIs the user an officer in the group (true) or not (false)? This will never be true if m_bMember is false.

Associated Functions: RequestUserGroupStatus

GSClientKick_t

Called when the game server should kick the user.

ИмеТипОписание
m_SteamIDCSteamIDThe Steam ID of the player that should be kicked.
m_eDenyReasonEDenyReasonThe reason the player is being kicked.

GSGameplayStats_t

Deprecated - Called when gameplay stats info has been queried using GetGameplayStats.

ИмеТипОписание
m_eResultEResultРезултатът от операцията.
m_nRankint32The overall rank of the server (0-based).
m_unTotalConnectsuint32Total number of clients who have ever connected to the server.
m_unTotalMinutesPlayeduint32Total number of minutes ever played on the server.

Associated Functions: GetGameplayStats

GSPolicyResponse_t

Received when the game server requests to be displayed as secure (VAC protected)

ИмеТипОписание
m_bSecureuint8Is the server now set to secure (true) or unsecure (false)?.

GSReputation_t

Deprecated - Called when the game server reputation has been queried.

Master server bans are by IP so it is possible to be banned even when the score is good if there is a bad server on another port.
This information can be used to determine which server is bad.

ИмеТипОписание
m_eResultEResultРезултатът от операцията.
m_unReputationScoreuint32The reputation score for the game server.
m_bBannedboolIs the server is banned from the Steam master servers (true) or not (false)?
m_unBannedIPuint32The IP of the banned server. Only set if m_bBanned is true.
m_usBannedPortuint16The port of the banned server. Only set if m_bBanned is true.
m_ulBannedGameIDuint64The game ID the banned server is serving. Only set if m_bBanned is true.
m_unBanExpiresuint32The time when the ban expires, provided in Unix epoch format (seconds since Jan 1st 1970). Only set if m_bBanned is true.

Associated Functions: GetServerReputation

Constants

These are constants which are defined for use with ISteamGameServer.

ИмеТипСтойностОписание
k_unServerFlagActiveuint320x01The game server has users playing.
k_unServerFlagDedicateduint320x04This game server is dedicated.
k_unServerFlagLinuxuint320x08This game server is running on linux.
k_unServerFlagNoneuint320x00This game server has no flags.
k_unServerFlagPasswordeduint320x10This game server is password protected.
k_unServerFlagPrivateuint320x20This game server shouldn't be listed on master server and won't enforce authentication of users that connect to the server.
This is useful when you run a server where the clients may not be connected to the internet but you want them to allow them to play (i.e LANs).
k_unServerFlagSecureuint320x02This game server wants to be VAC secure.
MASTERSERVERUPDATERPORT_USEGAMESOCKETSHAREint((uint16)-1)Used with SteamGameServer_Init to enable GameSocketShare mode.
STEAMGAMESERVER_INTERFACE_VERSIONconst char *"SteamGameServer012"