Ir para o conteúdo principal
Version: bleeding-edge 🩸

🎮 Steam

Interact with Steam APIs.

🗿Static ClassClient Only🧑‍💻API Source

🗿 Static Functions​

ReturnsNameDescription
string or nilGetJoinedFromFriendGets the SteamID of the Friend whose invite or "Join Game" brought this player to the current server
booleanInviteFriendInvites 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

Optimal

GetJoinedFromFriend​

Gets the SteamID of the Friend whose invite or "Join Game" brought this player to the current server, or 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

TypeDescription
string or nilThe Friend's SteamID, or <code>nil</code>
Steam.GetJoinedFromFriend Examples
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)

Optimal

InviteFriend​

Invites a Steam Friend to the current server
local ret = Steam.InviteFriend(steam_id)

Parameters

TypeParameterDefaultDescription
stringsteam_id Required parameter The SteamID of the Friend to invite

Returns

TypeDescription
booleanIf the invite was sent

Optimal

OpenInviteDialog​

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()

Optimal

SetRichPresence​

Sets Steam Rich Presence text
Steam.SetRichPresence(text)

Parameters

TypeParameterDefaultDescription
stringtext Required parameter The new Steam Rich Presence text

Optimal

TriggerScreenshot​

Triggers a Steam screenshot
Steam.TriggerScreenshot()

🚀 Events​

NameDescription
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

TypeArgumentDescription
stringfriend_steam_idThe SteamID of the Friend