AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Plugins (https://forums.alliedmods.net/forumdisplay.php?f=108)
-   -   [ANY] Simple Mysql Whitelist (https://forums.alliedmods.net/showthread.php?t=286965)

xines 08-28-2016 15:18

[ANY] Simple Mysql Whitelist
 
1 Attachment(s)
Simple Mysql Whitelist
Mysql database whitelister to control player access to server[s].

Currently Tested [CSS][CS:GO]


Description:
Spoiler


Requirements:
  • A mysql database (obviously)

Ingame Commands:
  • All Ingame commands including menu requires Admin-Root access.
  • sm_whitelist Opens the menu to list/remove
  • sm_whitelist_add Add a steamid to the database.
  • sm_whitelist_delete Deletes a steamid from the database.
  • sm_whitelist_list List all SteamIDs in the database.

Server Commands:
  • sm_server_whitelist_add Add a steamid to the database. Useable by Rcon or Console
  • sm_server_whitelist_delete Deletes a steamid from the database. Useable by Rcon or Console

Cvars:
  • sm_whitelist_adminflag "0" Admin flag required [a -> z] [0 = OFF].

Installation:
Spoiler


Changelog:
Code:

1.0 - Plugin release
1.1 - Added flags support and minor code edits.
1.2 - Added bots to be allowed!
1.3 - New method for faster player kick.
1.4 - Threaded queries been updated for safer use.
1.5 - Added ServerCommands, Optimized mysql and fixed reported bugs.


Addicted. 08-28-2016 16:02

Re: [ANY] Simple Mysql Whitelist
 
Nice plugin. Can confirm this works on CS:GO.

sneaK 08-28-2016 16:48

Re: [ANY] Simple Mysql Whitelist
 
Very nice!

Feature request: Can you add flag support? For example, I would like everyone in the MySQL database to be able to connect to the server, but also users with the A flag.

xines 08-28-2016 17:10

Re: [ANY] Simple Mysql Whitelist
 
Quote:

Originally Posted by oaaron99 (Post 2449080)
Nice plugin. Can confirm this works on CS:GO.

Thank you, good to know added to tested list! :up:

Quote:

Originally Posted by blackhawk74 (Post 2449093)
Very nice!

Feature request: Can you add flag support? For example, I would like everyone in the MySQL database to be able to connect to the server, but also users with the A flag.

Thank you :up:
By default everyone is not allowed to get into the server, that's why you whitelist them in.

Flags can be added, tho it will require me to take down function OnClientAuthorized and replace with OnClientPostAdminCheck, this will slow down the auto kick speed when not allowed into the server.
Done :wink:

Addicted. 08-28-2016 19:42

Re: [ANY] Simple Mysql Whitelist
 
Quote:

Originally Posted by xines (Post 2449101)
Flags can be added, tho it will require me to take down function OnClientAuthorized and replace with OnClientPostAdminCheck, this will slow down the auto kick speed when not allowed into the server.

Well you can make it so that if a flag is set then it will use OnClientPostAdminCheck and if not, use OnClientAuthorized

Potato Uno 08-28-2016 20:02

Re: [ANY] Simple Mysql Whitelist
 
IIRC doing it beyond OnClientAuthorized will kick the client AFTER they have downloaded the map, if any.

If you want to kick them before they download the map, use OnClientAuthorized. There is also a way to get admin flags from a plain steam ID (forgot how).

xines 08-29-2016 09:05

Re: [ANY] Simple Mysql Whitelist
 
Quote:

Originally Posted by oaaron99 (Post 2449126)
Well you can make it so that if a flag is set then it will use OnClientPostAdminCheck and if not, use OnClientAuthorized

Yeah very possible with a global variable, but it's no big deal as the client never gets into the server before OnClientPostAdminCheck have been fired :P.

Quote:

Originally Posted by Potato Uno (Post 2449130)
IIRC doing it beyond OnClientAuthorized will kick the client AFTER they have downloaded the map, if any.

If you want to kick them before they download the map, use OnClientAuthorized. There is also a way to get admin flags from a plain steam ID (forgot how).

Yes sounds about right, however, the SteamID would require i think GetUserFlagBits function, and there's been more than enough information about why not to use this, so for now OnClientPostAdminCheck is the right option to choose.

Potato Uno 08-30-2016 23:30

Re: [ANY] Simple Mysql Whitelist
 
I found the relevant code. Feel free to use it if you want:

PHP Code:

public void OnClientAuthorized(int iClient, const char[] SteamID)
{
    
AdminId Admin FindAdminByIdentity(AUTHMETHOD_STEAMSteamID);
    if (!
GetAdminFlag(AdminAdmin_Custom1)) // change flag to whatever
        
KickClient(iClient"reason here");



xines 08-31-2016 09:51

Re: [ANY] Simple Mysql Whitelist
 
Quote:

Originally Posted by Potato Uno (Post 2449739)
I found the relevant code. Feel free to use it if you want:

PHP Code:

public void OnClientAuthorized(int iClient, const char[] SteamID)
{
    
AdminId Admin FindAdminByIdentity(AUTHMETHOD_STEAMSteamID);
    if (!
GetAdminFlag(AdminAdmin_Custom1)) // change flag to whatever
        
KickClient(iClient"reason here");



Looks good, however, i'm unsure of this method due to asherkins answer here: https://forums.alliedmods.net/showthread.php?t=97165 I would need his opinion about this :shock:.

Potato Uno 08-31-2016 10:14

Re: [ANY] Simple Mysql Whitelist
 
Asherkin uses it himself in his connect extension's plugin.

You can still bolt a second check in postadmin to be super safe.

I use that code to prevent non-admins from getting into a server and it never failed me.


All times are GMT -4. The time now is 16:03.

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