From 21ad061055e13738b42d3066f688f8d226b55ff0 Mon Sep 17 00:00:00 2001 From: zaCade Date: Sat, 27 Jul 2019 19:18:50 +0200 Subject: [PATCH] PlaytimeReward: Hopefully make the reset work this time? --- PlaytimeReward/scripting/PlaytimeReward.sp | 41 +++++----------------- 1 file changed, 9 insertions(+), 32 deletions(-) diff --git a/PlaytimeReward/scripting/PlaytimeReward.sp b/PlaytimeReward/scripting/PlaytimeReward.sp index 9251ef7d..3e660eb4 100644 --- a/PlaytimeReward/scripting/PlaytimeReward.sp +++ b/PlaytimeReward/scripting/PlaytimeReward.sp @@ -5,6 +5,7 @@ #pragma newdecls required +int g_iClientSteamAccountID[MAXPLAYERS + 1]; int g_iClientConnectionTime[MAXPLAYERS + 1]; public Plugin myinfo = @@ -18,38 +19,6 @@ public Plugin myinfo = public void OnPluginStart() { CreateTimer(30.0, Timer_CheckConnectionTime, _, TIMER_REPEAT); - - HookEvent("player_disconnect", EventHook_PlayerDisconnect, EventHookMode_Post); - HookEvent("player_connect", EventHook_PlayerConnect, EventHookMode_Post); -} - -public void OnPluginEnd() -{ - UnhookEvent("player_disconnect", EventHook_PlayerDisconnect, EventHookMode_Post); -} - -public void EventHook_PlayerDisconnect(Event hEvent, const char[] sName, bool bDontBroadcast) -{ - bool bIsBot = view_as(hEvent.GetInt("bot")); - - if (bIsBot) - return; - - int client = GetClientOfUserId(hEvent.GetInt("userid")); - - g_iClientConnectionTime[client] = 0; -} - -public void EventHook_PlayerConnect(Event hEvent, const char[] sName, bool bDontBroadcast) -{ - bool bIsBot = view_as(hEvent.GetInt("bot")); - - if (bIsBot) - return; - - int client = GetClientOfUserId(hEvent.GetInt("userid")); - - g_iClientConnectionTime[client] = 0; } public Action Timer_CheckConnectionTime(Handle hThis) @@ -59,6 +28,14 @@ public Action Timer_CheckConnectionTime(Handle hThis) if (!IsValidClient(i)) continue; + int iSteamAccountID = GetSteamAccountID(i); + + if (g_iClientSteamAccountID[i] != iSteamAccountID) + { + g_iClientSteamAccountID[i] = iSteamAccountID; + g_iClientConnectionTime[i] = 0; + } + g_iClientConnectionTime[i] += 30; for (int iTime = 1800; iTime <= 36000; iTime += 1800)