diff --git a/Discord_UNLOZE/scripting/Discord_UNLOZE.sp b/Discord_UNLOZE/scripting/Discord_UNLOZE.sp index 08c8073..6dc33f0 100644 --- a/Discord_UNLOZE/scripting/Discord_UNLOZE.sp +++ b/Discord_UNLOZE/scripting/Discord_UNLOZE.sp @@ -774,7 +774,7 @@ public void CallAdmin_OnReportHandled(int client, int id) else Discord_POST(DISCORD_CALLADMIN_WEBHOOKURL, sMessage, true, sUsername, false, "", false); } -//' +// /* public Action Oryx_OnTrigger(int client, int &level, char[] cheat) { @@ -823,7 +823,7 @@ public void AntiBhopCheat_OnClientDetected(int client, char[] sReason, char[] sS Discord_POST(DISCORD_ANTIBHOPCHEAT_WEBHOOKURL, sMessage, true, sUsername, false, "", false); } -public void EW_OnClientRestricted(int client, int target, int length) +public void EW_OnClientRestricted(int client, int target, int hours, int minutes) { char sCurrentMap[64]; GetCurrentMap(sCurrentMap, sizeof(sCurrentMap)); @@ -835,12 +835,12 @@ public void EW_OnClientRestricted(int client, int target, int length) Format(sDemoInfo, sizeof(sDemoInfo), "Not recording"); char sMessageTemp[1280]; // 128 x 10 - if (length == -1) + if (hours == -1) Format(sMessageTemp, sizeof(sMessageTemp), "%L got temporarily restricted by %L", target, client); - else if (length == 0) + else if (hours == 0 && minutes == 0) Format(sMessageTemp, sizeof(sMessageTemp), "%L got permanently restricted by %L", target, client); else - Format(sMessageTemp, sizeof(sMessageTemp), "%L got restricted by %L for %d Hours playtime", target, client, length); + Format(sMessageTemp, sizeof(sMessageTemp), "%L got restricted by %L for %d Hours and %d minutes playtime", target, client, hours, minutes); char sMessage[1920]; // 128 x 15 Format(sMessage, sizeof(sMessage), "[ %s ][ %s ]```%s```", sCurrentMap, sDemoInfo, sMessageTemp); diff --git a/KnifeBan/scripting/KnifeBan_playtime.sp b/KnifeBan/scripting/KnifeBan_playtime.sp index 1bcde53..586e205 100644 --- a/KnifeBan/scripting/KnifeBan_playtime.sp +++ b/KnifeBan/scripting/KnifeBan_playtime.sp @@ -21,6 +21,7 @@ KeyValues Banlist; int g_hActiveWeapon; int g_iClientHours[MAXPLAYERS + 1]; +int g_iClientMinutes[MAXPLAYERS + 1]; public Plugin myinfo = { @@ -99,6 +100,8 @@ public void OnClientPostAdminCheck(int client) } g_iClientHours[client] = 0; + g_iClientMinutes[client] = 0; + char sAuth[32]; GetClientAuthId(client, AuthId_Steam2, sAuth, sizeof(sAuth)); @@ -107,12 +110,14 @@ public void OnClientPostAdminCheck(int client) if(Banlist.JumpToKey(sAuth)) { int length = Banlist.GetNum("duration"); + int length_minutes = Banlist.GetNum("duration_minutes"); int time = Banlist.GetNum("time"); + int time_minutes = Banlist.GetNum("time_minutes", 0); if(length == -1) g_bKnifeBanned[client] = true; else if(length > 0) - CheckIfClientIsStillKnifeBanned(sAuth, client, time, length); + CheckIfClientIsStillKnifeBanned(sAuth, client, time, time_minutes, length, length_minutes); } int accountid = GetSteamAccountID(client); @@ -127,6 +132,7 @@ public void OnClientPostAdminCheck(int client) public void OnClientDisconnect(int client) { g_iClientHours[client] = 0; + g_iClientMinutes[client] = 0; g_bKnifeBanned[client] = false; } @@ -150,28 +156,45 @@ public Action CheckKnifeBans(Handle timer) Banlist.Rewind(); int length; + int length_minutes; int time; + int time_minutes; if(Banlist.JumpToKey(sAuth)) { length = Banlist.GetNum("duration"); + length_minutes = Banlist.GetNum("duration_minutes"); time = Banlist.GetNum("time"); + time_minutes = Banlist.GetNum("time_minutes", 0); } if(length > 0) - CheckIfClientIsStillKnifeBanned(sAuth, i, time, length); + CheckIfClientIsStillKnifeBanned(sAuth, i, time, time_minutes, length, length_minutes); } } return Plugin_Continue; } -public void CheckIfClientIsStillKnifeBanned(char sAuth[32], int client, int time, int length) +public void CheckIfClientIsStillKnifeBanned(char sAuth[32], int client, int time, int time_minutes, int length, int length_minutes) { int timesinceknifeban = g_iClientHours[client] - time; + int timesinceknifeban_minutes = g_iClientMinutes[client] - time_minutes; - if(timesinceknifeban < length) + if (timesinceknifeban_minutes < 0) + { + timesinceknifeban_minutes += 60; + timesinceknifeban--; + } + + if (timesinceknifeban < length) + { g_bKnifeBanned[client] = true; - else + } + else if (timesinceknifeban == length && timesinceknifeban_minutes < length_minutes) + { + g_bKnifeBanned[client] = true; + } + else { g_bKnifeBanned[client] = false; Banlist.Rewind(); @@ -179,7 +202,9 @@ public void CheckIfClientIsStillKnifeBanned(char sAuth[32], int client, int time if(Banlist.JumpToKey(sAuth)) { Banlist.SetNum("time", 0); + Banlist.SetNum("time_minutes", 0); Banlist.SetNum("duration", 0); + Banlist.SetNum("duration_minutes", 0); Banlist.SetString("admin", ""); Banlist.Rewind(); Banlist.ExportToFile(g_sBanListFilePath); @@ -242,6 +267,9 @@ public Action Command_Knifeban(int client, int args) return Plugin_Handled; int length; + int length_hours; + int length_minutes; + if(GetCmdArgs() >= 2) { length = StringToInt(sArguments[1]); @@ -252,18 +280,10 @@ public Action Command_Knifeban(int client, int args) return Plugin_Handled; } - if(length < 60 && length != 0) - { - CReplyToCommand(client, "\x07%s[KnifeBan] \x07%sKnifebans are now done in hours of gametime. Minimum value is 60.", "E01B5D", "F16767"); - return Plugin_Handled; - } - if (length != 0) - { - length /= 60; - } + length_hours = length / 60; + length_minutes = length % 60; } - if(g_bKnifeBanned[target]) { CReplyToCommand(client, "\x07%s[KnifeBan] \x07%sThe given client is already knifebanned.", "E01B5D", "F16767"); @@ -272,6 +292,7 @@ public Action Command_Knifeban(int client, int args) g_bKnifeBanned[target] = true; int time = g_iClientHours[target]; + int time_minutes = g_iClientMinutes[target]; char sAdmin[32]; GetClientName(client, sAdmin, sizeof(sAdmin)); @@ -285,16 +306,18 @@ public Action Command_Knifeban(int client, int args) if(GetCmdArgs() >= 2) { - if(length) + if(length_hours || length_minutes) { - CPrintToChatAll("\x07%s[KnifeBan] \x07%s%N\x07%s knifebanned \x07%s%N\x07%s for \x07%s%d\x07%s hours Playtime.", "E01B5D", "EDEDED", client, "F16767", "EDEDED", target, "F16767", "EDEDED", length, "F16767"); - LogAction(client, target, "%L knifebanned %L for %d hours.", client, target, length); + CPrintToChatAll("\x07%s[KnifeBan] \x07%s%N\x07%s knifebanned \x07%s%N\x07%s for \x07%s%d\x07%s hours and \x07%s%d\x07%s minutes Playtime.", "E01B5D", "EDEDED", client, "F16767", "EDEDED", target, "F16767", "EDEDED", length_hours, "F16767", "EDEDED", length_minutes, "F16767"); + LogAction(client, target, "%L knifebanned %L for %d hours and %d minutes.", client, target, length_hours, length_minutes); if(Banlist.JumpToKey(sAuth, true)) { int history = Banlist.GetNum("history"); Banlist.SetNum("history", history + 1); Banlist.SetNum("time", time); - Banlist.SetNum("duration", length); + Banlist.SetNum("time_minutes", time_minutes); + Banlist.SetNum("duration", length_hours); + Banlist.SetNum("duration_minutes", length_minutes); Banlist.SetString("admin", sAdmin); Banlist.Rewind(); Banlist.ExportToFile(g_sBanListFilePath); @@ -309,7 +332,9 @@ public Action Command_Knifeban(int client, int args) int history = Banlist.GetNum("history"); Banlist.SetNum("history", history + 1); Banlist.SetNum("time", time); + Banlist.SetNum("time_minutes", time_minutes); Banlist.SetNum("duration", -1); + Banlist.SetNum("duration_minutes", -1); Banlist.SetString("admin", sAdmin); Banlist.Rewind(); Banlist.ExportToFile(g_sBanListFilePath); @@ -325,6 +350,7 @@ public Action Command_Knifeban(int client, int args) int history = Banlist.GetNum("history"); Banlist.SetNum("history", history + 1); Banlist.SetNum("time", time); + Banlist.SetNum("time_minutes", time_minutes); Banlist.SetString("admin", sAdmin); Banlist.Rewind(); Banlist.ExportToFile(g_sBanListFilePath); @@ -368,7 +394,9 @@ public Action Command_Knifeunban(int client, int args) int history = Banlist.GetNum("history"); Banlist.SetNum("history", history - 1); Banlist.SetNum("time", 0); + Banlist.SetNum("time_minutes", 0); Banlist.SetNum("duration", 0); + Banlist.SetNum("duration_minutes", 0); Banlist.SetString("admin", ""); Banlist.Rewind(); Banlist.ExportToFile(g_sBanListFilePath); @@ -405,13 +433,21 @@ public Action Command_Knifestatus(int client, int args) int index = g_TempBanned.FindValue(accountid); Banlist.Rewind(); - int length; + int length_hours; + int length_minutes; + int time; + int time_minutes; + int history; if(Banlist.JumpToKey(sAuth)) { - length = Banlist.GetNum("duration"); + length_hours = Banlist.GetNum("duration"); + length_minutes = Banlist.GetNum("duration_minutes"); + time = Banlist.GetNum("time"); + time_minutes = Banlist.GetNum("time_minutes"); + history = Banlist.GetNum("history"); } @@ -422,18 +458,27 @@ public Action Command_Knifestatus(int client, int args) CReplyToCommand(client, "\x07%s[KnifeBan] \x07%s%N\x07%s is currently temporarily knifebanned.", "E01B5D", "EDEDED", target, "F16767"); return Plugin_Handled; } - else if(g_bKnifeBanned[target] && length == -1) + else if(g_bKnifeBanned[target] && length_hours == -1) { CReplyToCommand(client, "\x07%s[KnifeBan] \x07%s%N\x07%s is currently permanently knifebanned.", "E01B5D", "EDEDED", target, "F16767"); return Plugin_Handled; } - else if(g_bKnifeBanned[target] && length > 0) + else if(g_bKnifeBanned[target] && (length_hours > 0 || length_minutes > 0)) { char sTimeRemaining[64]; int timesinceknifeban = g_iClientHours[target] - time; - int iTimeRemaining = length - timesinceknifeban; - Format(sTimeRemaining, sizeof(sTimeRemaining), "%d Hours playtime", iTimeRemaining); + int timesinceknifeban_minutes = g_iClientMinutes[target] - time_minutes; + if (timesinceknifeban_minutes < 0) + { + timesinceknifeban_minutes += 60; + timesinceknifeban--; + } + + int iTimeRemaining = length_hours - timesinceknifeban; + int iTimeRemaining_minutes = length_minutes - timesinceknifeban_minutes; + + Format(sTimeRemaining, sizeof(sTimeRemaining), "%d Hours and %d minutes playtime", iTimeRemaining, iTimeRemaining_minutes); CReplyToCommand(client, "\x07%s[KnifeBan] \x07%s%N\x07%s is currently knifebanned for another \x07%s%s\x07%s.", "E01B5D", "EDEDED", target, "F16767", "EDEDED", sTimeRemaining, "F16767"); return Plugin_Handled; } @@ -451,12 +496,18 @@ public Action Command_Knifestatus(int client, int args) int index = g_TempBanned.FindValue(accountid); Banlist.Rewind(); - int length; + int length_hours; + int length_minutes; + int time; + int time_minutes; if(Banlist.JumpToKey(sAuth)) { - length = Banlist.GetNum("duration"); + length_hours = Banlist.GetNum("duration"); + length_minutes = Banlist.GetNum("duration_minutes"); + time = Banlist.GetNum("time"); + time_minutes = Banlist.GetNum("time_minutes"); } if(g_bKnifeBanned[client] && index != -1) @@ -464,19 +515,27 @@ public Action Command_Knifestatus(int client, int args) CReplyToCommand(client, "\x07%s[KnifeBan] \x07%sYou are currently temporarily knifebanned.", "E01B5D", "F16767"); return Plugin_Handled; } - else if(g_bKnifeBanned[client] && length == -1) + else if(g_bKnifeBanned[client] && length_hours == -1) { CReplyToCommand(client, "\x07%s[KnifeBan] \x07%sYou are currently permanently knifebanned.", "E01B5D", "F16767"); return Plugin_Handled; } - else if (g_bKnifeBanned[client] && length > 0) + else if(g_bKnifeBanned[client] && (length_hours > 0 || length_minutes > 0)) { char sTimeRemaining[64]; int timesinceknifeban = g_iClientHours[client] - time; - int iTimeRemaining = length - timesinceknifeban; + int timesinceknifeban_minutes = g_iClientMinutes[client] - time_minutes; - Format(sTimeRemaining, sizeof(sTimeRemaining), "%d Hours playtime", iTimeRemaining); + if (timesinceknifeban_minutes < 0) + { + timesinceknifeban_minutes += 60; + timesinceknifeban--; + } + int iTimeRemaining = length_hours - timesinceknifeban; + int iTimeRemaining_minutes = length_minutes - timesinceknifeban_minutes; + + Format(sTimeRemaining, sizeof(sTimeRemaining), "%d Hours and %d minutes playtime", iTimeRemaining, iTimeRemaining_minutes); CReplyToCommand(client, "\x07%s[KnifeBan] \x07%sYou are currently knifebanned for another \x07%s%s\x07%s.", "E01B5D", "F16767", "EDEDED", sTimeRemaining, "F16767"); return Plugin_Handled; } @@ -600,13 +659,15 @@ public void OpenKnifebanlistOfTheClient(int client, char sBuffer[32]) Banlist.Rewind(); int length; - int time; + int length_minutes; + int history; char sAdmin[32]; if(Banlist.JumpToKey(sAuth)) { length = Banlist.GetNum("duration"); - time = Banlist.GetNum("time"); + length_minutes = Banlist.GetNum("duration_minutes"); + history = Banlist.GetNum("history"); Banlist.GetString("admin", sAdmin, sizeof(sAdmin)); } @@ -619,25 +680,18 @@ public void OpenKnifebanlistOfTheClient(int client, char sBuffer[32]) menuclient.AddItem("0", sInfo); if(length > 0) - Format(sInfo, sizeof(sInfo), "Duration: %d Hours playtime", length); + Format(sInfo, sizeof(sInfo), "Duration: %d Hours and %d minutes playtime", length, length_minutes); else if(length == -1) Format(sInfo, sizeof(sInfo), "Duration: Permanently"); else Format(sInfo, sizeof(sInfo), "Duration: Temporarly"); menuclient.AddItem("1", sInfo); - - char sTime[32]; - FormatTime(sTime, sizeof(sTime), "%c", time); - Format(sInfo, sizeof(sInfo), "Date: %s", sTime); + Format(sInfo, sizeof(sInfo), "Ban History: %d times", history); menuclient.AddItem("2", sInfo); - Format(sInfo, sizeof(sInfo), "Ban History: %d times", history); - - menuclient.AddItem("3", sInfo); - - menuclient.AddItem("4", "Back to List"); + menuclient.AddItem("3", "Back to List"); menuclient.Display(client, MENU_TIME_FOREVER); } @@ -663,7 +717,8 @@ public void MenuHandler_ClientMenu(Menu menuclient, MenuAction action, int clien //---------------------------------------------------------------------------------------------------- // Purpose: 2026 getting the ingame play time of the players. called with OnClientPostAdminCheck() forward and timer every 10 minutes //---------------------------------------------------------------------------------------------------- -public void GetPlayerHoursServer(int client, int hours) +public void GetPlayerHoursServer(int client, int hours, int minutes) { g_iClientHours[client] = hours; + g_iClientMinutes[client] = minutes; } diff --git a/SprayManager/scripting/SprayManager.sp b/SprayManager/scripting/SprayManager.sp index ed6175c..dd470f7 100644 --- a/SprayManager/scripting/SprayManager.sp +++ b/SprayManager/scripting/SprayManager.sp @@ -62,6 +62,7 @@ char g_sSprayHash[MAXPLAYERS + 1][16]; char g_csSID[MAXPLAYERS + 1][65]; int g_iClientHoursNotFullFilled[MAXPLAYERS + 1]; +int g_iClientMinutesNotFullFilled[MAXPLAYERS + 1]; int g_iClientToClientSprayLifetime[MAXPLAYERS + 1][MAXPLAYERS + 1]; int g_iClientSprayLifetime[MAXPLAYERS + 1] = { 2, ... }; int g_iSprayLifetime[MAXPLAYERS + 1]; @@ -338,9 +339,10 @@ public void OnClientPostAdminCheck(int client) UpdateHideSprays(); } -public void GetPlayerHoursServer(int client, int hours) +public void GetPlayerHoursServer(int client, int hours, int minutes) { g_iClientHoursNotFullFilled[client] = hours; + g_iClientMinutesNotFullFilled[client] = minutes; g_bFullFillHourRequirement[client] = g_iClientHoursNotFullFilled[client] > g_cvarHourRequirement.IntValue ? true : false; } @@ -2277,7 +2279,7 @@ public Action HookDecal(const char[] sTEName, const int[] iClients, int iNumClie //check for an arbitrary amount of hours before allowing spraying if (!g_bFullFillHourRequirement[client]) { - PrintToChat(client, "\x01\x04[SprayManager]\x01 You cannot spray because you dont have enough play time yet. (\x04%i/\x04%i\x01 hours)", g_iClientHoursNotFullFilled[client], g_cvarHourRequirement.IntValue); + PrintToChat(client, "\x01\x04[SprayManager]\x01 You cannot spray because you dont have enough play time yet. (You have \x04%i Hours and \x04%i minutes. You need \x04%i\x01 hours)", g_iClientHoursNotFullFilled[client], g_iClientMinutesNotFullFilled[client], g_cvarHourRequirement.IntValue); return Plugin_Handled; } @@ -3329,6 +3331,7 @@ stock void ClearPlayerInfo(int client) g_bMarkedNSFWByAdmin[client] = false; g_bFullFillHourRequirement[client] = false; g_iClientHoursNotFullFilled[client] = 0; + g_iClientMinutesNotFullFilled[client] = 0; } stock void UpdateClientToClientSprayLifeTime(int client, int iLifeTime) diff --git a/entWatch4/scripting/entWatch-restrictions_playtime.sp b/entWatch4/scripting/entWatch-restrictions_playtime.sp index ad49e8a..75b6feb 100644 --- a/entWatch4/scripting/entWatch-restrictions_playtime.sp +++ b/entWatch4/scripting/entWatch-restrictions_playtime.sp @@ -25,8 +25,13 @@ Handle g_hFwd_OnClientUnrestricted; /* COOKIES */ Handle g_hCookie_RestrictIssued; +Handle g_hCookie_RestrictIssued_minutes; + Handle g_hCookie_RestrictExpire; +Handle g_hCookie_RestrictExpire_minutes; + Handle g_hCookie_RestrictLength; +Handle g_hCookie_RestrictLength_minutes; /* BOOLEANS */ bool g_bRestrictedTemp[MAXPLAYERS+1]; @@ -34,9 +39,16 @@ bool g_bDontSpamMsg[MAXPLAYERS+1] /* INTERGERS */ int g_iRestrictIssued[MAXPLAYERS+1]; +int g_iRestrictIssued_minutes[MAXPLAYERS+1]; + int g_iRestrictLength[MAXPLAYERS+1]; +int g_iRestrictLength_minutes[MAXPLAYERS+1]; + int g_iRestrictExpire[MAXPLAYERS+1]; +int g_iRestrictExpire_minutes[MAXPLAYERS+1]; + int g_iClientHours[MAXPLAYERS + 1]; +int g_iClientMinutes[MAXPLAYERS + 1]; /* STRINGMAPS */ StringMap g_hTrie_Storage; @@ -76,12 +88,17 @@ public void OnPluginStart() LoadTranslations("common.phrases"); LoadTranslations("entWatch.restrictions.phrases"); - g_hFwd_OnClientRestricted = CreateGlobalForward("EW_OnClientRestricted", ET_Ignore, Param_Cell, Param_Cell, Param_Cell); + g_hFwd_OnClientRestricted = CreateGlobalForward("EW_OnClientRestricted", ET_Ignore, Param_Cell, Param_Cell, Param_Cell, Param_Cell); g_hFwd_OnClientUnrestricted = CreateGlobalForward("EW_OnClientUnrestricted", ET_Ignore, Param_Cell, Param_Cell); g_hCookie_RestrictIssued = RegClientCookie("EW_RestrictIssued", "", CookieAccess_Private); + g_hCookie_RestrictIssued_minutes = RegClientCookie("EW_RestrictIssued_minutes", "", CookieAccess_Private); + g_hCookie_RestrictExpire = RegClientCookie("EW_RestrictExpire", "", CookieAccess_Private); + g_hCookie_RestrictExpire_minutes = RegClientCookie("EW_RestrictExpire_minutes", "", CookieAccess_Private); + g_hCookie_RestrictLength = RegClientCookie("EW_RestrictLength", "", CookieAccess_Private); + g_hCookie_RestrictLength_minutes = RegClientCookie("EW_RestrictLength_minutes", "", CookieAccess_Private); g_hTrie_Storage = new StringMap(); @@ -134,8 +151,13 @@ public void OnClientPutInServer(int client) public void OnClientCookiesCached(int client) { g_iRestrictIssued[client] = GetClientCookieInt(client, g_hCookie_RestrictIssued); + g_iRestrictIssued_minutes[client] = GetClientCookieInt(client, g_hCookie_RestrictIssued_minutes); + g_iRestrictExpire[client] = GetClientCookieInt(client, g_hCookie_RestrictExpire); + g_iRestrictExpire_minutes[client] = GetClientCookieInt(client, g_hCookie_RestrictExpire_minutes); + g_iRestrictLength[client] = GetClientCookieInt(client, g_hCookie_RestrictLength); + g_iRestrictLength_minutes[client] = GetClientCookieInt(client, g_hCookie_RestrictLength_minutes); } //---------------------------------------------------------------------------------------------------- @@ -153,10 +175,18 @@ public void OnClientDisconnect(int client) g_bDontSpamMsg[client] = false; g_bRestrictedTemp[client] = false; + g_iRestrictIssued[client] = 0; + g_iRestrictIssued_minutes[client] = 0; + g_iRestrictExpire[client] = 0; + g_iRestrictExpire_minutes[client] = 0; + g_iRestrictLength[client] = 0; + g_iRestrictLength_minutes[client] = 0; + g_iClientHours[client] = 0; + g_iClientMinutes[client] = 0; } //---------------------------------------------------------------------------------------------------- @@ -184,13 +214,20 @@ public Action Command_ClientRestrict(int client, int args) if (ClientRestrict(client, target, length)) { - if (length && length >= 60) + if (length == -1) { - length /= 60; - CPrintToChatAll("\x07%s[entWatch] \x07%s%N\x07%s restricted \x07%s%N\x07%s for \x07%s%d\x07%s hours Playtime.", "E01B5D", "EDEDED", client, "F16767", "EDEDED", target, "F16767", "EDEDED", length, "F16767"); - LogAction(client, target, "%L restricted %L for %d hours playtime.", client, target, length); + CPrintToChatAll("\x07%s[entWatch] \x07%s%N\x07%s restricted \x07%s%N\x07%s temporarily.", "E01B5D", "EDEDED", client, "F16767", "EDEDED", target, "F16767"); + LogAction(client, target, "%L restricted %L temporarily.", client, target); } - else if (!length) + else if (length > 0) + { + int hours = length / 60; + int minutes = length % 60; + + CPrintToChatAll("\x07%s[entWatch] \x07%s%N\x07%s restricted \x07%s%N\x07%s for \x07%s%d\x07%s hours and \x07%s%d\x07%s minutes Playtime.", "E01B5D", "EDEDED", client, "F16767", "EDEDED", target, "F16767", "EDEDED", hours, "F16767", "EDEDED", minutes, "F16767"); + LogAction(client, target, "%L restricted %L for %d hours and %d minutes playtime.", client, target, hours, minutes); + } + else { CPrintToChatAll("\x07%s[entWatch] \x07%s%N\x07%s restricted \x07%s%N\x07%s permanently.", "E01B5D", "EDEDED", client, "F16767", "EDEDED", target, "F16767"); LogAction(client, target, "%L restricted %L permanently.", client, target); @@ -252,7 +289,7 @@ public Action Command_DisplayRestrictions(int client, int args) { if (ClientRestricted(i)) { - if (g_iClientHours[i] <= g_cvarHourRequirement.IntValue) + if (g_iClientHours[i] < g_cvarHourRequirement.IntValue) { GetClientName(i, aBuf2_time_requirement, sizeof(aBuf2_time_requirement)); StrCat(aBuf_time_requirement, sizeof(aBuf_time_requirement), aBuf2_time_requirement); @@ -318,9 +355,24 @@ public Action Command_DisplayStatus(int client, int args) } else if (g_iRestrictIssued[target] && g_iRestrictExpire[target] >= g_iClientHours[target]) { + //example: 1335 hours and 40 minutes restriction expires. player at 1335 hours and 50 minutes is no longer restricted. + if (g_iRestrictExpire[target] == g_iClientHours[target] && g_iRestrictExpire_minutes[target] < g_iClientMinutes[target]) + { + CReplyToCommand(client, "\x07%s[entWatch] \x07%s%N\x07%s is currently not restricted.", "E01B5D", "EDEDED", target, "F16767"); + return Plugin_Handled; + } + + //its just hours and minutes now char sTimeRemaining[64]; - int iTimeRemaining = g_iRestrictExpire[target] - g_iClientHours[target]; //its just hours now - Format(sTimeRemaining, sizeof(sTimeRemaining), "%d Hours Playtime", iTimeRemaining); + int iTimeRemaining_hours = g_iRestrictExpire[target] - g_iClientHours[target]; + int iTimeRemaining_minutes = g_iRestrictExpire_minutes[target] - g_iClientMinutes[target]; + if (iTimeRemaining_minutes < 0) + { + iTimeRemaining_minutes += 60; + iTimeRemaining_hours--; + } + + Format(sTimeRemaining, sizeof(sTimeRemaining), "%d Hours and %d minutes Playtime", iTimeRemaining_hours, iTimeRemaining_minutes); CReplyToCommand(client, "\x07%s[entWatch] \x07%s%N\x07%s is currently restricted for another \x07%s%s\x07%s.", "E01B5D", "EDEDED", target, "F16767", "EDEDED", sTimeRemaining, "F16767"); return Plugin_Handled; @@ -350,9 +402,24 @@ public Action Command_DisplayStatus(int client, int args) } else if (g_iRestrictIssued[client] && g_iRestrictExpire[client] >= g_iClientHours[client]) { + //example: 1335 hours and 40 minutes restriction expires. player at 1335 hours and 50 minutes is no longer restricted. + if (g_iRestrictExpire[client] == g_iClientHours[client] && g_iRestrictExpire_minutes[client] < g_iClientMinutes[client]) + { + CReplyToCommand(client, "\x07%s[entWatch] \x07%sYou are currently not restricted.", "E01B5D", "F16767"); + return Plugin_Handled; + } + + //its just hours and minutes now char sTimeRemaining[64]; - int iTimeRemaining = g_iRestrictExpire[client] - g_iClientHours[client]; //its just hours now - Format(sTimeRemaining, sizeof(sTimeRemaining), "%d Hours Playtime", iTimeRemaining); + int iTimeRemaining_hours = g_iRestrictExpire[client] - g_iClientHours[client]; + int iTimeRemaining_minutes = g_iRestrictExpire_minutes[client] - g_iClientMinutes[client]; + if (iTimeRemaining_minutes < 0) + { + iTimeRemaining_minutes += 60; + iTimeRemaining_hours--; + } + + Format(sTimeRemaining, sizeof(sTimeRemaining), "%d Hours and %d minutes Playtime", iTimeRemaining_hours, iTimeRemaining_minutes); CReplyToCommand(client, "\x07%s[entWatch] \x07%sYou are currently restricted for another \x07%s%s\x07%s.", "E01B5D", "F16767", "EDEDED", sTimeRemaining, "F16767"); return Plugin_Handled; @@ -401,6 +468,7 @@ stock bool ClientRestrict(int client, int target, int length) } else if (length == 0) { + //permanently g_bRestrictedTemp[target] = false; g_iRestrictIssued[target] = g_iClientHours[target]; g_iRestrictExpire[target] = 0; @@ -412,27 +480,52 @@ stock bool ClientRestrict(int client, int target, int length) } else { - if (length < 60) - { - CPrintToChat(client, "\x07%s[entWatch] \x07%sEban length is now rounded in hours so minimum value has to be 60.", "E01B5D", "EDEDED"); - return false; - } //2026 edit. we now use ingame play time of the client instead of real time. - length /= 60; + int hours_length = length / 60; + int minutes_length = length % 60; + g_bRestrictedTemp[target] = false; + g_iRestrictIssued[target] = g_iClientHours[target]; - g_iRestrictExpire[target] = g_iClientHours[target] + length; - g_iRestrictLength[target] = length; + g_iRestrictIssued_minutes[target] = g_iClientMinutes[target]; + + g_iRestrictExpire[target] = g_iClientHours[target] + hours_length; + int rounded_minutes = g_iClientMinutes[target] + minutes_length; + if (rounded_minutes > 60) + { + rounded_minutes -= 60; + g_iRestrictExpire[target]++; + } + g_iRestrictExpire_minutes[target] = rounded_minutes; + + g_iRestrictLength[target] = hours_length; + g_iRestrictLength_minutes[target] = minutes_length; SetClientCookieInt(target, g_hCookie_RestrictIssued, g_iRestrictIssued[target]); + SetClientCookieInt(target, g_hCookie_RestrictIssued_minutes, g_iRestrictIssued_minutes[target]); + SetClientCookieInt(target, g_hCookie_RestrictExpire, g_iRestrictExpire[target]); - SetClientCookieInt(target, g_hCookie_RestrictLength, length); + SetClientCookieInt(target, g_hCookie_RestrictExpire_minutes, g_iRestrictExpire_minutes[target]); + + SetClientCookieInt(target, g_hCookie_RestrictLength, g_iRestrictLength[target]); + SetClientCookieInt(target, g_hCookie_RestrictLength_minutes, g_iRestrictLength_minutes[target]); } Call_StartForward(g_hFwd_OnClientRestricted); Call_PushCell(client); Call_PushCell(target); - Call_PushCell(length); + if (length == -1 || length == 0) + { + //its temporarily or permanently + Call_PushCell(length); + Call_PushCell(0); + } + else + { + //its certain amount of hours and minutes + Call_PushCell(g_iRestrictLength[target]); + Call_PushCell(g_iRestrictLength_minutes[target]); + } Call_Finish(); return true; @@ -447,13 +540,24 @@ stock bool ClientUnrestrict(int client, int target) return false; g_bRestrictedTemp[target] = false; + g_iRestrictIssued[target] = 0; + g_iRestrictIssued_minutes[target] = 0; + g_iRestrictExpire[target] = 0; + g_iRestrictExpire_minutes[target] = 0; + g_iRestrictLength[target] = 0; + g_iRestrictLength_minutes[target] = 0; SetClientCookieInt(target, g_hCookie_RestrictIssued, 0); + SetClientCookieInt(target, g_hCookie_RestrictIssued_minutes, 0); + SetClientCookieInt(target, g_hCookie_RestrictExpire, 0); + SetClientCookieInt(target, g_hCookie_RestrictExpire_minutes, 0); + SetClientCookieInt(target, g_hCookie_RestrictLength, 0); + SetClientCookieInt(target, g_hCookie_RestrictLength_minutes, 0); Call_StartForward(g_hFwd_OnClientUnrestricted); Call_PushCell(client); @@ -485,14 +589,25 @@ stock bool ClientRestricted(int client) //Normal restriction. if (g_iRestrictIssued[client] && g_iRestrictExpire[client] >= g_iClientHours[client]) - return true; - + { + //example: client restricted until 1335 hours and currently has 1320 + if (g_iRestrictExpire[client] > g_iClientHours[client]) + { + return true; + } + //example client restricted until 1335 hours and 45 minutes. currently has 1335 hours and 20 minutes. + if (g_iRestrictExpire_minutes[client] > g_iClientMinutes[client]) + { + return true; + } + } + //hour requirement for picking up items - if (g_iClientHours[client] <= g_cvarHourRequirement.IntValue) + if (g_iClientHours[client] < g_cvarHourRequirement.IntValue) { if (!g_bDontSpamMsg[client]) { - CPrintToChat(client, "\x07%s[entWatch] \x07%s You have \x07%s%i\x07%s hours playtime and need more than %i hours for picking up items.", "E01B5D", "EDEDED", "EDEDED", g_iClientHours[client], "EDEDED", g_cvarHourRequirement.IntValue); + CPrintToChat(client, "\x07%s[entWatch] \x07%s You have \x07%s%i\x07%s hours and \x07%s%i\x07%s minutes playtime and need %i hours for picking up items.", "E01B5D", "EDEDED", "EDEDED", g_iClientHours[client], "EDEDED", "EDEDED", g_iClientMinutes[client], "EDEDED", g_cvarHourRequirement.IntValue); g_bDontSpamMsg[client] = true; CreateTimer(1.0, allow_message_again, GetClientSerial(client)); } @@ -551,9 +666,10 @@ stock int GetClientCookieInt(int client, Handle hCookie) //---------------------------------------------------------------------------------------------------- // Purpose: 2026 getting the ingame play time of the players. called with OnClientPostAdminCheck() forward and timer every 10 minutes //---------------------------------------------------------------------------------------------------- -public void GetPlayerHoursServer(int client, int hours) +public void GetPlayerHoursServer(int client, int hours, int minutes) { g_iClientHours[client] = hours; + g_iClientMinutes[client] = minutes; } //---------------------------------------------------------------------------------------------------- diff --git a/entWatch4/scripting/include/entWatch_restrictions_playtime.inc b/entWatch4/scripting/include/entWatch_restrictions_playtime.inc new file mode 100644 index 0000000..d0c45cf --- /dev/null +++ b/entWatch4/scripting/include/entWatch_restrictions_playtime.inc @@ -0,0 +1,33 @@ +#if defined entWatch_restrictions_included + #endinput +#endif + +#define entWatch_restrictions_included + +public SharedPlugin __pl_entWatch_restrictions = +{ + name = "entWatch-restrictions", + file = "entWatch-restrictions.smx", + + #if defined REQUIRE_PLUGIN + required = 1 + #else + required = 0 + #endif +}; + +#if !defined REQUIRE_PLUGIN + public void __pl_entWatch_restrictions_SetNTVOptional() + { + MarkNativeAsOptional("EW_ClientRestrict"); + MarkNativeAsOptional("EW_ClientUnrestrict"); + MarkNativeAsOptional("EW_ClientRestricted"); + } +#endif + +native bool EW_ClientRestrict(int client, int target, int length); +native bool EW_ClientUnrestrict(int client, int target); +native bool EW_ClientRestricted(int client); + +forward void EW_OnClientRestricted(int client, int target, int hours, int minutes); +forward void EW_OnClientUnrestricted(int client, int target);