Manage Groups
Create a New Group
You can create a new group once you have a group configuration in your namespace. The members of your group will be admins by default.
- Unreal Engine
- Unity
FAccelByteModelsGroupRules GroupRules;
FAccelByteModelsCreateGroupRequest GroupConfiguration;
GroupConfiguration.GroupName = "MyNewGroupName";
GroupConfiguration.GroupType = EAccelByteGroupType::OPEN;
GroupConfiguration.GroupMaxMember = 25;
GroupConfiguration.GroupDescription = "MyNewGroupDescription";
GroupConfiguration.GroupIcon = "https://example.com";
GroupConfiguration.GroupRegion = "US";
GroupConfiguration.GroupRules = GroupRules;
GroupConfiguration.ConfigurationCode = "MyConfiguration Code";
FRegistry::Group.CreateGroup(
GroupConfiguration,
THandler<FAccelByteModelsGroupInformation>::CreateWeakLambda(this, [this](const FAccelByteModelsGroupInformation& Result)
{
// Do something if CreateGroup has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if CreateGroup has an error
}));
RuleInformation ruleInformation = new RuleInformation
{
ruleAttribute = "MyRuleAttribute",
ruleCriteria = RuleCriteria.MAXIMUM,
ruleValue = 50.0f
};
Rules rules = new Rules
{
allowedAction = AllowedAction.joinGroup,
ruleDetail = [ruleInformation]
};
GroupRules groupRules = new GroupRules
{
groupCustomRule = {},
groupPredefinedRules = [rules]
};
CreateGroupRequest createGroupRequest = new CreateGroupRequest
{
groupName = "MyNewGroupName",
groupType = GroupType.OPEN,
groupMaxMember = 25,
groupDescription = "MyNewGroupDescription",
groupIcon = "https://example.com",
groupRegion = "US",
groupRules = groupRules,
configurationCode = "MyConfiguration Code",
customAttributes = new Dictionary<string, object>
{
{ "sword", 3 },
{ "armor", 7 }
}
};
AccelBytePlugin.GetGroup().CreateGroup(createGroupRequest, result =>
{
if (result.IsError)
{
// Do something if CreateGroup has an error
Debug.Log($"Error CreateGroup, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if CreateGroup has been successful
}
});
Retrieve a List of Groups
Search for a group by its name or region. The results will be paginated, and you can use offset and limit parameters to limit the list. This function only shows PUBLIC and OPEN groups.
- Unreal Engine
- Unity
FAccelByteModelsGetGroupListRequest SearchConfiguration;
SearchConfiguration.GroupName = "SomeGroupName"; // You can leave it blank if you want to fetch all the groups
SearchConfiguration.GroupRegion = "US"; // You can leave it blank if you want to fetch all the groups
SearchConfiguration.Offset = 0;
SearchConfiguration.Limit = 99;
FRegistry::Group.GetGroupList(
SearchConfiguration,
THandler<FAccelByteModelsGetGroupListResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsGetGroupListResponse& Result)
{
// Do something if GetGroupList has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetGroupList has an error
}));
string groupName = "SomeGroupName"; // You can leave it blank if you want to fetch all the groups
string groupRegion = "US"; // You can leave it blank if you want to fetch all the groups
int offset = 0;
int limit = 99;
AccelBytePlugin.GetGroup().SearchGroups(groupName, groupRegion, offset, limit, result =>
{
if (result.IsError)
{
// Do something if SearchGroups has an error
Debug.Log($"Error SearchGroups, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if SearchGroups has been successful
}
});
Retrieve Group Information
Get information about a group by using the Group ID.
- Unreal Engine
- Unity
FString groupId = "SomeGroupId";
FRegistry::Group.GetGroup(
groupId,
THandler<FAccelByteModelsGroupInformation>::CreateWeakLambda(this, [this](const FAccelByteModelsGroupInformation& Result)
{
// Do something if GetGroup has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetGroup has been successful
}));
string groupId = "SomeGroupId";
AccelBytePlugin.GetGroup().GetGroup(groupId, result =>
{
if (result.IsError)
{
// Do something if GetGroup has an error
Debug.Log($"Error GetGroup, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if GetGroup has been successful
}
});
Retrieve a Player's Group Information
You can get your current player's group information by using this function. If the player you requested doesn't belong to any group, the returned status will be ErrorCode.UserNotBelongToAnyGroup, and the player will be able to be invited to a group.
- Unreal Engine
- Unity
FString UserId = "CurrentPlayerUserId";
FRegistry::Group.GetUserGroupInfoByUserId(
UserId,
THandler<FAccelByteModelsGetUserGroupInfoResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsGetUserGroupInfoResponse& Result)
{
// Do something if GetUserGroupInfoByUserId has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetUserGroupInfoByUserId has an error
}));
AccelBytePlugin.GetGroup().GetMyGroupInfo(result =>
{
if (result.IsError)
{
// Do something if GetMyGroupInfo has an error
Debug.Log($"Error GetMyGroupInfo, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if GetMyGroupInfo has been successful
}
});
Retrieve Other Player's Group Information
This function is to call the group information of other users with a specific user ID.
- Unreal Engine
- Unity
FString UserId = "OtherPlayerUserId";
FRegistry::Group.GetUserGroupInfoByUserId(
UserId,
THandler<FAccelByteModelsGetUserGroupInfoResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsGetUserGroupInfoResponse& Result)
{
// Do something if GetUserGroupInfoByUserId has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetUserGroupInfoByUserId has an error
}));
string userid = "SomeUserId";
AccelBytePlugin.GetGroup().GetOtherGroupInfo(userId, result =>
{
if (result.IsError)
{
// Do something if GetOtherGroupInfo has an error
Debug.Log($"Error GetOtherGroupInfo, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if GetOtherGroupInfo has been successful
}
});
Retrieve a Group's Member List
Use this function to get a group's member list.
- Unreal Engine
- Unity
FString GroupId = "SomeGroupId";
FAccelByteModelsGetGroupMembersListByGroupIdRequest SearchGroupMemberConfiguration;
FRegistry::Group.GetGroupMembersListByGroupId(
GroupId,
SearchGroupMemberConfiguration,
THandler<FAccelByteModelsMemberRequestGroupResponse>::CreateWeakLambda(this, [this](const FAccelByteModelsMemberRequestGroupResponse& Result)
{
// Do something if GetGroupMembersListByGroupId has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if GetGroupMembersListByGroupId has an error
}));
string groupId = "SomeGroupId";
AccelBytePlugin.GetGroup().GetGroupMemberList(groupId, result =>
{
if (result.IsError)
{
// Do something if GetGroupMemberList has an error
Debug.Log($"Error GetGroupMemberList, Error Code: {result.Error.Code} Error Code: {result.Error.Message}");
}
else
{
// Do something if GetGroupMemberList has been successful
}
});
Update Group Information
A group's information such as its name, icon, description, region, and type can be updated with this function. Only members with an admin role can update the group's information.
- Unreal Engine
- Unity
FString GroupId = "SomeGroupId";
FAccelByteModelsGroupUpdatable UpdateGroupConfiguration;
FRegistry::Group.UpdateGroup(
GroupId,
True, // set True if you want to replace all group informations
UpdateGroupConfiguration,
THandler<FAccelByteModelsGroupInformation>::CreateWeakLambda(this, [this](const FAccelByteModelsGroupInformation& Result)
{
// Do something if UpdateGroup has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UpdateGroup has an error
}));
string groupId = "SomeGroupId";
AccelBytePlugin.GetGroup().UpdateGroup(groupId, updateGroupRequest, result =>
{
if (result.IsError)
{
// Do something if UpdateGroup has an error
Debug.Log($"Error UpdateGroup, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if UpdateGroup has been successful
}
});
Update a Group's Custom Attributes
You can also update a group's custom attributes separately using this function. Just like the group information update, only members with an admin role can update the group's custom attributes.
- Unreal Engine
- Unity
FString GroupId = "SomeGroupId";
FAccelByteModelsUpdateGroupCustomAttributesRequest UpdateGroupCustomAttributeGroup;
FRegistry::Group.UpdateGroupCustomAttributes(
GroupId,
UpdateGroupCustomAttributeGroup,
THandler<FAccelByteModelsGroupInformation>::CreateWeakLambda(this, [this](const FAccelByteModelsGroupInformation& Result)
{
// Do something if UpdateGroupCustomAttributes has been successful
}),
FErrorHandler::CreateWeakLambda(this, [](int32 ErrorCode, const FString& ErrorMessage)
{
// Do something if UpdateGroupCustomAttributes has an error
}));
Dictionary<string, object> customAttributes = new Dictionary<string, object>
{
{ "requirementLevel", 50 },
{ "requirementItem", 25 }
};
string groupId = "SomeGroupId";
AccelBytePlugin.GetGroup().UpdateGroupCustomAttributes(groupId, customAttributes, result =>
{
if (result.IsError)
{
// Do something if UpdateGroupCustomAttributes has an error
Debug.Log($"Error UpdateGroupCustomAttributes, Error Code: {result.Error.Code} Error Message: {result.Error.Message}");
}
else
{
// Do something if UpdateGroupCustomAttributes has been successful
}
});