This site is a testing version, but all data is shared with the live forum.


Raised This Month: $ Target: $400
 0% 

Plugin that checks steam profiles and warns/kicks private profile holders


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Obyboby
Veteran Member
Join Date: Sep 2013
Old 07-03-2017 , 16:33   Plugin that checks steam profiles and warns/kicks private profile holders
Reply With Quote #1

So in order to find smurfs/cheaters on our server, we ask players to keep their profile public while playing.
Is it easy to write a plugin that performs a check on users' Steam profiles, and if it finds a private profile, starts warning the user (via the in game chat) and after x amount of warnings, it kicks the client and displays a message about the rule (eg please make your profile public to play on our server)

Thanks for any help!
__________________
Obyboby is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 07-03-2017 , 17:03   Re: Plugin that checks steam profiles and warns/kicks private profile holders
Reply With Quote #2

Veterans Only claims to be able to do what you want, and a little bit more than that.. :-)
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
Obyboby
Veteran Member
Join Date: Sep 2013
Old 07-03-2017 , 17:03   Re: Plugin that checks steam profiles and warns/kicks private profile holders
Reply With Quote #3

Quote:
Originally Posted by arne1288 View Post
Veterans Only claims to be able to do what you want, and a little bit more than that.. :-)
Had totally missed that one!! Will look into it right now. Thank you sir!!
__________________
Obyboby is offline
WatchDogs
Senior Member
Join Date: Oct 2015
Location: Iran
Old 07-03-2017 , 17:57   Re: Plugin that checks steam profiles and warns/kicks private profile holders
Reply With Quote #4

Download The Latest Version From Here Please

Last edited by WatchDogs; 08-09-2017 at 07:37.
WatchDogs is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 07-03-2017 , 19:56   Re: Plugin that checks steam profiles and warns/kicks private profile holders
Reply With Quote #5

Quote:
Originally Posted by WatchDogs View Post
I picked up some of code from Veterans Only and made this:
  1. Do not do it in OnClientPutInServer, you will most likely never get a Steam ID in this place.
    Wait until OnClientAuthorized, or even better, OnClientPostAdminCheck, so you can check if the person is an admin or not, and that way ignore doing anything on admins.
  2. Use AuthId_Steam2, not AuthId_Engine. AuthId_Engine is not supported by that API end point.
  3. Always check the return value of GetClientAuthId, (it returns TRUE or FALSE), do not use it blindly:
    Bad Code

    Good Code
  4. Always check up with third parties, (e.g. if they have any terms of services / acceptable usage policies available) for their services, if they don't, ask them if you may use their API end points for things like this.
    There is also no guarantee that the end point used will be available next month, next year, or even the year after that.. So in theory, there are chances that your provided plugin will break too.


Quote:
Originally Posted by WatchDogs View Post
Not tested. Please test it and tell the result
Well, hope you're OK with feedback coming towards your code, even without testing it.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
B3none
AlliedModders Donor
Join Date: Oct 2016
Location: United Kingdom
Old 07-07-2017 , 09:09   Re: Plugin that checks steam profiles and warns/kicks private profile holders
Reply With Quote #6

Quote:
Originally Posted by WatchDogs View Post
Hi, You have good ideas in your mind totally

I picked up some of code from Veterans Only and made this:

PHP Code:
#pragma semicolon 1

#define PLUGIN_VERSION    "1.1.1"

#include <sourcemod>
#include <SteamWorks>

bool IsPrivate[MAXPLAYERS 1];
int iWarnings[MAXPLAYERS 1];

Handle h_bEnable;
Handle h_bKickFailed;
Handle h_iGameID;
Handle h_sURL;
Handle h_iWarnings;


public 
Plugin myinfo 
{
    
name "Private Kicker",
    
author "[W]atch [D]ogs, Soroush Falahati",
    
description "Kicks the players without public profile after X count of warnings",
    
version PLUGIN_VERSION,
    
url "http://www.falahati.net/"
}

public 
void OnPluginStart()
{
    
h_bEnable CreateConVar("sm_private_kick_enable""1""Enable / Disable the plugin"_true0.0true1.0);
    
h_iGameID CreateConVar("sm_private_kick_gameid""730""Steam's Store id of the game you want us to check against?");
    
h_bKickFailed CreateConVar("sm_private_kick_failed""0""Enable / Disable kicking client if didn't receive response"_true0.0true1.0);
    
h_sURL CreateConVar("sm_private_kick_url""http://falahati.net/steamapi/queryPlaytime.php""Address of the PHP file responsible for getting user profile status.");
    
h_iWarnings CreateConVar("sm_private_kick_warnings""5""How many warnings should plugin warn before kicking client"_true1.0);
    
    
HookEvent("player_spawn"Event_PlayerSpawn);
}

public 
Action Event_PlayerSpawn(Handle event, const char[] namebool dontBroadcast)
{
    
int client GetClientOfUserId(GetEventInt(event"userid"));
    if(
IsPrivate[client])
    {
        
PrintToChat(client"[SM] WARNING! Your steam profile is private. If you don't make it public before your next spawn you will get kicked.");
        
iWarnings[client]++;
        
        if(
iWarnings[client] >= GetConVarInt(h_iWarnings))
        {
            
KickClient(client"Kicked by server. Your steam profile is private Make it public and rejoin.");
        }
    }
}

public 
void OnClientDisconnect(int client)
{
    if(
GetConVarBool(h_bEnable) && !IsFakeClient(client) && IsPrivate[client])
    {
        
IsPrivate[client] = false;
        
iWarnings[client] = 0;
    }
}

public 
void OnClientPutInServer(int client)
{
    if(
GetConVarBool(h_bEnable) && !IsFakeClient(client))
    {
        
char sURL[256];
        
GetConVarString(h_sURLsURLsizeof(sURL));
        
        
char gameId[16];
        
IntToString(GetConVarInt(h_iGameID), gameIdsizeof(gameId));
        
        
char steamId[32];
        
GetClientAuthId(clientAuthId_EnginesteamIdsizeof(steamId));
        
        
Handle hRequest SteamWorks_CreateHTTPRequest(k_EHTTPMethodGETsURL);
        
SteamWorks_SetHTTPRequestNetworkActivityTimeout(hRequest10);
        
SteamWorks_SetHTTPRequestGetOrPostParameter(hRequest"gameId"gameId);
        
SteamWorks_SetHTTPRequestGetOrPostParameter(hRequest"steamId"steamId);
        
SteamWorks_SetHTTPCallbacks(hRequestHTTP_RequestComplete);
        
SteamWorks_SetHTTPRequestContextValue(hRequestclient);
        
SteamWorks_SendHTTPRequest(hRequest);
    }
}

public 
HTTP_RequestComplete(Handle HTTPRequestbool bFailurebool bRequestSuccessfulEHTTPStatusCode eStatusCodeint client)
{
    if(!
bRequestSuccessful || eStatusCode != k_EHTTPStatusCode200OK)
    {
        if(
bRequestSuccessful)
        {
            
CloseHandle(HTTPRequest);
        }
        if (
GetConVarBool(h_bKickFailed))
        {    
            
KickClient(client"Failed to retrieve profile status.");
        }
        
LogError("Private-Kicker: Failed to retrieve user's profile status (HTTP status: %d)"eStatusCode);
        return;
    }
    
    
int iBodySize;
    if (
SteamWorks_GetHTTPResponseBodySize(HTTPRequestiBodySize))
    {
        if (
iBodySize == 0)
        {
            
PrintToChat(client"[SM] WARNING! Your steam profile is private. If you don't make it public you will get kicked.");
            
IsPrivate[client] = true;
            
iWarnings[client] = 0;
        }
    }

Not tested. Please test it and tell the result


EDIT: 1.0.1 | Added a check for fail connections
EDIT: 1.1.1 | Fixed plugin (didn't work)
Hey, can you try and be consistent when you're naming variables please Makes the code much easier to read. In this case you've written one of your boolean variables as
PHP Code:
bool IsPrivate[MAXPLAYERS 1]; 
However if we were following the same variable naming scheme it would become
PHP Code:
bool b_IsPrivate[MAXPLAYERS 1]; 
Not trivial but variable naming consistency helps other people read your code. It'd be much worse if the code was huge but in this small case it doesn't matter too much.
__________________
B3none is offline
WatchDogs
Senior Member
Join Date: Oct 2015
Location: Iran
Old 07-04-2017 , 07:36   Re: Plugin that checks steam profiles and warns/kicks private profile holders
Reply With Quote #7

Download The Latest Version From Here Please

Last edited by WatchDogs; 08-09-2017 at 07:38.
WatchDogs is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 07-05-2017 , 03:36   Re: Plugin that checks steam profiles and warns/kicks private profile holders
Reply With Quote #8

Quote:
Originally Posted by WatchDogs View Post
Also I checked the license. It's GNU and you know it's free to edit and develop.
https://github.com/falahati/veterans#license
I have NEVER said you couldn't edit and re-develop on it?

The plugin is one thing, ... you can do whatever you want with it - that's correct!

However:

Quote:
Originally Posted by WatchDogs View Post
PHP Code:
public void OnPluginStart()
{
    
h_bEnable CreateConVar("sm_private_kick_enable""1""Enable / Disable the plugin"_true0.0true1.0);
    
h_iGameID CreateConVar("sm_private_kick_gameid""730""Steam's Store id of the game you want us to check against?");
    
h_bKickFailed CreateConVar("sm_private_kick_failed""0""Enable / Disable kicking client if didn't receive response"_true0.0true1.0);
    
h_sURL CreateConVar("sm_private_kick_url""http://falahati.net/steamapi/queryPlaytime.php""Address of the PHP file responsible for getting user profile status."); 

The "http://falahati.net/steamapi/queryPlaytime.php" thing is something else.

The GPL does not allow you to "spam away queries towards any site", nor does it disallow it either.

So if you don't have permission from the owner of falahati.net to use it, e.g. unless the owner of falahati.net said something like "Do whatever you want with it, just don't blame me for the results of your plugin", then you should either set up your own end point or find an alternative way of doing the public<->private profile check.
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
Obyboby
Veteran Member
Join Date: Sep 2013
Old 07-04-2017 , 14:43   Re: Plugin that checks steam profiles and warns/kicks private profile holders
Reply With Quote #9

Thank you so much for your prompt plugins WatchDogs, really appreciate it!
Will be testing this as soon as possible.
Thank you arne for your input as well.
__________________
Obyboby is offline
Obyboby
Veteran Member
Join Date: Sep 2013
Old 07-04-2017 , 16:46   Re: Plugin that checks steam profiles and warns/kicks private profile holders
Reply With Quote #10

Does it create a cfg file? Or should I be typing the settings inside another file?

EDIT: tried removing the admin immunity, then rejoining with my profile set to private..I didn't get any warnings :C a CFG file would be great (if possible, of course!)
thanks
__________________

Last edited by Obyboby; 07-04-2017 at 18:07.
Obyboby 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 13:04.


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