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

[ANY] Basic Donator Interface


Post New Thread Reply   
 
Thread Tools Display Modes
Author
toazron1
Senior Member
Join Date: Oct 2006
Plugin ID:
2130
Plugin Version:
0.4
Plugin Category:
Server Management
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
    10 
    Plugin Description:
    Provides an interface donator functions in other plugins
    Old 12-17-2010 , 11:50   [ANY] Basic Donator Interface
    Reply With Quote #1

    This plugin provides a backend for other plugins to interface with, acting as a core to simplify adding donator support to existing / new plugins.

    Note: This is a repost of http://forums.alliedmods.net/showthread.php?t=122315 which broke from quick editing.

    Information:
    After spending hours modifying/creating plugins with donator features only to have to go back into each one to make changes every time I needed to make a modification to the database layout I set out to develop an easier way.

    A thanks goes out to [AAA] Thrawn for pointing me in the right direction with the menu registering (and stealing his naming scheme).
    Commands:
    !donators (or CHAT_TRIGGER) - Lets donators access the menu.
    sm_reloaddonators - Lets admins >= ADMFLAG_BAN reload the donator database.
    Natives:
    PHP Code:
    /**
     * Register a menu item.
     * 
     * @param name            Name of the menu item.
     * @param func            Callback for menu items.
     * @return                Menu item ID.
     */
    native Donator_RegisterMenuItem(const String:name[], DonatorMenuCallback:callback);

    /**
     * Unregister a menu item.
     * 
     * @param name            Name of the menu item.
     * @param func            Callback for menu items.
     * @return                Bool
     */
    native Donator_UnregisterMenuItem(iItemId);

    /**  
     * Get a clients donator level, -1 if invalid
     * 
     * @param iClient    Client
     * @return            Donator level
     */
    native GetDonatorLevel(iClient);

    /**  
     * Sets a clients donator level
     *
     * @param iClient        Client
     * @param iLevel        Donator level
     * @return                Nothing
     */
    native SetDonatorLevel(iClientiLevel);

    /**  
     * Returns True if a client is a donator, -1 if invalid
     * 
     * @param iClient    Client
     * @return            bool
     */
    native bool:IsPlayerDonator(iClient);

    /**  
     * Returns True if a steamid is a donator, -1 if invalid
     * 
     * @param iClient    Client
     * @return            bool
     */
    native bool:FindDonatorBySteamId(const String:szSteamId[]);

    /**  
     * Returns a clients connect message
     
     * @param iClient        Client
     * @return                Clients connect message
     */
    native GetDonatorMessage(iClient, const String:szMessage[], iLength);

    /**  
     * Sets a donators connect message
     *
     * @param iClient        Client
     * @param szMessage        Message to show on donator connect
     * @return                Nothing
     */
    native SetDonatorMessage(iClient, const String:szMessage[]); 
    Forwards:
    PHP Code:
    /**
     * Forwards when a donator connects.
     * Note: This is before OnPostDonatorCheck - Cookies are not loaded here
     *
     * @param iClient        Client
     * @noreturn
     */
    forward OnDonatorConnect(iClient);

    /**
     * Forwards after OnPostAdminCheck for everyone.
     *
     * @param iClient        Client
     * @noreturn
     */
    forward OnPostDonatorCheck(iClient);

    /**
     * Forwards after the donators has been reladed with sm_reloaddonators.
     *
     * @param iClient        Client
     * @noreturn
     */
    forward OnDonatorsChanged(); 
    Usage
    For example, if you wanted to make donators immune to the auto team balance in gScramble you can add an IsPlayerDonator(client) check into the IsValidTarget(...) check to skip a player who is a donator.

    Another feature is a centralized menu for plugins to register with which can minimize the amount of commands a player has to remember. This menu can be access by typing whatever CHAT_TRIGGER is set to (defaults !donators).

    To register a menu with the core:
    PHP Code:
    public OnAllPluginsLoaded()
    {
        if(!
    LibraryExists("donator.core")) SetFailState("Unabled to find plugin: Basic Donator Interface");
        
    Donator_RegisterMenuItem("MENU TITLE"MenuCallback);

    See one of the attached plugins for an example of a fully functional example.
    Flat File Setup:
    The plugin looks for a text file named donators.txt (DONATOR_FILE) in the sourcemod/data directory
    The file format is as follows:
    PHP Code:
    STEAMID;LEVEL 
    mySQL Setup:
    Note: If you are using the flat file option, you can skip this.

    If you do not already have an existing table you want to use (IE forums or another donator style setup.. if you do skip down a little) you need to create a new one (you can use a new database or a current one as long as it is a clean table).

    In this database make a new table, we will call it: donators
    If you decide to change the table name be sure and change the SQL_DBNAME define to your new table name.
    Code:
        CREATE TABLE IF NOT EXISTS `donators` (
          `steamid` varchar(64) default NULL,
          `tag` varchar(128) NOT NULL,
          `level` tinyint(1) NOT NULL default '1'
        )
    If you already have an existing table you want to use make sure that this table has the 3 columns needed (steamid, tag, level) Also, if you have them named different make sure you update the db_cols strings in the plugin.

    Also be sure and change SQL_CONFIG if you are not using default.
    Example:
    Examples for visual learners:
    donator.chatcolor - gives donators the ability to set their chat color. If you want to use yellow (tf2) uncomment the define.
    Note:
    This was developed for TF2 and I have not tested it in any other game, however, there is nothing TF2 specific within the core so there is no reason it shouldn't work.

    Compiling Information:

    You must have loghelper.inc to compile donator.chatcolor
    The web compiler will not work.
    You must compile donator.core manually (it requires donator.inc)
    Please feel free to post suggestions / questions / comments / criticisms

    Previous downloads: 247
    Attached Files
    File Type: inc donator.inc (2.3 KB, 4654 views)
    File Type: sp Get Plugin or Get Source (donator.core.sp - 4402 views - 14.0 KB)
    File Type: sp Get Plugin or Get Source (donator.colorchat.sp - 3572 views - 4.4 KB)
    __________________

    Last edited by toazron1; 02-17-2011 at 09:30.
    toazron1 is offline
    Send a message via AIM to toazron1
    toazron1
    Senior Member
    Join Date: Oct 2006
    Old 12-17-2010 , 11:50   Re: [ANY] Basic Donator Interface
    Reply With Quote #2

    Plugins using this interface:

    TF2: Donator Recognition
    __________________
    toazron1 is offline
    Send a message via AIM to toazron1
    TyanColte
    Member
    Join Date: Sep 2010
    Old 10-08-2011 , 13:04   Re: [ANY] Basic Donator Interface
    Reply With Quote #3

    Quote:
    Originally Posted by toazron1 View Post
    Plugins using this interface:

    TF2: Donator Recognition
    Also using this interface

    Donator Skin Color Mod
    __________________
    TyanColte is offline
    toazron1
    Senior Member
    Join Date: Oct 2006
    Old 12-17-2010 , 11:51   Re: [ANY] Basic Donator Interface
    Reply With Quote #4

    Reserved
    __________________
    toazron1 is offline
    Send a message via AIM to toazron1
    xomp
    BANNED
    Join Date: Jul 2008
    Old 12-17-2010 , 20:40   Re: [ANY] Basic Donator Interface
    Reply With Quote #5

    Quote:
    //SourceMod Batch Compiler
    // by the SourceMod Dev Team


    //// donator.colorchat.tf2.sp
    // C:\Users\Josh\Desktop\sourcemod-1.3.4-hg2998\addons\sourcemod\scripting\donat
    or.colorchat.tf2.sp(4) : fatal error 120: cannot read from file: "loghelper"
    //
    // Compilation aborted.
    // 1 Error.
    //
    // Compilation Time: 0.73 sec
    // ----------------------------------------

    Press enter to exit ...
    Happens when I try to compile the donator.colorchat.tf2.sp ** Thanks to psychonic I managed to get it to compile using the loghelper.inc here which you may want to link to in your OP since it's required for compiling.

    Also, where exactly does this look for a "donators.txt" file? I have mine set in sourcemod/configs and hope it can locate it there.

    Also thanks for fixing this

    Last edited by xomp; 12-17-2010 at 20:47.
    xomp is offline
    Send a message via Skype™ to xomp
    toazron1
    Senior Member
    Join Date: Oct 2006
    Old 12-17-2010 , 20:54   Re: [ANY] Basic Donator Interface
    Reply With Quote #6

    I knew I forgot something. I'll update it when I get home, the iPhone does not like this site lol. Thanks for the heads up.
    __________________
    toazron1 is offline
    Send a message via AIM to toazron1
    xomp
    BANNED
    Join Date: Jul 2008
    Old 12-17-2010 , 20:59   Re: [ANY] Basic Donator Interface
    Reply With Quote #7

    Also, if you can include instructions in the OP for those of us who have an sv_pure server it would be helpful
    xomp is offline
    Send a message via Skype™ to xomp
    naris
    AlliedModders Donor
    Join Date: Dec 2006
    Old 12-18-2010 , 01:41   Re: [ANY] Basic Donator Interface
    Reply With Quote #8

    Why is the plugin called dontator.core?
    naris is offline
    toazron1
    Senior Member
    Join Date: Oct 2006
    Old 12-18-2010 , 03:18   Re: [ANY] Basic Donator Interface
    Reply With Quote #9

    Quote:
    Originally Posted by naris View Post
    Why is the plugin called dontator.core?
    That's because I'm terrible at spelling and consistency. I'll fix that, and add the pure instructions tomorrow.
    __________________
    toazron1 is offline
    Send a message via AIM to toazron1
    xomp
    BANNED
    Join Date: Jul 2008
    Old 12-18-2010 , 18:05   Re: [ANY] Basic Donator Interface
    Reply With Quote #10

    Well, I installed this plugin right before the major Valve X-Mas faildate and it's not working.

    Quote:
    54 <Error> "Donator Recognition" (0.5) by Nut
    55 <Error> "Donator: Colored Chat" (0.2) by Nut
    56 <Error> "Basic Donator Interface" (0.4) by Nut
    Quote:
    Filename: donator.recognition.tf2.smx
    Title: Donator Recognition (Give donators the recognition they deserve.)
    Author: Nut
    Version: 0.5
    URL: http://www.lolsup.com/tf2
    Error: Unabled to find plugin: Basic Donator Interface
    Timestamp: 12/18/2010 01:56:52
    Quote:
    Filename: donator.colorchat.tf2.smx
    Title: Donator: Colored Chat (Donators get colored chat!)
    Author: Nut
    Version: 0.2
    Error: Unabled to find plugin: Basic Donator Interface
    Timestamp: 12/18/2010 01:45:49
    Quote:
    Filename: donator.core.smx
    Title: Basic Donator Interface (A core to handle donator related plugins)
    Author: Nut
    Version: 0.4
    URL: http://www.lolsup.com/tf2
    Error: Error detected in plugin startup (see error logs)
    Timestamp: 12/18/2010 01:419
    xomp is offline
    Send a message via Skype™ to xomp
    Reply


    Thread Tools
    Display Modes

    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 09:01.


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