From 477b7cb010f0635372b54e66d9ab8a136685ad3c Mon Sep 17 00:00:00 2001 From: neon <> Date: Fri, 24 Aug 2018 12:55:00 +0200 Subject: [PATCH] NoSteamPlayerCount: update --- .../scripting/NoSteamPlayerCount.sp | 43 +++++++++++++------ 1 file changed, 30 insertions(+), 13 deletions(-) diff --git a/NoSteamPlayerCount/scripting/NoSteamPlayerCount.sp b/NoSteamPlayerCount/scripting/NoSteamPlayerCount.sp index 6ef08ddc..4e0113fc 100644 --- a/NoSteamPlayerCount/scripting/NoSteamPlayerCount.sp +++ b/NoSteamPlayerCount/scripting/NoSteamPlayerCount.sp @@ -5,7 +5,7 @@ #pragma semicolon 1 #pragma newdecls required -bool g_bConnected[MAXPLAYERS + 1] = {false,...}; +bool g_bHasFakeClient[MAXPLAYERS + 1] = {false,...}; public Plugin myinfo = { @@ -21,10 +21,12 @@ public Plugin myinfo = //---------------------------------------------------------------------------------------------------- public void OnGameFrame() { - //SteamWorks_SetMapName("ze_FFVII_Mako_Reactor_v5_3"); SteamWorks_SetMaxPlayers(65); } +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- public void OnPluginStart() { RegAdminCmd("sm_addfake", Command_addfake, ADMFLAG_ROOT, ""); @@ -38,6 +40,9 @@ public void OnPluginStart() } } +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- public void OnPluginEnd() { for(int client = 1; client <= MaxClients; client++) @@ -47,18 +52,27 @@ public void OnPluginEnd() } } +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- public Action Command_addfake(int client, int argc) { SteamWorks_CreateFake("Kaitou Sinbad"); return Plugin_Handled; } +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- public Action Command_removefake(int client, int argc) { SteamWorks_KickFake(); return Plugin_Handled; } +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- public Action Command_countfakes(int client, int argc) { int iFakes = SteamWorks_CountFakes(); @@ -66,6 +80,9 @@ public Action Command_countfakes(int client, int argc) return Plugin_Handled; } +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- public void OnClientAuthorized(int client, const char[] auth) { char sSteamID[32]; @@ -76,27 +93,27 @@ public void OnClientAuthorized(int client, const char[] auth) if(!SteamClientAuthenticated(sSteamID)) { int iFakeID = SteamWorks_CreateFake(sName); - g_bConnected[client] = true; + g_bHasFakeClient[client] = true; LogMessage("\"%L\" connected as NoSteam. Fake Client with ID: \"%d\" got created.", client, iFakeID); } } +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- public void OnClientDisconnect(int client) { - if (!g_bConnected[client]) + if (!g_bHasFakeClient[client]) return; - char sSteamID[32]; - GetClientAuthId(client, AuthId_Steam2, sSteamID, sizeof(sSteamID)); - - if(!SteamClientAuthenticated(sSteamID)) - { - SteamWorks_KickFake(); - g_bConnected[client] = false; - LogMessage("\"%L\" left as NoSteam. Fake Client got removed.", client); - } + SteamWorks_KickFake(); + g_bHasFakeClient[client] = false; + LogMessage("\"%L\" left as NoSteam. Fake Client got removed.", client); } +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- public bool IsValidClient(int client) { if (client <= 0)