Group Handler API
This API allows developers to append groups to players instead of worrying about getting their adminId and reapplying it every time the cache is rebuilt. sm_reloadadmins will reapply the groups that are registered to users. Mapchanges and player disconnects clears the cache, however you should be using OnClientPostAdminCheck to assign the group anyways.
The Groups can also be normal admin groups set within Sourcebans or admin_groups.cfg, allowing server operators to completely customize what flags or access that group is allowed.
CheckCommandAccess can be properly used with this api as all groups registered are given the override of the group name.
Since this uses admin groups as a developer you no longer have to worry about adding or removing flags from a user, however you cannot properly delete a group from a user without unassigning their group and using DumpAdminCache().
This was created because I wanted several plugins to essentially do the same thing and kind of flew with the idea in order to allow creating those separate plugins not worry about the flag assigning issue.
More information
Example Plugin:
Code:
char myGroupNames[5][] = {
"Group #1",
"Group #2",
"Group #3",
"Group #4",
"Cool Group"
};
public void OnClientPostAdminCheck(int client) {
int groupNum = 1; // * Does some kind of awesome calls to some kind of database some where to set this *
//Only assigns the player to this group if it exists, wont create the group.
// Be warned though, if you're creating the group within your plugin then assign the player it'll stick.
// So make sure that you use the forward for whenever a new group is created instead.
GroupHandler_Assign(client, myGroupNames[0], false);
//Assign the player to the group
if(groupNum >= 0 && groupNum < 5) {
//Only add in if the groupNum
GroupHandler_Assign(client, myGroupNames[groupNum]);
}
}
public void GroupHandler_GroupCreated(char[] groupName, GroupId groupId) {
//Called if the group wasn't found and was created as a temp group
if(StrEqual(groupName, "Cool Group")) {
groupId.SetFlag(Admin_Custom4, true);
}
}
Releases (Plugin)
GitHub (Source)