Ir para o conteúdo principal
Version: latest - a1.172.0 ⚖️

🎮 Steam

Interact with Steam APIs

🗿Static ClassClient Only🧑‍💻API Source

🗿 Static Functions​

GetJoinedFromFriend: string or nilGets the SteamID of the Friend whose invite or "Join Game" brought this player to the current server
InviteFriend: booleanInvites a Steam Friend to the current server
OpenInviteDialogOpens the Steam Overlay invite dialog, so the player can invite Friends to the current server
SetRichPresenceSets Steam Rich Presence text
TriggerScreenshotTriggers a Steam screenshot

GetJoinedFromFriendOptimal​

Gets the SteamID of the Friend whose invite or "Join Game" brought this player to the current server

It is nil if they connected any other way.

This value is reported by the client, so a server should not trust it blindly (e.g. ask the Friend to accept before adding the player to a private group)

local ret = Steam.GetJoinedFromFriend()
Returns
TypeDescrição
string or nilThe Friend's SteamID, or nil
Examples (1)
Puts a player in the party of the Friend who invited them
-- Client side
local function JoinFriendParty(friend_steam_id)
Events.CallRemote("JoinFriendParty", friend_steam_id)
end

-- If we connected through an invite or "Join Game"
local friend_steam_id = Steam.GetJoinedFromFriend()
if (friend_steam_id) then
JoinFriendParty(friend_steam_id)
end

-- If we accepted an invite to the server we are already on
Steam.Subscribe("FriendJoin", JoinFriendParty)

-- Server side
Events.SubscribeRemote("JoinFriendParty", function(player, friend_steam_id)
for _, other in pairs(Player.GetAll()) do
if (other:GetSteamID() == friend_steam_id) then
-- Adds player to other's party
break
end
end
end)

InviteFriendOptimal​

Invites a Steam Friend to the current server

local ret = Steam.InviteFriend(steam_id)
Parameters
NameTypeDescrição
steam_idstringThe SteamID of the Friend to invite
Returns
TypeDescrição
booleanIf the invite was sent

OpenInviteDialogOptimal​

Opens the Steam Overlay invite dialog, so the player can invite Friends to the current server

When a Friend accepts, they join this server and Steam.GetJoinedFromFriend() returns this player's SteamID on their side. If they were already on this server, the FriendJoin event is called instead

Steam.OpenInviteDialog()

SetRichPresenceOptimal​

Sets Steam Rich Presence text

Steam.SetRichPresence(text)
Parameters
NameTypeDescrição
textstringThe new Steam Rich Presence text

TriggerScreenshotOptimal​

Triggers a Steam screenshot

Steam.TriggerScreenshot()

🚀 Events​

FriendJoinCalled when this player accepts a Friend's invite or "Join Game" to the server they are already on

FriendJoin​

Called when this player accepts a Friend's invite or "Join Game" to the server they are already on

In this case the player does not reconnect.

When the player connects from another server or from the menus, use Steam.GetJoinedFromFriend() instead

Steam.Subscribe("FriendJoin", function(friend_steam_id)
-- FriendJoin was called
end)
Arguments
NameTypeDescrição
friend_steam_idstringThe SteamID of the Friend