Raised This Month: $51 Target: $400
 12% 

[ANY] Favorite Connections (v1.1, 2015-2-7)


Post New Thread Reply   
 
Thread Tools Display Modes
Author
Nanochip
Senior Member
Join Date: Jan 2014
Plugin ID:
4504
Plugin Version:
1.1
Plugin Category:
Technical/Development
Plugin Game:
Any
Plugin Dependencies:
    Servers with this Plugin:
    3 
    Plugin Description:
    Plugin for developers to use as an API to detect when a client connects through his/her favorites.
    Old 01-27-2015 , 19:26   [ANY] Favorite Connections (v1.1, 2015-2-7)
    Reply With Quote #1

    [ANY] Favorite Connections
    Special thanks to Wolvan for the example and helping me with forwards.




    Description:
    Small plugin for developers to use as an API using the forward "ClientConnectedViaFavorites" to detect when a player connects through his/her favorites.
    Please note that this plugin ALONE literally does nothing and only serves as an API for developers.
    Side note: this is my first plugin to publish on here and I am still pretty new to Sourcepawn. Any suggestions are more than welcome, but please be nice!

    Dependencies:
    Due to the use of "cl_connectmethod", this plugin only works on the following games:
    • Team Fortress 2
    • Day of Defeat: Source
    • Counter-Strike: Source
    • Half Life 2: Deathmatch

    CVARS:
    • favoriteconnections_version - Plugin version, no touchy!
    • favoriteconnections_enable [0/1] - (Default = 1) Enable plugin = 1 Disable plugin = 0

    Forward:
    Code:
    forward Action:ClientConnectedViaFavorites(client);
    Example:
    Code:
    public Action:ClientConnectedViaFavorites(client)
    {
    	new String:name[MAX_NAME_LENGTH];
    	GetClientName(client, name, sizeof(name));
    	PrintToChatAll("%s joined this server through his/her favorites! Thank you!", name);
    	return Plugin_Continue;
    }
    Please note that the callback on the end is Plugin_Continue!

    Plugins That Use Favorite Connestions:
    Changelog:
    Spoiler


    Installation:
    1. favoriteconnections.smx -> (game)/addons/sourcemod/plugins/
    2. (for developers) favoriteconnections.sp -> (game)/addons/sourcemod/scripting/

    Want to support me?
    • Leave some feedback of this plugin and/or a suggestion.
    Attached Files
    File Type: sp Get Plugin or Get Source (favoriteconnections.sp - 1384 views - 1.9 KB)
    __________________

    Last edited by Nanochip; 08-31-2015 at 01:56. Reason: Version 1.1
    Nanochip is offline
    Sreaper
    髪を用心
    Join Date: Nov 2009
    Old 01-27-2015 , 19:32   Re: [ANY] Favorite Connections (v1.0, 2015-1-27)
    Reply With Quote #2

    Cool. However I'm sure Dr. Mckay would have been happy to add natives to his existing plugin had you requested them.
    https://forums.alliedmods.net/showthread.php?p=2060588

    Last edited by Sreaper; 01-27-2015 at 19:52.
    Sreaper is offline
    Nanochip
    Senior Member
    Join Date: Jan 2014
    Old 01-27-2015 , 19:56   Re: [ANY] Favorite Connections (v1.0, 2015-1-27)
    Reply With Quote #3

    Quote:
    Originally Posted by Sreaper View Post
    I'm sure Dr. Mckay would have been happy to add natives to his existing plugin had you requested them.
    https://forums.alliedmods.net/showthread.php?p=2060588
    Hi there, Sreaper,

    True, however, I think you might have dodged the fact that maybe a developer who only wants to detect when a player connects via favorites with no additional features is in need of something for the sake of simplicity.

    Best Regards,
    -Nano

    Last edited by Nanochip; 01-27-2015 at 19:59.
    Nanochip is offline
    Chdata
    Veteran Member
    Join Date: Aug 2012
    Location: Computer Chair, Illinois
    Old 01-28-2015 , 01:07   Re: [ANY] Favorite Connections (v1.0, 2015-1-27)
    Reply With Quote #4

    It's funny, I was just about to make something like this for myself

    [by ripping code from player_analytics]

    Except I haven't bothered much with making forwards/natives, so this is p c00l.

    Does this fire before/after OnClientPutInServer / OnClientPostAdminCheck?

    (Then again, I could always just set something like g_bFav[iClient] = false; on disconnect and only set it true in this forward).
    __________________

    Last edited by Chdata; 01-28-2015 at 01:09.
    Chdata is offline
    Nanochip
    Senior Member
    Join Date: Jan 2014
    Old 01-28-2015 , 01:38   Re: [ANY] Favorite Connections (v1.0, 2015-1-27)
    Reply With Quote #5

    Quote:
    Originally Posted by Chdata View Post
    It's funny, I was just about to make something like this for myself

    [by ripping code from player_analytics]

    Except I haven't bothered much with making forwards/natives, so this is p c00l.

    Does this fire before/after OnClientPutInServer / OnClientPostAdminCheck?

    (Then again, I could always just set something like g_bFav[iClient] = false; on disconnect and only set it true in this forward).
    Hi there, Chdata,

    Haha thanks! Yes, indeed, it does fire before OnClientPutInServer, as it uses the OnClientAuthorized forward.

    Best Regards,
    -Nano

    Last edited by Nanochip; 02-25-2015 at 12:41. Reason: Latest update uses OnClientPostAdminCheck.
    Nanochip is offline
    Wolvan
    Senior Member
    Join Date: Jul 2014
    Location: Tyrol, Austria
    Old 01-28-2015 , 08:45   Re: [ANY] Favorite Connections (v1.0, 2015-1-27)
    Reply With Quote #6

    If anyone requires a specific favorite connections extension, just go ahead and shoot me a message (or put it in here)

    Also, Chdata, if you need Nano and I could fire it multiple times (under different names) in different native forwards
    __________________
    Wolvan is offline
    Send a message via Skype™ to Wolvan
    Nanochip
    Senior Member
    Join Date: Jan 2014
    Old 02-07-2015 , 18:57   Re: [ANY] Favorite Connections (v1.1, 2015-2-7)
    Reply With Quote #7

    UPDATE: v1.1 (2015-2-7)
    • Optimized some code
    • Now uses OnClientPostAdminCheck to detect admin flags for client
    Nanochip is offline
    Chdata
    Veteran Member
    Join Date: Aug 2012
    Location: Computer Chair, Illinois
    Old 02-12-2017 , 07:00   Re: [ANY] Favorite Connections (v1.1, 2015-2-7)
    Reply With Quote #8

    PHP Code:
    /*
        IsConnectedViaFavorite(iClient, true);
        Must be called during OnClientPostAdminCheck()
        And also must be called on all clients in game during OnMapStart().
    */
    stock bool:IsConnectedViaFavorites(iClientbool:bForceRecalc false)
    {
        static 
    bool:bFavorite[MAXPLAYERS 1] = false;
        static 
    bool:bFound[MAXPLAYERS 1] = false;

        if (
    bForceRecalc)
        {
            
    bFound[iClient] = false;
            
    bFavorite[iClient] = false;
        }

        if (!
    bFound[iClient])
        {
            
    decl String:szConnectMethod[32];
            if (
    GetClientInfo(iClient"cl_connectmethod"szConnectMethodsizeof(szConnectMethod)))
            {
                
    bFavorite[iClient] = StrEqual(szConnectMethod"serverbrowser_favorites");
            }
            
    bFound[iClient] = true;
        }
        return 
    bFavorite[iClient];

    No plugin necessary ;p
    __________________

    Last edited by Chdata; 02-12-2017 at 07:24.
    Chdata is offline
    Nanochip
    Senior Member
    Join Date: Jan 2014
    Old 02-12-2017 , 12:58   Re: [ANY] Favorite Connections (v1.1, 2015-2-7)
    Reply With Quote #9

    bu-but, (insert my way is better than yours here).

    no point in defending my shitty first plugin lolxd ;-;
    __________________
    Nanochip 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 02:00.


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