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", _, true, 0.0, true, 1.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", _, true, 0.0, true, 1.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", _, true, 1.0);
HookEvent("player_spawn", Event_PlayerSpawn);
}
public Action Event_PlayerSpawn(Handle event, const char[] name, bool 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_sURL, sURL, sizeof(sURL));
char gameId[16];
IntToString(GetConVarInt(h_iGameID), gameId, sizeof(gameId));
char steamId[32];
GetClientAuthId(client, AuthId_Engine, steamId, sizeof(steamId));
Handle hRequest = SteamWorks_CreateHTTPRequest(k_EHTTPMethodGET, sURL);
SteamWorks_SetHTTPRequestNetworkActivityTimeout(hRequest, 10);
SteamWorks_SetHTTPRequestGetOrPostParameter(hRequest, "gameId", gameId);
SteamWorks_SetHTTPRequestGetOrPostParameter(hRequest, "steamId", steamId);
SteamWorks_SetHTTPCallbacks(hRequest, HTTP_RequestComplete);
SteamWorks_SetHTTPRequestContextValue(hRequest, client);
SteamWorks_SendHTTPRequest(hRequest);
}
}
public HTTP_RequestComplete(Handle HTTPRequest, bool bFailure, bool bRequestSuccessful, EHTTPStatusCode eStatusCode, int 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(HTTPRequest, iBodySize))
{
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