Thread: [Solved] Save user for x time
View Single Post
azalty
AlliedModders Donor
Join Date: Feb 2020
Location: France
Old 06-12-2022 , 05:19   Re: Save user for x time
Reply With Quote #6

Sorry, g_bChecked was a leftover

Code:
#include <sourcemod>
#include <cstrike>

ArrayList g_hConnectHistoryList;
char g_sBuffer[32];
bool g_bShouldRespawn[MAXPLAYERS + 1];

public void OnPluginStart()
{
	g_hConnectHistoryList = new ArrayList(ByteCountToCells(32)); // Let's use a size of 32 for SteamIDs
}

void RespawnPlayer(int client)
{
	// Write your code here to respawn the player, ex:
	CS_RespawnPlayer(client);
}

public void OnMapStart()
{
	g_hConnectHistoryList.Clear();
}

public void OnClientDisconnect(int client)
{
	g_bShouldRespawn[client] = false;
}

public void OnClientAuthorized(int client, const char[] auth)
{	
	if (g_hConnectHistoryList.FindString(auth) == -1)
	{
		if (!IsClientInGame(client))
		{
			g_bShouldRespawn[client] = true;
			return;
		}
		g_hConnectHistoryList.PushString(auth);
		
		RespawnPlayer(client);
	}
}

public void OnClientPutInServer(int client)
{
	if (!g_bShouldRespawn[client])
		return;
	GetClientAuthId(client, AuthId_Steam2, g_sBuffer, sizeof(g_sBuffer));
	g_hConnectHistoryList.PushString(g_sBuffer);
	
	RespawnPlayer(client);
}
__________________
GitHub | Discord: @azalty | Steam
azalty is offline