如果可能的话,我如何找到一个空的Roblox组是否被锁定?这是我迄今为止的代码:
local group = game:GetService("GroupService")
local id = 0
local thisstop = false
game.Players.PlayerAdded:Connect(function(plr)
wait(2)
local function pcalltest()
while wait() do
print(id)
local stop = false
id += 1
local info = 0
if stop == false then
if group:GetGroupInfoAsync(id) then
local info = group:GetGroupInfoAsync(id)
print(table.concat(info, ", ", 1, #info))
if info["Owner"] then
local owner = info["Owner"]["Name"]
local id = info["Id"]
if owner then
local name = info["Name"]
local result = name.." (ID: "..id..") is owned by "..owner.."!"
print(result)
plr.PlayerGui.ScreenGui.TextLabel.Text = result
end
elseif info["Owner"] == nil then
local ok = game.ReplicatedStorage.TextButton:Clone()
ok.Parent = plr.PlayerGui.ScreenGui
plr.PlayerGui.ScreenGui.TextLabel.Text = "Group found! ID: "..id
thisstop= true
stop = true
repeat
wait()
ok.MouseButton1Click:Connect(function()
thisstop = false
stop = false
id += 1
ok:Destroy()
end)
until thisstop == false
end
else
id += 1
end
end
end
end
local function pcal()
local success, errormsg = pcall(pcalltest)
if success then
print("Success!")
else
warn("Error: "..errormsg)
id += 1
pcal()
end
end
pcal()
end)
我看了看";GroupService";在Roblox Creator文档中,但我认为我没有找到任何东西。有什么方法可以使";如果一个组被"锁定";finder?
我认为这段代码是为了查找被放弃但未锁定的组,以便用户对其进行声明。
我看到的唯一方法是通过组API来确定组是否被锁定。
/v1/groups/{groupId}
这个API调用将给出一个包含"publicEntryAllowed": true/false
的响应,它将告诉您它是否被锁定。唯一的问题是ROBLOX的HTTPService不允许调用自己的站点。您可以托管一些代理,例如rproxy,但这由您自己决定。
祝你的项目好运!
GroupService没有直接的方法来检查组是否被锁定。然而,您可以通过检查";GroupWall";已为组启用功能。像这个
local GroupService = game:GetService("GroupService")
local groupId = --id here
local success, groupInfo = pcall(GroupService.GetGroupInfoAsync, GroupService, groupId)
if success then
local isGroupWallEnabled = groupInfo["publicEntryAllowed"]
if isGroupWallEnabled then
print("Locked")
else
print("Not Locked")
end
else
warn("Error occurred while fetching group info.")
end