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
+43 -14
View File
@@ -11,12 +11,13 @@
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#include <entWatch>
/* BOOLS */
bool g_bLate;
/* HANDLES */
/* ARRAYS */
ArrayList g_hArray_Items;
ArrayList g_hArray_Config;
@@ -70,11 +71,12 @@ public void OnPluginStart()
g_hFwd_OnClientItemCanPickup = CreateGlobalForward("EW_OnClientItemCanPickup", ET_Hook, Param_Array, Param_Cell, Param_Cell);
g_hFwd_OnClientItemCanActivate = CreateGlobalForward("EW_OnClientItemCanActivate", ET_Hook, Param_Array, Param_Cell, Param_Cell);
g_hArray_Items = new ArrayList(512);
g_hArray_Config = new ArrayList(512);
HookEvent("player_death", OnClientDeath);
HookEvent("round_start", OnRoundStart);
if (g_bLate)
{
@@ -100,12 +102,13 @@ public void OnMapStart()
char sCurrentMap[128];
GetCurrentMap(sCurrentMap, sizeof(sCurrentMap));
String_ToLower(sCurrentMap, sCurrentMap, sizeof(sCurrentMap));
char sFilePathDefault[PLATFORM_MAX_PATH];
char sFilePathOverride[PLATFORM_MAX_PATH];
Format(sFilePathDefault, sizeof(sFilePathDefault), "cfg/sourcemod/entwatch/%s.cfg", sCurrentMap);
Format(sFilePathOverride, sizeof(sFilePathOverride), "cfg/sourcemod/entwatch/%s_override.cfg", sCurrentMap);
BuildPath(Path_SM, sFilePathDefault, sizeof(sFilePathDefault), "configs/entwatch/%s.cfg", sCurrentMap);
BuildPath(Path_SM, sFilePathOverride, sizeof(sFilePathOverride), "configs/entwatch/%s.override.cfg", sCurrentMap);
KeyValues hConfig = new KeyValues("items");
@@ -159,6 +162,24 @@ public void OnMapStart()
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:
//----------------------------------------------------------------------------------------------------
@@ -212,7 +233,7 @@ stock bool RegisterItem(any[] itemArray, int 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;
return true;
@@ -301,16 +322,17 @@ public void OnClientPutInServer(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++)
{
any itemArray[items];
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_PushArray(itemArray, sizeof(itemArray));
@@ -329,7 +351,7 @@ public void OnClientDisconnect(int client)
//----------------------------------------------------------------------------------------------------
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)
{
@@ -338,9 +360,10 @@ public void OnClientDeath(Event hEvent, const char[] sEvent, bool bDontBroadcast
any itemArray[items];
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_PushArray(itemArray, sizeof(itemArray));
@@ -369,6 +392,7 @@ public Action OnWeaponPickup(int client, int weapon)
if (itemArray[item_weapon] && itemArray[item_weapon] == weapon)
{
itemArray[item_owner] = client;
itemArray[item_owned] = true;
Call_StartForward(g_hFwd_OnClientItemPickup);
Call_PushArray(itemArray, sizeof(itemArray));
@@ -397,7 +421,8 @@ public Action OnWeaponDrop(int client, int 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_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 (HasEntProp(button, Prop_Data, "m_bLocked") &&
GetEntProp(button, Prop_Data, "m_bLocked"))
return Plugin_Handled;
for (int index; index < g_hArray_Items.Length; index++)
{
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_owner] && itemArray[item_owner] == client)
if (itemArray[item_owned] && itemArray[item_owner] == client)
{
Action aResult;
Call_StartForward(g_hFwd_OnClientItemCanActivate);
@@ -574,7 +603,7 @@ public int Native_GetItemArray(Handle hPlugin, int numParams)
int index = GetNativeCell(1);
int size = GetNativeCell(3);
g_hArray_Items.GetArray(index, itemArray, size);
SetNativeArray(2, itemArray, size);