2018-07-23 10:49:15 +02:00
|
|
|
#pragma semicolon 1
|
|
|
|
|
|
|
|
#include <sourcemod>
|
|
|
|
|
|
|
|
#include "loghelper.inc"
|
|
|
|
|
|
|
|
#pragma newdecls required
|
|
|
|
|
|
|
|
int g_iClientConnectionTime[MAXPLAYERS + 1];
|
|
|
|
|
|
|
|
public Plugin myinfo =
|
|
|
|
{
|
2018-12-16 01:58:41 +01:00
|
|
|
name = "PlaytimeReward",
|
|
|
|
author = "Obus + Dogan",
|
|
|
|
description = "reward players with points for playing on the server",
|
|
|
|
version = "1.0.0"
|
2018-07-23 10:49:15 +02:00
|
|
|
};
|
|
|
|
|
|
|
|
public void OnPluginStart()
|
|
|
|
{
|
|
|
|
CreateTimer(30.0, Timer_CheckConnectionTime, _, TIMER_REPEAT);
|
|
|
|
|
|
|
|
HookEvent("player_disconnect", EventHook_PlayerDisconnect, EventHookMode_Post);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnPluginEnd()
|
|
|
|
{
|
|
|
|
UnhookEvent("player_disconnect", EventHook_PlayerDisconnect, EventHookMode_Post);
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnMapStart()
|
|
|
|
{
|
|
|
|
GetTeams();
|
|
|
|
}
|
|
|
|
|
|
|
|
public void EventHook_PlayerDisconnect(Event hEvent, const char[] sName, bool bDontBroadcast)
|
|
|
|
{
|
|
|
|
bool bIsBot = view_as<bool>(hEvent.GetInt("bot"));
|
|
|
|
|
|
|
|
if (bIsBot)
|
|
|
|
return;
|
|
|
|
|
|
|
|
int client = GetClientOfUserId(hEvent.GetInt("userid"));
|
|
|
|
|
|
|
|
g_iClientConnectionTime[client] = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
public Action Timer_CheckConnectionTime(Handle hThis)
|
|
|
|
{
|
|
|
|
for (int i = 1; i <= MaxClients; i++)
|
|
|
|
{
|
|
|
|
if (!IsValidClient(i))
|
2018-12-16 01:59:26 +01:00
|
|
|
continue;
|
2018-07-23 10:49:15 +02:00
|
|
|
|
2018-12-16 01:58:41 +01:00
|
|
|
g_iClientConnectionTime[i] += 30;
|
|
|
|
|
2018-12-16 02:37:12 +01:00
|
|
|
if (g_iClientConnectionTime[i] > 36000 && g_iClientConnectionTime[i] <= 36030)
|
2018-12-16 01:58:41 +01:00
|
|
|
{
|
|
|
|
LogPlayerEvent(i, "triggered", "staying_server_600");
|
|
|
|
g_iClientConnectionTime[i] = 0; //start over, but i doubt someone will ever reach so far ;)
|
|
|
|
}
|
2018-12-16 02:37:12 +01:00
|
|
|
else if (g_iClientConnectionTime[i] > 34200 && g_iClientConnectionTime[i] <= 34230)
|
2018-12-16 01:58:41 +01:00
|
|
|
{
|
|
|
|
LogPlayerEvent(i, "triggered", "staying_server_570");
|
|
|
|
}
|
2018-12-16 02:37:12 +01:00
|
|
|
else if (g_iClientConnectionTime[i] > 32400 && g_iClientConnectionTime[i] <= 32430)
|
2018-12-16 01:58:41 +01:00
|
|
|
{
|
|
|
|
LogPlayerEvent(i, "triggered", "staying_server_540");
|
|
|
|
}
|
2018-12-16 02:37:12 +01:00
|
|
|
else if (g_iClientConnectionTime[i] > 30600 && g_iClientConnectionTime[i] <= 30630)
|
2018-12-16 01:58:41 +01:00
|
|
|
{
|
|
|
|
LogPlayerEvent(i, "triggered", "staying_server_510");
|
|
|
|
}
|
2018-12-16 02:37:12 +01:00
|
|
|
else if (g_iClientConnectionTime[i] > 28800 && g_iClientConnectionTime[i] <= 28830)
|
2018-12-16 01:58:41 +01:00
|
|
|
{
|
|
|
|
LogPlayerEvent(i, "triggered", "staying_server_480");
|
|
|
|
}
|
2018-12-16 02:37:12 +01:00
|
|
|
else if (g_iClientConnectionTime[i] > 27000 && g_iClientConnectionTime[i] <= 27030)
|
2018-12-16 01:58:41 +01:00
|
|
|
{
|
|
|
|
LogPlayerEvent(i, "triggered", "staying_server_450");
|
|
|
|
}
|
2018-12-16 02:37:12 +01:00
|
|
|
else if (g_iClientConnectionTime[i] > 25200 && g_iClientConnectionTime[i] <= 25230)
|
2018-12-16 01:58:41 +01:00
|
|
|
{
|
|
|
|
LogPlayerEvent(i, "triggered", "staying_server_420");
|
|
|
|
}
|
2018-12-16 02:37:12 +01:00
|
|
|
else if (g_iClientConnectionTime[i] > 23400 && g_iClientConnectionTime[i] <= 23430)
|
2018-12-16 01:58:41 +01:00
|
|
|
{
|
|
|
|
LogPlayerEvent(i, "triggered", "staying_server_390");
|
|
|
|
}
|
2018-12-16 02:37:12 +01:00
|
|
|
else if (g_iClientConnectionTime[i] > 21600 && g_iClientConnectionTime[i] <= 21630)
|
2018-12-16 01:58:41 +01:00
|
|
|
{
|
|
|
|
LogPlayerEvent(i, "triggered", "staying_server_360");
|
|
|
|
}
|
2018-12-16 02:37:12 +01:00
|
|
|
else if (g_iClientConnectionTime[i] > 19800 && g_iClientConnectionTime[i] <= 19830)
|
2018-12-16 01:58:41 +01:00
|
|
|
{
|
|
|
|
LogPlayerEvent(i, "triggered", "staying_server_330");
|
|
|
|
}
|
2018-12-16 02:37:12 +01:00
|
|
|
else if (g_iClientConnectionTime[i] > 18000 && g_iClientConnectionTime[i] <= 18030)
|
2018-12-16 01:58:41 +01:00
|
|
|
{
|
|
|
|
LogPlayerEvent(i, "triggered", "staying_server_300");
|
|
|
|
}
|
2018-12-16 02:37:12 +01:00
|
|
|
else if (g_iClientConnectionTime[i] > 16200 && g_iClientConnectionTime[i] <= 16230)
|
2018-12-16 01:58:41 +01:00
|
|
|
{
|
|
|
|
LogPlayerEvent(i, "triggered", "staying_server_270");
|
|
|
|
}
|
2018-12-16 02:37:12 +01:00
|
|
|
else if (g_iClientConnectionTime[i] > 14400 && g_iClientConnectionTime[i] <= 14430)
|
2018-12-16 01:58:41 +01:00
|
|
|
{
|
|
|
|
LogPlayerEvent(i, "triggered", "staying_server_240");
|
|
|
|
}
|
2018-12-16 02:37:12 +01:00
|
|
|
else if (g_iClientConnectionTime[i] > 12600 && g_iClientConnectionTime[i] <= 12630)
|
2018-12-16 01:58:41 +01:00
|
|
|
{
|
|
|
|
LogPlayerEvent(i, "triggered", "staying_server_210");
|
|
|
|
}
|
2018-12-16 02:37:12 +01:00
|
|
|
else if (g_iClientConnectionTime[i] > 10800 && g_iClientConnectionTime[i] <= 10830)
|
2018-12-16 01:58:41 +01:00
|
|
|
{
|
|
|
|
LogPlayerEvent(i, "triggered", "staying_server_180");
|
|
|
|
}
|
2018-12-16 02:37:12 +01:00
|
|
|
else if (g_iClientConnectionTime[i] > 9000 && g_iClientConnectionTime[i] <= 99030)
|
2018-12-16 01:58:41 +01:00
|
|
|
{
|
|
|
|
LogPlayerEvent(i, "triggered", "staying_server_150");
|
|
|
|
}
|
2018-12-16 02:37:12 +01:00
|
|
|
else if (g_iClientConnectionTime[i] > 7200 && g_iClientConnectionTime[i] <= 7230)
|
2018-12-16 01:58:41 +01:00
|
|
|
{
|
|
|
|
LogPlayerEvent(i, "triggered", "staying_server_120");
|
|
|
|
}
|
2018-12-16 02:37:12 +01:00
|
|
|
else if (g_iClientConnectionTime[i] > 5400 && g_iClientConnectionTime[i] <= 5430)
|
2018-12-16 01:58:41 +01:00
|
|
|
{
|
|
|
|
LogPlayerEvent(i, "triggered", "staying_server_90");
|
|
|
|
}
|
2018-12-16 02:37:12 +01:00
|
|
|
else if (g_iClientConnectionTime[i] > 3600 && g_iClientConnectionTime[i] <= 3630)
|
2018-12-16 01:58:41 +01:00
|
|
|
{
|
|
|
|
LogPlayerEvent(i, "triggered", "staying_server_60");
|
|
|
|
}
|
2018-12-16 02:37:12 +01:00
|
|
|
else if (g_iClientConnectionTime[i] > 1800 && g_iClientConnectionTime[i] <= 1830)
|
2018-07-23 10:49:15 +02:00
|
|
|
{
|
2018-12-16 01:58:41 +01:00
|
|
|
LogPlayerEvent(i, "triggered", "staying_server_30");
|
2018-07-23 10:49:15 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
stock bool IsValidClient(int client)
|
|
|
|
{
|
|
|
|
return (client >= 1 && client <= MaxClients && IsClientInGame(client) && !IsFakeClient(client));
|
|
|
|
}
|