diff --git a/PlaytimeReward/scripting/PlaytimeReward.sp b/PlaytimeReward/scripting/PlaytimeReward.sp index 2b88fd9a..bcd4b294 100644 --- a/PlaytimeReward/scripting/PlaytimeReward.sp +++ b/PlaytimeReward/scripting/PlaytimeReward.sp @@ -21,11 +21,13 @@ 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); + UnhookEvent("player_connect", EventHook_PlayerConnect, EventHookMode_Post); } public void OnMapStart() @@ -45,6 +47,18 @@ public void EventHook_PlayerDisconnect(Event hEvent, const char[] sName, bool bD 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) { for (int i = 1; i <= MaxClients; i++)