🎮 Steam
与 Steam API 交互。
🗿 静态函数
| Returns | Name | Description | |
|---|---|---|---|
| string or nil | GetJoinedFromFriend | 获取通过邀请或“加入游戏”将该玩家带到当前服务器的好友的 SteamID | |
| boolean | InviteFriend | 邀请一位 Steam 好友加入当前服务器 | |
OpenInviteDialog | 打开 Steam 叠加界面邀请对话框,以便玩家可以邀请好友加入当前服务器 | ||
SetRichPresence | 设置 Steam 丰富状态文本 | ||
TriggerScreenshot | 触发 Steam 屏幕截图 |
Optimal

GetJoinedFromFriend
获取通过邀请或“加入游戏”将该玩家带到当前服务器的好友的 SteamID。
如果他们通过其他方式连接,则为nil。
该值由客户端报告,因此服务器不应盲目信任它(例如,在将玩家添加到私密组之前先让好友确认)。
local ret = Steam.GetJoinedFromFriend()
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
邀请一位 Steam 好友加入当前服务器
local ret = Steam.InviteFriend(steam_id)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | steam_id | Required parameter | 要邀请的好友的 SteamID |
Returns
| Type | Description |
|---|---|
| boolean | 邀请是否已发送 |
Optimal

OpenInviteDialog
打开 Steam 叠加界面邀请对话框,以便玩家可以邀请好友加入当前服务器。
当好友接受时,他们会加入此服务器,并且Steam.GetJoinedFromFriend()会在他们那一侧返回该玩家的 SteamID。如果他们已在此服务器上,则会改为调用FriendJoin事件
Steam.OpenInviteDialog()
Optimal

SetRichPresence
设置 Steam 丰富状态文本
Steam.SetRichPresence(text)
Parameters
| Type | Parameter | Default | Description |
|---|---|---|---|
| string | text | Required parameter | 新的 Steam 丰富状态文本 |
Optimal

TriggerScreenshot
触发 Steam 屏幕截图
Steam.TriggerScreenshot()
🚀 事件
| Name | Description | |
|---|---|---|
FriendJoin | 当该玩家接受好友的邀请或通过“加入游戏”加入他们已在的服务器时调用 |

FriendJoin
当该玩家接受好友的邀请或通过“加入游戏”加入他们已在的服务器时调用。
在这种情况下,玩家不会重新连接。
当玩家从其他服务器或从菜单连接时,请改用Steam.GetJoinedFromFriend()。
Steam.Subscribe("FriendJoin", function(friend_steam_id)
-- FriendJoin was called
end)
Arguments
| Type | Argument | Description |
|---|---|---|
| string | friend_steam_id | 好友的 SteamID |
