diff --git a/ReservedSlot/scripting/ReservedSlot.sp b/ReservedSlot/scripting/ReservedSlot.sp index c23e8742..89a74321 100644 --- a/ReservedSlot/scripting/ReservedSlot.sp +++ b/ReservedSlot/scripting/ReservedSlot.sp @@ -5,6 +5,7 @@ #undef REQUIRE_PLUGIN #include #include +#tryinclude #define REQUIRE_PLUGIN #pragma semicolon 1 @@ -12,6 +13,7 @@ bool g_Plugin_AFKManager; bool g_Plugin_UNLOZE; +bool g_Plugin_entWatch; int g_Client_Reservation[MAXPLAYERS + 1] = {0, ...}; @@ -38,6 +40,7 @@ public void OnAllPluginsLoaded() { g_Plugin_AFKManager = LibraryExists("AFKManager"); g_Plugin_UNLOZE = LibraryExists("UNLOZE_ForumIntegration"); + g_Plugin_entWatch = LibraryExists("entWatch-core"); LogMessage("ReservedSlots capabilities:\nAFKManager: %s\nUNLOZE: %s\n", (g_Plugin_AFKManager ? "loaded" : "not loaded"), @@ -50,6 +53,8 @@ public void OnLibraryAdded(const char[] name) g_Plugin_AFKManager = true; else if(StrEqual(name, "UNLOZE_ForumIntegration")) g_Plugin_UNLOZE = true; + else if(StrEqual(name, "entWatch-core")) + g_Plugin_entWatch = true; } public void OnLibraryRemoved(const char[] name) @@ -58,6 +63,8 @@ public void OnLibraryRemoved(const char[] name) g_Plugin_AFKManager = false; else if(StrEqual(name, "UNLOZE_ForumIntegration")) g_Plugin_UNLOZE = false; + else if(StrEqual(name, "entWatch-core")) + g_Plugin_entWatch = false; } public void OnClientPostAdminCheck(int client) @@ -149,15 +156,15 @@ public void AsyncHasSteamIDReservedSlotCallback(const char[] sSteam32ID, int Res stock bool KickValidClient(const char[] sName, const char[] sSteam32ID, AdminId admin, int Immunity) { - int HighestValue[4] = {0, ...}; - int HighestValueClient[4] = {0, ...}; + int HighestValue[3] = {-1, ...}; + int HighestValueClient[3] = {0, ...}; for(int client = 1; client <= MaxClients; client++) { if(!IsClientInGame(client) || IsFakeClient(client)) continue; - int Donator = g_Client_Reservation[client]; + bool Donator = view_as(g_Client_Reservation[client]); int ConnectionTime = RoundToNearest(GetClientTime(client)); int IdleTime; @@ -166,6 +173,12 @@ stock bool KickValidClient(const char[] sName, const char[] sSteam32ID, AdminId else // Fall back to highest connection time. IdleTime = ConnectionTime; + int HasItem; + #if defined entWatch_core_included + if(g_Plugin_entWatch) + HasItem = EW_ClientHasItem(client); + #endif + /* Spectators * Sort by idle time and also kick donators if IdleTime > 30 */ @@ -197,7 +210,7 @@ stock bool KickValidClient(const char[] sName, const char[] sSteam32ID, AdminId /* Alive non-donator with IdleTime > 30 * Sort by idle time and don't kick donators and item owners. - * + */ if(!Donator && IsPlayerAlive(client) && !HasItem) { if(IdleTime > 30 && IdleTime > HighestValue[2]) @@ -206,13 +219,13 @@ stock bool KickValidClient(const char[] sName, const char[] sSteam32ID, AdminId HighestValueClient[2] = client; } } - * Alive non-donator with IdleTime > 30 */ + /* Alive non-donator with IdleTime > 30 */ } // Check if any condition was met in the correct order and perform kick for(int i = 0; i < sizeof(HighestValue); i++) { - if(HighestValue[i]) + if(HighestValue[i] != -1) { ExecuteKickValidClient(HighestValueClient[i], sName, sSteam32ID, admin, Immunity); return true; diff --git a/entWatch4/scripting/entWatch-core.sp b/entWatch4/scripting/entWatch-core.sp index 36413788..ed5d534f 100644 --- a/entWatch4/scripting/entWatch-core.sp +++ b/entWatch4/scripting/entWatch-core.sp @@ -56,6 +56,7 @@ public APLRes AskPluginLoad2(Handle hMyself, bool bLate, char[] sError, int erro CreateNative("EW_GetItemCount", Native_GetItemCount); CreateNative("EW_GetItemData", Native_GetItemData); + CreateNative("EW_ClientHasItem", Native_ClientHasItem); RegPluginLibrary("entWatch-core"); return APLRes_Success; @@ -752,4 +753,34 @@ public int Native_GetItemData(Handle hPlugin, int numParams) } return view_as(g_hArray_Items.Get(index)); -} \ No newline at end of file +} + +//---------------------------------------------------------------------------------------------------- +// Purpose: +//---------------------------------------------------------------------------------------------------- +public int Native_ClientHasItem(Handle hPlugin, int numParams) +{ + int client = GetNativeCell(1); + + if(client > MaxClients || client <= 0) + { + return ThrowNativeError(SP_ERROR_NATIVE, "Client is not valid."); + } + + if(!IsClientInGame(client)) + { + ThrowNativeError(SP_ERROR_NATIVE, "Client is not in game."); + } + + for (int index; index < g_hArray_Items.Length; index++) + { + CItem item = g_hArray_Items.Get(index); + + if (item.bClient && item.iClient == client) + { + return 1; + } + } + + return 0; +} diff --git a/entWatch4/scripting/classes/CConfig.inc b/entWatch4/scripting/include/entWatch/CConfig.inc similarity index 100% rename from entWatch4/scripting/classes/CConfig.inc rename to entWatch4/scripting/include/entWatch/CConfig.inc diff --git a/entWatch4/scripting/classes/CItem.inc b/entWatch4/scripting/include/entWatch/CItem.inc similarity index 100% rename from entWatch4/scripting/classes/CItem.inc rename to entWatch4/scripting/include/entWatch/CItem.inc diff --git a/entWatch4/scripting/include/entWatch_core.inc b/entWatch4/scripting/include/entWatch_core.inc index 147b91b7..876da0e2 100644 --- a/entWatch4/scripting/include/entWatch_core.inc +++ b/entWatch4/scripting/include/entWatch_core.inc @@ -24,8 +24,8 @@ /* CLASSES */ #include -#include "../classes/CConfig.inc" -#include "../classes/CItem.inc" +#include "entWatch/CConfig.inc" +#include "entWatch/CItem.inc" public SharedPlugin __pl_entWatch_core = { @@ -44,6 +44,7 @@ public SharedPlugin __pl_entWatch_core = { MarkNativeAsOptional("EW_GetItemCount"); MarkNativeAsOptional("EW_GetItemData"); + MarkNativeAsOptional("EW_ClientHasItem"); } #endif @@ -51,6 +52,8 @@ native int EW_GetItemCount(); native CItem EW_GetItemData(int index); +native bool EW_ClientHasItem(int client); + forward void EW_OnClientItemDrop(int client, int index); forward void EW_OnClientItemDeath(int client, int index); forward void EW_OnClientItemPickup(int client, int index); @@ -58,4 +61,4 @@ forward void EW_OnClientItemActivate(int client, int index); forward void EW_OnClientItemDisconnect(int client, int index); forward Action EW_OnClientItemCanPickup(int client, int index); -forward Action EW_OnClientItemCanActivate(int client, int index); \ No newline at end of file +forward Action EW_OnClientItemCanActivate(int client, int index); diff --git a/includes/entWatch b/includes/entWatch new file mode 120000 index 00000000..b055d2de --- /dev/null +++ b/includes/entWatch @@ -0,0 +1 @@ +../entWatch4/scripting/include/entWatch \ No newline at end of file