SGroup
客户端玩家
在此类中IsMemberOf
成员 5
| 函数 | IsMemberOf | Whether is a member of this group. |
| 函数 | GetGroupInfo | Get the group info by groupID. |
| 函数 | JoinGroup | Shows player a prompt to join specified group. |
| 函数 | LeaveGroup | Shows player a prompt to leave specified group. |
| 属性 | Membership | Return an array with all the groups this player is a member of |
函数
IsMemberOf
bool IsMemberOf(int groupID)
Whether is a member of this group.
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| groupID | int | – |
返回值
bool
示例
Lua
IsMember = Space.Groups.IsMemberOf(675)
Lua
--Clicking this object will check if player is a member of group with ID 350
--and it will turn green if you are, or red turn if you are not
thisObject = Space.Host.ExecutingObject
OnClickFunction = function()
if Space.Groups.IsMemberOf(350) then
thisObject.Renderer.Material.SetColor("_Color", Color.Green)
else
thisObject.Renderer.Material.SetColor("_Color", Color.Red)
end
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
GetGroupInfo
Get the group info by groupID.
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| groupID | int | – |
返回值
SGroupInfo
示例
Lua
groupInfo = Space.Groups.GetGroupInfo(675)
Lua
--Clicking this object will turn green if your in group 350 is "Owner"
--and red if your role is not "Owner"
thisObject = Space.Host.ExecutingObject
OnClickFunction = function()
local groupInfo = Space.Groups.GetGroupInfo(350)
if groupInfo.Role == "Owner" then
thisObject.Renderer.Material.SetColor("_Color", Color.Green)
else
thisObject.Renderer.Material.SetColor("_Color", Color.Red)
end
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
JoinGroup
void JoinGroup(int groupID, bool force = false)
Shows player a prompt to join specified group. If force is true, the user will not be shown a prompt. (force parameter is white-label only)
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| groupID | int | – |
| force | bool | false |
返回值
void
示例
Lua
Space.Groups.JoinGroup(675)
Lua
--Clicking this object will check if player is in group 350
--and will prompt the player to leave if they are a member
--and will prompt them to join if they are not a member
thisObject = Space.Host.ExecutingObject
OnClickFunction = function()
if Space.Groups.IsMemberOf(350) then
Space.Groups.LeaveGroup(350)
else
Space.Groups.JoinGroup(350)
end
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
LeaveGroup
void LeaveGroup(int groupID, bool force = false)
Shows player a prompt to leave specified group. If force is true, the user will not be shown a prompt. (force parameter is white-label only)
参数
| 名称 | 类型 | 默认值 |
|---|---|---|
| groupID | int | – |
| force | bool | false |
返回值
void
示例
Lua
Space.Groups.LeaveGroup(675)
Lua
--Clicking this object will check if player is in group 350
--and will prompt the player to leave if they are a member
--and will prompt them to join if they are not a member
thisObject = Space.Host.ExecutingObject
OnClickFunction = function()
if Space.Groups.IsMemberOf(350) then
Space.Groups.LeaveGroup(350)
else
Space.Groups.JoinGroup(350)
end
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)
属性
Membership只读
Return an array with all the groups this player is a member of
示例
Lua
groups = Space.Groups.Membership
Lua
--Clicking this object will turn green if you are in at least 1 group
--and red if you are in no groups
thisObject = Space.Host.ExecutingObject
OnClickFunction = function()
local groups = Space.Groups.Membership
if #groups > 0 then
thisObject.Renderer.Material.SetColor("_Color", Color.Green)
else
thisObject.Renderer.Material.SetColor("_Color", Color.Red)
end
end
thisObject.AddClickable()
thisObject.Clickable.OnClick(OnClickFunction)



