I was bored so here is an example for you. In theory this should work but it is untested.
This adds a 5min timer against someones steamid when they disconnect and if they reconnect while timer is still going it will stop. If the timer fires it will ban them then insert/update a row in a table which has columns steamid and ban_expiry. On your website you can check if their steamid exists in this table, and see if their ban_expiry has been reached yet.
PHP Code:
#include <sourcemod>
StringMap g_hTimers = new StringMap();
Database g_hDatabase;
public void OnPluginStart() {
static char szError[512];
g_hDatabase = SQL_Connect("db_name", false, szError, sizeof(szError));
if (g_hDatabase == INVALID_HANDLE) SetFailState(szError);
}
public void OnClientAuthorized(int iClient, char[] szSteamID) {
Handle hTimer;
if (g_hTimers.GetValue(szSteamID, hTimer)) {
KillTimer(hTimer);
g_hTimers.Remove(szSteamID);
}
}
public void OnClientDisconnect(int iClient) {
static char szSteamID[32];
if (GetClientAuthId(iClient, AuthId_Steam2, szSteamID, sizeof(szSteamID))) {
DataPack hPack = new DataPack();
hPack.WriteString(szSteamID);
Handle hTimer = CreateTimer(300.0, Timer_Ban, hPack, TIMER_HNDL_CLOSE);
g_hTimers.SetValue(szSteamID, hTimer);
}
}
public Action Timer_Ban(Handle hTimer, DataPack hPack) {
static char szSteamID[32];
static char szQuery[512];
int iBanExpiry = GetTime() + (69*60);
hPack.Reset()
hPack.ReadString(szSteamID, sizeof(szSteamID));
g_hTimers.Remove(szSteamID);
BanIdentity(szSteamID, 69, BANFLAG_AUTHID, "You were banned for being naughty", "automatic_timer_ban", 0);
g_hDatabase.Format(szQuery, sizeof(szQuery), "INSERT INTO `table_name` (`steamid`, `ban_expiry`) VALUES (\'%s\', %i) ON DUPLICATE KEY UPDATE `ban_expiry` = %i", szSteamID, iBanExpiry, iBanExpiry);
g_hDatabase.Query(QueryCallback_InsertBan, szQuery);
return Plugin_Handled;
}
public void QueryCallback_InsertBan(Database hDatabase, DBResultSet hResults, const char[] szError, any data) {
delete hDatabase; // this is a cloned Handle of g_hDatabase
if (strlen(szError) > 0) PrintToServer("Failed to insert ban");
}