2018-08-23 16:02:35 +02:00
|
|
|
#include <sourcemod>
|
|
|
|
#include <SteamWorks>
|
|
|
|
#include <connect>
|
|
|
|
|
|
|
|
#pragma semicolon 1
|
|
|
|
#pragma newdecls required
|
|
|
|
|
2018-08-24 12:55:00 +02:00
|
|
|
bool g_bHasFakeClient[MAXPLAYERS + 1] = {false,...};
|
2018-08-29 15:44:30 +02:00
|
|
|
int g_MaxPlayers = 64;
|
2018-08-23 16:02:35 +02:00
|
|
|
|
2018-08-29 15:59:53 +02:00
|
|
|
ConVar g_hCVar_FakeClients;
|
|
|
|
ConVar g_hCVar_SourceTV;
|
|
|
|
ConVar g_hCVar_MaxPlayers;
|
2018-08-29 14:38:31 +02:00
|
|
|
|
2018-08-25 17:29:39 +02:00
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
2018-08-23 16:02:35 +02:00
|
|
|
public Plugin myinfo =
|
|
|
|
{
|
|
|
|
name = "NoSteamPlayerCount",
|
|
|
|
author = "Neon",
|
|
|
|
description = "",
|
|
|
|
version = "1.0",
|
|
|
|
url = "https://steamcommunity.com/id/n3ontm"
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
public void OnGameFrame()
|
|
|
|
{
|
2018-08-29 15:44:30 +02:00
|
|
|
SteamWorks_SetMaxPlayers(g_MaxPlayers);
|
2018-08-23 16:02:35 +02:00
|
|
|
}
|
|
|
|
|
2018-08-24 12:55:00 +02:00
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
2018-08-23 16:02:35 +02:00
|
|
|
public void OnPluginStart()
|
|
|
|
{
|
2018-08-29 14:38:31 +02:00
|
|
|
g_hCVar_FakeClients = CreateConVar("sm_nosteamplayercount_fakeclients", "1", "Increse PlayerCount for Fake Clients", 0, true, 0.0, true, 1.0);
|
|
|
|
g_hCVar_SourceTV = CreateConVar("sm_nosteamplayercount_sourcetv", "1", "Increse PlayerCount for SourceTV", 0, true, 0.0, true, 1.0);
|
2018-08-29 15:44:30 +02:00
|
|
|
g_hCVar_MaxPlayers = CreateConVar("sm_nosteamplayercount_maxplayers", "64", "Max Players to display in the sv browser", 0, true, 1.0, true, 128.0);
|
2018-08-29 14:38:31 +02:00
|
|
|
|
2018-08-29 15:59:53 +02:00
|
|
|
g_hCVar_MaxPlayers.AddChangeHook(OnConVarChanged);
|
|
|
|
|
2018-08-29 14:38:31 +02:00
|
|
|
AutoExecConfig(true, "plugin.NoSteamPlayerCount");
|
|
|
|
|
2018-08-24 19:59:50 +02:00
|
|
|
RegAdminCmd("sm_addfake", Command_AddFake, ADMFLAG_ROOT, "");
|
|
|
|
RegAdminCmd("sm_removefake", Command_RemoveFake, ADMFLAG_ROOT, "");
|
|
|
|
RegAdminCmd("sm_countfakes", Command_CountFakes, ADMFLAG_BAN, "");
|
2018-08-23 17:34:48 +02:00
|
|
|
|
|
|
|
for(int client = 1; client <= MaxClients; client++)
|
|
|
|
{
|
2018-08-24 19:59:50 +02:00
|
|
|
if(IsValidClient(client) && IsClientAuthorized(client))
|
|
|
|
OnClientAuthorized(client, "");
|
2018-08-23 17:34:48 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-24 12:55:00 +02:00
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
2018-08-23 17:34:48 +02:00
|
|
|
public void OnPluginEnd()
|
|
|
|
{
|
|
|
|
for(int client = 1; client <= MaxClients; client++)
|
|
|
|
{
|
|
|
|
if(IsValidClient(client))
|
|
|
|
OnClientDisconnect(client);
|
|
|
|
}
|
2018-08-23 16:02:35 +02:00
|
|
|
}
|
|
|
|
|
2018-08-29 15:44:30 +02:00
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
public void OnConVarChanged(ConVar convar, const char[] oldValue, const char[] newValue)
|
|
|
|
{
|
|
|
|
if(convar == g_hCVar_MaxPlayers)
|
|
|
|
g_MaxPlayers = g_hCVar_MaxPlayers.IntValue;
|
|
|
|
}
|
|
|
|
|
2018-08-24 12:55:00 +02:00
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
2018-08-24 19:59:50 +02:00
|
|
|
public Action Command_AddFake(int client, int argc)
|
2018-08-23 16:02:35 +02:00
|
|
|
{
|
|
|
|
SteamWorks_CreateFake("Kaitou Sinbad");
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
|
|
|
|
2018-08-24 12:55:00 +02:00
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
2018-08-24 19:59:50 +02:00
|
|
|
public Action Command_RemoveFake(int client, int argc)
|
2018-08-23 16:02:35 +02:00
|
|
|
{
|
|
|
|
SteamWorks_KickFake();
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
|
|
|
|
2018-08-24 12:55:00 +02:00
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
2018-08-24 19:59:50 +02:00
|
|
|
public Action Command_CountFakes(int client, int argc)
|
2018-08-23 16:02:35 +02:00
|
|
|
{
|
|
|
|
int iFakes = SteamWorks_CountFakes();
|
|
|
|
ReplyToCommand(client, "There are currently %d Fake Clients active.", iFakes);
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
|
|
|
|
2018-08-24 12:55:00 +02:00
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
2018-08-23 17:34:48 +02:00
|
|
|
public void OnClientAuthorized(int client, const char[] auth)
|
2018-08-23 16:02:35 +02:00
|
|
|
{
|
2018-08-29 14:38:31 +02:00
|
|
|
if (IsClientSourceTV(client) && (!GetConVarBool(g_hCVar_SourceTV)))
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (IsFakeClient(client) && (!GetConVarBool(g_hCVar_FakeClients)))
|
|
|
|
return;
|
|
|
|
|
2018-08-23 16:02:35 +02:00
|
|
|
char sSteamID[32];
|
|
|
|
GetClientAuthId(client, AuthId_Steam2, sSteamID, sizeof(sSteamID));
|
2018-08-24 19:59:50 +02:00
|
|
|
|
2018-08-23 16:02:35 +02:00
|
|
|
char sName[128];
|
|
|
|
GetClientName(client, sName, sizeof(sName));
|
|
|
|
|
|
|
|
if(!SteamClientAuthenticated(sSteamID))
|
|
|
|
{
|
|
|
|
int iFakeID = SteamWorks_CreateFake(sName);
|
2018-08-24 12:55:00 +02:00
|
|
|
g_bHasFakeClient[client] = true;
|
2018-08-23 16:02:35 +02:00
|
|
|
LogMessage("\"%L\" connected as NoSteam. Fake Client with ID: \"%d\" got created.", client, iFakeID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2018-08-24 12:55:00 +02:00
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
2018-08-23 16:02:35 +02:00
|
|
|
public void OnClientDisconnect(int client)
|
|
|
|
{
|
2018-08-24 12:55:00 +02:00
|
|
|
if (!g_bHasFakeClient[client])
|
2018-08-23 16:02:35 +02:00
|
|
|
return;
|
|
|
|
|
2018-08-24 12:55:00 +02:00
|
|
|
SteamWorks_KickFake();
|
|
|
|
g_bHasFakeClient[client] = false;
|
|
|
|
LogMessage("\"%L\" left as NoSteam. Fake Client got removed.", client);
|
2018-08-23 17:34:48 +02:00
|
|
|
}
|
|
|
|
|
2018-08-24 12:55:00 +02:00
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
2018-08-23 17:34:48 +02:00
|
|
|
public bool IsValidClient(int client)
|
|
|
|
{
|
2018-08-24 19:59:50 +02:00
|
|
|
if (client <= 0)
|
|
|
|
return false;
|
2018-08-23 17:34:48 +02:00
|
|
|
|
2018-08-24 19:59:50 +02:00
|
|
|
if (client > GetMaxClients())
|
|
|
|
return false;
|
2018-08-23 17:34:48 +02:00
|
|
|
|
2018-08-24 19:59:50 +02:00
|
|
|
return true;
|
2018-08-23 16:02:35 +02:00
|
|
|
}
|