Raised This Month: $32 Target: $400
 8% 

[DEV] GroupHandlerAPI


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Mitchell
~lick~
Join Date: Mar 2010
Plugin ID:
6502
Plugin Version:
1.1.0
Plugin Category:
Technical/Development
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
     
    Plugin Description:
    Allows other plugins to easily assign groups to players/admins
    Old 04-07-2019 , 15:04   [DEV] GroupHandlerAPI
    Reply With Quote #1

    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)

    Last edited by Mitchell; 04-07-2019 at 15:04.
    Mitchell is offline
    Mitchell
    ~lick~
    Join Date: Mar 2010
    Old 04-07-2019 , 16:35   Re: [DEV] GroupHandlerAPI
    Reply With Quote #2

    Im pretty sure i forgot to comment out the debug log define in the 1.1.0 release, going to do a quick patch

    Edit: Release 1.1.1 was added to the GitHub releases.

    Last edited by Mitchell; 04-07-2019 at 17:40.
    Mitchell is offline
    Mitchell
    ~lick~
    Join Date: Mar 2010
    Old 04-12-2019 , 18:50   Re: [DEV] GroupHandlerAPI
    Reply With Quote #3

    Release v1.1.2 Changelog:
    • This is a quick bug fix for accessing an index out of bounds of a dynamic array.

    Download:
    Github Tag
    Mitchell is offline
    Reply



    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off

    Forum Jump


    All times are GMT -4. The time now is 04:15.


    Powered by vBulletin®
    Copyright ©2000 - 2024, vBulletin Solutions, Inc.
    Theme made by Freecode