NoSteamPlayerCount: update

This commit is contained in:
neon 2018-08-24 12:55:00 +02:00
parent c85025e69d
commit 477b7cb010

View File

@ -5,7 +5,7 @@
#pragma semicolon 1 #pragma semicolon 1
#pragma newdecls required #pragma newdecls required
bool g_bConnected[MAXPLAYERS + 1] = {false,...}; bool g_bHasFakeClient[MAXPLAYERS + 1] = {false,...};
public Plugin myinfo = public Plugin myinfo =
{ {
@ -21,10 +21,12 @@ public Plugin myinfo =
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void OnGameFrame() public void OnGameFrame()
{ {
//SteamWorks_SetMapName("ze_FFVII_Mako_Reactor_v5_3");
SteamWorks_SetMaxPlayers(65); SteamWorks_SetMaxPlayers(65);
} }
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnPluginStart() public void OnPluginStart()
{ {
RegAdminCmd("sm_addfake", Command_addfake, ADMFLAG_ROOT, ""); RegAdminCmd("sm_addfake", Command_addfake, ADMFLAG_ROOT, "");
@ -38,6 +40,9 @@ public void OnPluginStart()
} }
} }
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnPluginEnd() public void OnPluginEnd()
{ {
for(int client = 1; client <= MaxClients; client++) for(int client = 1; client <= MaxClients; client++)
@ -47,18 +52,27 @@ public void OnPluginEnd()
} }
} }
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Command_addfake(int client, int argc) public Action Command_addfake(int client, int argc)
{ {
SteamWorks_CreateFake("Kaitou Sinbad"); SteamWorks_CreateFake("Kaitou Sinbad");
return Plugin_Handled; return Plugin_Handled;
} }
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Command_removefake(int client, int argc) public Action Command_removefake(int client, int argc)
{ {
SteamWorks_KickFake(); SteamWorks_KickFake();
return Plugin_Handled; return Plugin_Handled;
} }
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Command_countfakes(int client, int argc) public Action Command_countfakes(int client, int argc)
{ {
int iFakes = SteamWorks_CountFakes(); int iFakes = SteamWorks_CountFakes();
@ -66,6 +80,9 @@ public Action Command_countfakes(int client, int argc)
return Plugin_Handled; return Plugin_Handled;
} }
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClientAuthorized(int client, const char[] auth) public void OnClientAuthorized(int client, const char[] auth)
{ {
char sSteamID[32]; char sSteamID[32];
@ -76,27 +93,27 @@ public void OnClientAuthorized(int client, const char[] auth)
if(!SteamClientAuthenticated(sSteamID)) if(!SteamClientAuthenticated(sSteamID))
{ {
int iFakeID = SteamWorks_CreateFake(sName); 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); LogMessage("\"%L\" connected as NoSteam. Fake Client with ID: \"%d\" got created.", client, iFakeID);
} }
} }
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClientDisconnect(int client) public void OnClientDisconnect(int client)
{ {
if (!g_bConnected[client]) if (!g_bHasFakeClient[client])
return; return;
char sSteamID[32]; SteamWorks_KickFake();
GetClientAuthId(client, AuthId_Steam2, sSteamID, sizeof(sSteamID)); g_bHasFakeClient[client] = false;
LogMessage("\"%L\" left as NoSteam. Fake Client got removed.", client);
if(!SteamClientAuthenticated(sSteamID))
{
SteamWorks_KickFake();
g_bConnected[client] = false;
LogMessage("\"%L\" left as NoSteam. Fake Client got removed.", client);
}
} }
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public bool IsValidClient(int client) public bool IsValidClient(int client)
{ {
if (client <= 0) if (client <= 0)