2018-08-23 16:02:35 +02:00
|
|
|
#include <sourcemod>
|
|
|
|
#include <SteamWorks>
|
|
|
|
#include <connect>
|
|
|
|
|
|
|
|
#pragma semicolon 1
|
|
|
|
#pragma newdecls required
|
|
|
|
|
|
|
|
bool g_bConnected[MAXPLAYERS + 1] = {false,...};
|
|
|
|
|
|
|
|
public Plugin myinfo =
|
|
|
|
{
|
|
|
|
name = "NoSteamPlayerCount",
|
|
|
|
author = "Neon",
|
|
|
|
description = "",
|
|
|
|
version = "1.0",
|
|
|
|
url = "https://steamcommunity.com/id/n3ontm"
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
public void OnGameFrame()
|
|
|
|
{
|
|
|
|
//SteamWorks_SetMapName("ze_FFVII_Mako_Reactor_v5_3");
|
|
|
|
SteamWorks_SetMaxPlayers(65);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnPluginStart()
|
|
|
|
{
|
|
|
|
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++)
|
|
|
|
{
|
|
|
|
if(IsValidClient(client))
|
|
|
|
OnClientAuthorized(client, "xxx");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnPluginEnd()
|
|
|
|
{
|
|
|
|
for(int client = 1; client <= MaxClients; client++)
|
|
|
|
{
|
|
|
|
if(IsValidClient(client))
|
|
|
|
OnClientDisconnect(client);
|
|
|
|
}
|
2018-08-23 16:02:35 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public Action Command_addfake(int client, int argc)
|
|
|
|
{
|
|
|
|
SteamWorks_CreateFake("Kaitou Sinbad");
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Action Command_removefake(int client, int argc)
|
|
|
|
{
|
|
|
|
SteamWorks_KickFake();
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Action Command_countfakes(int client, int argc)
|
|
|
|
{
|
|
|
|
int iFakes = SteamWorks_CountFakes();
|
|
|
|
ReplyToCommand(client, "There are currently %d Fake Clients active.", iFakes);
|
|
|
|
return Plugin_Handled;
|
|
|
|
}
|
|
|
|
|
2018-08-23 17:34:48 +02:00
|
|
|
public void OnClientAuthorized(int client, const char[] auth)
|
2018-08-23 16:02:35 +02:00
|
|
|
{
|
|
|
|
char sSteamID[32];
|
|
|
|
GetClientAuthId(client, AuthId_Steam2, sSteamID, sizeof(sSteamID));
|
|
|
|
char sName[128];
|
|
|
|
GetClientName(client, sName, sizeof(sName));
|
|
|
|
|
|
|
|
if(!SteamClientAuthenticated(sSteamID))
|
|
|
|
{
|
|
|
|
int iFakeID = SteamWorks_CreateFake(sName);
|
|
|
|
g_bConnected[client] = true;
|
|
|
|
LogMessage("\"%L\" connected as NoSteam. Fake Client with ID: \"%d\" got created.", client, iFakeID);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnClientDisconnect(int client)
|
|
|
|
{
|
|
|
|
if (!g_bConnected[client])
|
|
|
|
return;
|
|
|
|
|
|
|
|
char sSteamID[32];
|
|
|
|
GetClientAuthId(client, AuthId_Steam2, sSteamID, sizeof(sSteamID));
|
|
|
|
|
|
|
|
if(!SteamClientAuthenticated(sSteamID))
|
|
|
|
{
|
|
|
|
SteamWorks_KickFake();
|
|
|
|
g_bConnected[client] = false;
|
2018-08-23 17:34:48 +02:00
|
|
|
LogMessage("\"%L\" left as NoSteam. Fake Client got removed.", client);
|
2018-08-23 16:02:35 +02:00
|
|
|
}
|
2018-08-23 17:34:48 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
public bool IsValidClient(int client)
|
|
|
|
{
|
|
|
|
if (client <= 0)
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (client > GetMaxClients())
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!IsClientInGame(client))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
if (!IsClientAuthorized(client))
|
|
|
|
return false;
|
|
|
|
|
|
|
|
return true;
|
2018-08-23 16:02:35 +02:00
|
|
|
}
|