entWatch4 update.

This commit is contained in:
zaCade 2017-10-12 21:53:17 +02:00
parent 5c8a765776
commit 8ba1041e8d
4 changed files with 76 additions and 305 deletions

View File

@ -11,12 +11,13 @@
#include <sourcemod> #include <sourcemod>
#include <sdkhooks> #include <sdkhooks>
#include <sdktools>
#include <entWatch> #include <entWatch>
/* BOOLS */ /* BOOLS */
bool g_bLate; bool g_bLate;
/* HANDLES */ /* ARRAYS */
ArrayList g_hArray_Items; ArrayList g_hArray_Items;
ArrayList g_hArray_Config; ArrayList g_hArray_Config;
@ -75,6 +76,7 @@ public void OnPluginStart()
g_hArray_Config = new ArrayList(512); g_hArray_Config = new ArrayList(512);
HookEvent("player_death", OnClientDeath); HookEvent("player_death", OnClientDeath);
HookEvent("round_start", OnRoundStart);
if (g_bLate) if (g_bLate)
{ {
@ -100,12 +102,13 @@ public void OnMapStart()
char sCurrentMap[128]; char sCurrentMap[128];
GetCurrentMap(sCurrentMap, sizeof(sCurrentMap)); GetCurrentMap(sCurrentMap, sizeof(sCurrentMap));
String_ToLower(sCurrentMap, sCurrentMap, sizeof(sCurrentMap));
char sFilePathDefault[PLATFORM_MAX_PATH]; char sFilePathDefault[PLATFORM_MAX_PATH];
char sFilePathOverride[PLATFORM_MAX_PATH]; char sFilePathOverride[PLATFORM_MAX_PATH];
Format(sFilePathDefault, sizeof(sFilePathDefault), "cfg/sourcemod/entwatch/%s.cfg", sCurrentMap); BuildPath(Path_SM, sFilePathDefault, sizeof(sFilePathDefault), "configs/entwatch/%s.cfg", sCurrentMap);
Format(sFilePathOverride, sizeof(sFilePathOverride), "cfg/sourcemod/entwatch/%s_override.cfg", sCurrentMap); BuildPath(Path_SM, sFilePathOverride, sizeof(sFilePathOverride), "configs/entwatch/%s.override.cfg", sCurrentMap);
KeyValues hConfig = new KeyValues("items"); KeyValues hConfig = new KeyValues("items");
@ -159,6 +162,24 @@ public void OnMapStart()
return; return;
} }
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast)
{
if (g_hArray_Items.Length)
{
for (int index; index < g_hArray_Items.Length; index++)
{
any itemArray[items];
g_hArray_Items.GetArray(index, itemArray, sizeof(itemArray));
if (itemArray[item_owned] && itemArray[item_owner] >= 0)
g_hArray_Items.Erase(index);
}
}
}
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -212,7 +233,7 @@ stock bool RegisterItem(any[] itemArray, int entity)
{ {
if (itemArray[item_weaponid] && itemArray[item_weaponid] == Entity_GetHammerId(entity)) if (itemArray[item_weaponid] && itemArray[item_weaponid] == Entity_GetHammerId(entity))
{ {
if (!itemArray[item_weapon]) if (!itemArray[item_weapon] && (Entity_GetOwner(entity) == INVALID_ENT_REFERENCE))
{ {
itemArray[item_weapon] = entity; itemArray[item_weapon] = entity;
return true; return true;
@ -301,16 +322,17 @@ public void OnClientPutInServer(int client)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void OnClientDisconnect(int client) public void OnClientDisconnect(int client)
{ {
if (!IsFakeClient(client) && g_hArray_Items.Length) if (!IsFakeClient(client) && g_hArray_Items.Length)
{ {
for (int index; index < g_hArray_Items.Length; index++) for (int index; index < g_hArray_Items.Length; index++)
{ {
any itemArray[items]; any itemArray[items];
g_hArray_Items.GetArray(index, itemArray, sizeof(itemArray)); g_hArray_Items.GetArray(index, itemArray, sizeof(itemArray));
if (itemArray[item_owner] && itemArray[item_owner] == client) if (itemArray[item_owned] && itemArray[item_owner] == client)
{ {
itemArray[item_owner] = 0; itemArray[item_owner] = INVALID_ENT_REFERENCE;
itemArray[item_owned] = false;
Call_StartForward(g_hFwd_OnClientItemDisconnect); Call_StartForward(g_hFwd_OnClientItemDisconnect);
Call_PushArray(itemArray, sizeof(itemArray)); Call_PushArray(itemArray, sizeof(itemArray));
@ -329,7 +351,7 @@ public void OnClientDisconnect(int client)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void OnClientDeath(Event hEvent, const char[] sEvent, bool bDontBroadcast) public void OnClientDeath(Event hEvent, const char[] sEvent, bool bDontBroadcast)
{ {
int client = GetClientOfUserId(hEvent.GetInt("userid")) int client = GetClientOfUserId(hEvent.GetInt("userid"));
if (Client_IsValid(client) && !IsFakeClient(client) && g_hArray_Items.Length) if (Client_IsValid(client) && !IsFakeClient(client) && g_hArray_Items.Length)
{ {
@ -338,9 +360,10 @@ public void OnClientDeath(Event hEvent, const char[] sEvent, bool bDontBroadcast
any itemArray[items]; any itemArray[items];
g_hArray_Items.GetArray(index, itemArray, sizeof(itemArray)); g_hArray_Items.GetArray(index, itemArray, sizeof(itemArray));
if (itemArray[item_owner] && itemArray[item_owner] == client) if (itemArray[item_owned] && itemArray[item_owner] == client)
{ {
itemArray[item_owner] = 0; itemArray[item_owner] = INVALID_ENT_REFERENCE;
itemArray[item_owned] = false;
Call_StartForward(g_hFwd_OnClientItemDeath); Call_StartForward(g_hFwd_OnClientItemDeath);
Call_PushArray(itemArray, sizeof(itemArray)); Call_PushArray(itemArray, sizeof(itemArray));
@ -369,6 +392,7 @@ public Action OnWeaponPickup(int client, int weapon)
if (itemArray[item_weapon] && itemArray[item_weapon] == weapon) if (itemArray[item_weapon] && itemArray[item_weapon] == weapon)
{ {
itemArray[item_owner] = client; itemArray[item_owner] = client;
itemArray[item_owned] = true;
Call_StartForward(g_hFwd_OnClientItemPickup); Call_StartForward(g_hFwd_OnClientItemPickup);
Call_PushArray(itemArray, sizeof(itemArray)); Call_PushArray(itemArray, sizeof(itemArray));
@ -397,7 +421,8 @@ public Action OnWeaponDrop(int client, int weapon)
if (itemArray[item_weapon] && itemArray[item_weapon] == weapon) if (itemArray[item_weapon] && itemArray[item_weapon] == weapon)
{ {
itemArray[item_owner] = 0; itemArray[item_owner] = INVALID_ENT_REFERENCE;
itemArray[item_owned] = false;
Call_StartForward(g_hFwd_OnClientItemDrop); Call_StartForward(g_hFwd_OnClientItemDrop);
Call_PushArray(itemArray, sizeof(itemArray)); Call_PushArray(itemArray, sizeof(itemArray));
@ -419,6 +444,10 @@ public Action OnButtonPress(int button, int client)
{ {
if (Client_IsValid(client) && Entity_IsValid(button) && g_hArray_Items.Length) if (Client_IsValid(client) && Entity_IsValid(button) && g_hArray_Items.Length)
{ {
if (HasEntProp(button, Prop_Data, "m_bLocked") &&
GetEntProp(button, Prop_Data, "m_bLocked"))
return Plugin_Handled;
for (int index; index < g_hArray_Items.Length; index++) for (int index; index < g_hArray_Items.Length; index++)
{ {
any itemArray[items]; any itemArray[items];
@ -426,7 +455,7 @@ public Action OnButtonPress(int button, int client)
if (itemArray[item_button] && itemArray[item_button] == button) if (itemArray[item_button] && itemArray[item_button] == button)
{ {
if (itemArray[item_owner] && itemArray[item_owner] == client) if (itemArray[item_owned] && itemArray[item_owner] == client)
{ {
Action aResult; Action aResult;
Call_StartForward(g_hFwd_OnClientItemCanActivate); Call_StartForward(g_hFwd_OnClientItemCanActivate);

View File

@ -41,7 +41,7 @@ public void OnGameFrame()
if (itemArray[item_display] & DISPLAY_HUD) if (itemArray[item_display] & DISPLAY_HUD)
{ {
if (itemArray[item_owner] && Client_IsValid(itemArray[item_owner])) if (itemArray[item_owned] && itemArray[item_owner] >= 0)
{ {
switch(itemArray[item_mode]) switch(itemArray[item_mode])
{ {

View File

@ -5,8 +5,8 @@
// Description: Handle the restrictions of [entWatch] // Description: Handle the restrictions of [entWatch]
// //
//==================================================================================================== //====================================================================================================
#include <smlib>
#include <morecolors> #include <morecolors>
#include <smlib>
#pragma newdecls required #pragma newdecls required
@ -20,14 +20,14 @@ Handle g_hFwd_OnClientRestricted;
Handle g_hFwd_OnClientUnrestricted; Handle g_hFwd_OnClientUnrestricted;
/* COOKIES */ /* COOKIES */
Handle g_hCookie_RestrictedIssued; Handle g_hCookie_RestrictIssued;
Handle g_hCookie_RestrictedLength; Handle g_hCookie_RestrictLength;
Handle g_hCookie_RestrictedExpire; Handle g_hCookie_RestrictExpire;
/* INTERGERS */ /* INTERGERS */
int g_iRestrictedIssued[MAXPLAYERS+1]; int g_iRestrictIssued[MAXPLAYERS+1];
int g_iRestrictedLength[MAXPLAYERS+1]; int g_iRestrictLength[MAXPLAYERS+1];
int g_iRestrictedExpire[MAXPLAYERS+1]; int g_iRestrictExpire[MAXPLAYERS+1];
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
@ -64,9 +64,9 @@ public void OnPluginStart()
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);
g_hFwd_OnClientUnrestricted = CreateGlobalForward("EW_OnClientUnrestricted", ET_Ignore, Param_Cell, Param_Cell); g_hFwd_OnClientUnrestricted = CreateGlobalForward("EW_OnClientUnrestricted", ET_Ignore, Param_Cell, Param_Cell);
g_hCookie_RestrictedIssued = RegClientCookie("EW_RestrictedIssued", "", CookieAccess_Private); g_hCookie_RestrictIssued = RegClientCookie("EW_RestrictIssued", "", CookieAccess_Private);
g_hCookie_RestrictedLength = RegClientCookie("EW_RestrictedLength", "", CookieAccess_Private); g_hCookie_RestrictLength = RegClientCookie("EW_RestrictLength", "", CookieAccess_Private);
g_hCookie_RestrictedExpire = RegClientCookie("EW_RestrictedExpire", "", CookieAccess_Private); g_hCookie_RestrictExpire = RegClientCookie("EW_RestrictExpire", "", CookieAccess_Private);
RegAdminCmd("sm_eban", Command_ClientRestrict, ADMFLAG_BAN); RegAdminCmd("sm_eban", Command_ClientRestrict, ADMFLAG_BAN);
RegAdminCmd("sm_eunban", Command_ClientUnrestrict, ADMFLAG_UNBAN); RegAdminCmd("sm_eunban", Command_ClientUnrestrict, ADMFLAG_UNBAN);
@ -77,9 +77,9 @@ public void OnPluginStart()
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void OnClientCookiesCached(int client) public void OnClientCookiesCached(int client)
{ {
g_iRestrictedIssued[client] = GetClientCookieInt(client, g_hCookie_RestrictedIssued); g_iRestrictIssued[client] = GetClientCookieInt(client, g_hCookie_RestrictIssued);
g_iRestrictedLength[client] = GetClientCookieInt(client, g_hCookie_RestrictedLength); g_iRestrictLength[client] = GetClientCookieInt(client, g_hCookie_RestrictLength);
g_iRestrictedExpire[client] = GetClientCookieInt(client, g_hCookie_RestrictedExpire); g_iRestrictExpire[client] = GetClientCookieInt(client, g_hCookie_RestrictExpire);
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -87,9 +87,9 @@ public void OnClientCookiesCached(int client)
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void OnClientDisconnect(int client) public void OnClientDisconnect(int client)
{ {
g_iRestrictedIssued[client] = 0; g_iRestrictIssued[client] = 0;
g_iRestrictedLength[client] = 0; g_iRestrictLength[client] = 0;
g_iRestrictedExpire[client] = 0; g_iRestrictExpire[client] = 0;
} }
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
@ -186,13 +186,13 @@ stock bool ClientRestrict(int client, int target, int length)
int second = length * 60; int second = length * 60;
int expire = issued + second; int expire = issued + second;
g_iRestrictedIssued[target] = issued; g_iRestrictIssued[target] = issued;
g_iRestrictedLength[target] = length; g_iRestrictLength[target] = length;
g_iRestrictedExpire[target] = expire; g_iRestrictExpire[target] = expire;
SetClientCookieInt(target, g_hCookie_RestrictedIssued, issued); SetClientCookieInt(target, g_hCookie_RestrictIssued, issued);
SetClientCookieInt(target, g_hCookie_RestrictedLength, length); SetClientCookieInt(target, g_hCookie_RestrictLength, length);
SetClientCookieInt(target, g_hCookie_RestrictedExpire, expire); SetClientCookieInt(target, g_hCookie_RestrictExpire, expire);
Call_StartForward(g_hFwd_OnClientRestricted); Call_StartForward(g_hFwd_OnClientRestricted);
Call_PushCell(client); Call_PushCell(client);
@ -211,13 +211,13 @@ stock bool ClientUnrestrict(int client, int target)
if (!Client_IsValid(client) || !Client_IsValid(target) || !AreClientCookiesCached(target) || !ClientRestricted(target)) if (!Client_IsValid(client) || !Client_IsValid(target) || !AreClientCookiesCached(target) || !ClientRestricted(target))
return false; return false;
g_iRestrictedIssued[target] = 0; g_iRestrictIssued[target] = 0;
g_iRestrictedLength[target] = 0; g_iRestrictLength[target] = 0;
g_iRestrictedExpire[target] = 0; g_iRestrictExpire[target] = 0;
SetClientCookieInt(target, g_hCookie_RestrictedIssued, 0); SetClientCookieInt(target, g_hCookie_RestrictIssued, 0);
SetClientCookieInt(target, g_hCookie_RestrictedLength, 0); SetClientCookieInt(target, g_hCookie_RestrictLength, 0);
SetClientCookieInt(target, g_hCookie_RestrictedExpire, 0); SetClientCookieInt(target, g_hCookie_RestrictExpire, 0);
Call_StartForward(g_hFwd_OnClientUnrestricted); Call_StartForward(g_hFwd_OnClientUnrestricted);
Call_PushCell(client); Call_PushCell(client);
@ -240,11 +240,11 @@ stock bool ClientRestricted(int client)
return true; return true;
//Permanent restriction.. //Permanent restriction..
if (g_iRestrictedExpire[client] && g_iRestrictedLength[client] == 0) if (g_iRestrictExpire[client] && g_iRestrictLength[client] == 0)
return true; return true;
//Limited restriction.. //Limited restriction..
if (g_iRestrictedExpire[client] && g_iRestrictedExpire[client] >= GetTime()) if (g_iRestrictExpire[client] && g_iRestrictExpire[client] >= GetTime())
return true; return true;
return false; return false;

View File

@ -14,6 +14,7 @@ enum items
String:item_short[32], String:item_short[32],
String:item_color[32], String:item_color[32],
String:item_filter[32], String:item_filter[32],
bool:item_owned,
item_buttonid, item_buttonid,
item_weaponid, item_weaponid,
item_triggerid, item_triggerid,
@ -28,262 +29,3 @@ enum items
item_nextuse, item_nextuse,
item_cooldown, item_cooldown,
}; };
/*
methodmap CItem < Basic
{
public CItem()
{
Basic myclass = new Basic();
myclass.SetHandle("hConfig", INVALID_HANDLE);
myclass.SetInt("iOwner", INVALID_ENT_REFERENCE);
myclass.SetInt("iButton", INVALID_ENT_REFERENCE);
myclass.SetInt("iWeapon", INVALID_ENT_REFERENCE);
myclass.SetInt("iTrigger", INVALID_ENT_REFERENCE);
myclass.SetInt("iLastActivation", 0);
myclass.SetInt("iActivations", 0);
return myclass;
}
property CConfig hConfig
{
public get()
{
return this.GetHandle("hConfig");
}
public set(CConfig value)
{
this.SetHandle("hConfig", value);
}
}
property int iOwner
{
public get()
{
return this.GetInt("iOwner");
}
public set(int value)
{
this.SetInt("iOwner", value);
}
}
property int iButton
{
public get()
{
return this.GetInt("iButton");
}
public set(int value)
{
this.SetInt("iButton", value);
}
}
property int iWeapon
{
public get()
{
return this.GetInt("iWeapon");
}
public set(int value)
{
this.SetInt("iWeapon", value);
}
}
property int iTrigger
{
public get()
{
return this.GetInt("iTrigger");
}
public set(int value)
{
this.SetInt("iTrigger", value);
}
}
property int iLastActivation
{
public get()
{
return this.GetInt("iLastActivation");
}
public set(int value)
{
this.SetInt("iLastActivation", value);
}
}
property int iActivations
{
public get()
{
return this.GetInt("iActivations");
}
public set(int value)
{
this.SetInt("iActivations", value);
}
}
}
methodmap CConfig < Basic
{
public CConfig()
{
Basic myclass = new Basic();
myclass.SetString("sName", "");
myclass.SetString("sShort", "");
myclass.SetString("sColor", "");
myclass.SetString("sFilter", "");
myclass.SetInt("iButtonID", 0);
myclass.SetInt("iWeaponID", 0);
myclass.SetInt("iTriggerID", 0);
myclass.SetInt("iDisplay", 0);
myclass.SetInt("iMode", 0);
myclass.SetInt("iCooldown", 0);
myclass.SetInt("iMaxActivations", 0);
return myclass;
}
property char sName
{
public get()
{
return this.GetString("sName");
}
public set(char[] value)
{
this.SetString("sName", value);
}
}
property char sShort
{
public get()
{
return this.GetString("sShort");
}
public set(char[] value)
{
this.SetString("sShort", value);
}
}
property char sColor
{
public get()
{
return this.GetString("sColor");
}
public set(char[] value)
{
this.SetString("sColor", value);
}
}
property char sFilter
{
public get()
{
return this.GetString("sFilter");
}
public set(char[] value)
{
this.SetString("sFilter", value);
}
}
property int iButtonID
{
public get()
{
return this.GetInt("iButtonID");
}
public set(int value)
{
this.SetInt("iButtonID", value);
}
}
property int iWeaponID
{
public get()
{
return this.GetInt("iWeaponID");
}
public set(int value)
{
this.SetInt("iWeaponID", value);
}
}
property int iTriggerID
{
public get()
{
return this.GetInt("iTriggerID");
}
public set(int value)
{
this.SetInt("iTriggerID", value);
}
}
property int iDisplay
{
public get()
{
return this.GetInt("iDisplay");
}
public set(int value)
{
this.SetInt("iDisplay", value);
}
}
property int iMode
{
public get()
{
return this.GetInt("iMode");
}
public set(int value)
{
this.SetInt("iMode", value);
}
}
property int iCooldown
{
public get()
{
return this.GetInt("iCooldown");
}
public set(int value)
{
this.SetInt("iCooldown", value);
}
}
property int iMaxActivations
{
public get()
{
return this.GetInt("iMaxActivations");
}
public set(int value)
{
this.SetInt("iMaxActivations", value);
}
}
}
*/