entWatch4: Update to class instead of struct enum.
And some other cleanup stuff.
This commit is contained in:
parent
5c37acb50e
commit
2238db206c
298
_entWatch4/scripting/CItem.inc
Normal file
298
_entWatch4/scripting/CItem.inc
Normal file
@ -0,0 +1,298 @@
|
||||
#if defined entWatch_class_item_included
|
||||
#endinput
|
||||
#endif
|
||||
|
||||
#define entWatch_class_item_included
|
||||
|
||||
methodmap CItem < Basic
|
||||
{
|
||||
public CItem()
|
||||
{
|
||||
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("iOwner", INVALID_ENT_REFERENCE);
|
||||
myclass.SetInt("iButton", INVALID_ENT_REFERENCE);
|
||||
myclass.SetInt("iWeapon", INVALID_ENT_REFERENCE);
|
||||
myclass.SetInt("iTrigger", INVALID_ENT_REFERENCE);
|
||||
|
||||
myclass.SetInt("iDisplay", 0);
|
||||
myclass.SetInt("iMode", 0);
|
||||
|
||||
myclass.SetInt("iMaxUses", 0);
|
||||
myclass.SetInt("iCooldown", 0);
|
||||
|
||||
myclass.SetInt("iTimesUsed", 0);
|
||||
myclass.SetInt("iTimeReady", 0);
|
||||
|
||||
return view_as<CItem>(myclass);
|
||||
}
|
||||
|
||||
|
||||
public bool GetName(char[] buffer, int length)
|
||||
{
|
||||
return this.GetString("sName", buffer, length);
|
||||
}
|
||||
|
||||
public void SetName(const char[] buffer)
|
||||
{
|
||||
this.SetString("sName", buffer);
|
||||
}
|
||||
|
||||
public bool GetShort(char[] buffer, int length)
|
||||
{
|
||||
return this.GetString("sShort", buffer, length);
|
||||
}
|
||||
|
||||
public void SetShort(const char[] buffer)
|
||||
{
|
||||
this.SetString("sShort", buffer);
|
||||
}
|
||||
|
||||
public bool GetColor(char[] buffer, int length)
|
||||
{
|
||||
return this.GetString("sColor", buffer, length);
|
||||
}
|
||||
|
||||
public void SetColor(const char[] buffer)
|
||||
{
|
||||
this.SetString("sColor", buffer);
|
||||
}
|
||||
|
||||
public bool GetFilter(char[] buffer, int length)
|
||||
{
|
||||
return this.GetString("sFilter", buffer, length);
|
||||
}
|
||||
|
||||
public void SetFilter(const char[] buffer)
|
||||
{
|
||||
this.SetString("sFilter", buffer);
|
||||
}
|
||||
|
||||
|
||||
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 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 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 iMaxUses
|
||||
{
|
||||
public get()
|
||||
{
|
||||
return this.GetInt("iMaxUses");
|
||||
}
|
||||
public set(int value)
|
||||
{
|
||||
this.SetInt("iMaxUses", value);
|
||||
}
|
||||
}
|
||||
|
||||
property int iCooldown
|
||||
{
|
||||
public get()
|
||||
{
|
||||
return this.GetInt("iCooldown");
|
||||
}
|
||||
public set(int value)
|
||||
{
|
||||
this.SetInt("iCooldown", value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
property int iTimesUsed
|
||||
{
|
||||
public get()
|
||||
{
|
||||
return this.GetInt("iTimesUsed");
|
||||
}
|
||||
public set(int value)
|
||||
{
|
||||
this.SetInt("iTimesUsed", value);
|
||||
}
|
||||
}
|
||||
|
||||
property int iTimeReady
|
||||
{
|
||||
public get()
|
||||
{
|
||||
return this.GetInt("iTimeReady");
|
||||
}
|
||||
public set(int value)
|
||||
{
|
||||
this.SetInt("iTimeReady", value);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
property bool bOwner
|
||||
{
|
||||
public get()
|
||||
{
|
||||
return view_as<bool>(this.iOwner != INVALID_ENT_REFERENCE);
|
||||
}
|
||||
}
|
||||
|
||||
property bool bButton
|
||||
{
|
||||
public get()
|
||||
{
|
||||
return view_as<bool>(this.iButton != INVALID_ENT_REFERENCE);
|
||||
}
|
||||
}
|
||||
|
||||
property bool bWeapon
|
||||
{
|
||||
public get()
|
||||
{
|
||||
return view_as<bool>(this.iWeapon != INVALID_ENT_REFERENCE);
|
||||
}
|
||||
}
|
||||
|
||||
property bool bTrigger
|
||||
{
|
||||
public get()
|
||||
{
|
||||
return view_as<bool>(this.iTrigger != INVALID_ENT_REFERENCE);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
property bool bDisplayEventMessages
|
||||
{
|
||||
public get()
|
||||
{
|
||||
return view_as<bool>(this.iDisplay & (1<<0));
|
||||
}
|
||||
}
|
||||
|
||||
property bool bDisplayActivateMessages
|
||||
{
|
||||
public get()
|
||||
{
|
||||
return view_as<bool>(this.iDisplay & (1<<1));
|
||||
}
|
||||
}
|
||||
|
||||
property bool bDisplayInterface
|
||||
{
|
||||
public get()
|
||||
{
|
||||
return view_as<bool>(this.iDisplay & (1<<2));
|
||||
}
|
||||
}
|
||||
}
|
@ -12,7 +12,10 @@
|
||||
#include <sourcemod>
|
||||
#include <sdkhooks>
|
||||
#include <sdktools>
|
||||
#include <entWatch_core>
|
||||
#include <basic>
|
||||
|
||||
/* CLASSES */
|
||||
#include "CItem.inc"
|
||||
|
||||
/* BOOLS */
|
||||
bool g_bLate;
|
||||
@ -20,7 +23,7 @@ bool g_bIntermission;
|
||||
|
||||
/* ARRAYS */
|
||||
ArrayList g_hArray_Items;
|
||||
ArrayList g_hArray_Config;
|
||||
ArrayList g_hArray_Configs;
|
||||
|
||||
/* FORWARDS */
|
||||
Handle g_hFwd_OnClientItemDrop;
|
||||
@ -52,8 +55,6 @@ public APLRes AskPluginLoad2(Handle hMyself, bool bLate, char[] sError, int erro
|
||||
g_bLate = bLate;
|
||||
|
||||
CreateNative("EW_GetItemCount", Native_GetItemCount);
|
||||
CreateNative("EW_GetItemArray", Native_GetItemArray);
|
||||
CreateNative("EW_SetItemArray", Native_SetItemArray);
|
||||
|
||||
RegPluginLibrary("entWatch-core");
|
||||
return APLRes_Success;
|
||||
@ -64,17 +65,17 @@ public APLRes AskPluginLoad2(Handle hMyself, bool bLate, char[] sError, int erro
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnPluginStart()
|
||||
{
|
||||
g_hFwd_OnClientItemDrop = CreateGlobalForward("EW_OnClientItemDrop", ET_Ignore, Param_Array, Param_Cell, Param_Cell);
|
||||
g_hFwd_OnClientItemDeath = CreateGlobalForward("EW_OnClientItemDeath", ET_Ignore, Param_Array, Param_Cell, Param_Cell);
|
||||
g_hFwd_OnClientItemPickup = CreateGlobalForward("EW_OnClientItemPickup", ET_Ignore, Param_Array, Param_Cell, Param_Cell);
|
||||
g_hFwd_OnClientItemActivate = CreateGlobalForward("EW_OnClientItemActivate", ET_Ignore, Param_Array, Param_Cell, Param_Cell);
|
||||
g_hFwd_OnClientItemDisconnect = CreateGlobalForward("EW_OnClientItemDisconnect", ET_Ignore, Param_Array, Param_Cell, Param_Cell);
|
||||
g_hFwd_OnClientItemDrop = CreateGlobalForward("EW_OnClientItemDrop", ET_Ignore, Param_Cell, Param_Cell);
|
||||
g_hFwd_OnClientItemDeath = CreateGlobalForward("EW_OnClientItemDeath", ET_Ignore, Param_Cell, Param_Cell);
|
||||
g_hFwd_OnClientItemPickup = CreateGlobalForward("EW_OnClientItemPickup", ET_Ignore, Param_Cell, Param_Cell);
|
||||
g_hFwd_OnClientItemActivate = CreateGlobalForward("EW_OnClientItemActivate", ET_Ignore, Param_Cell, Param_Cell);
|
||||
g_hFwd_OnClientItemDisconnect = CreateGlobalForward("EW_OnClientItemDisconnect", ET_Ignore, Param_Cell, Param_Cell);
|
||||
|
||||
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_hFwd_OnClientItemCanPickup = CreateGlobalForward("EW_OnClientItemCanPickup", ET_Hook, Param_Cell, Param_Cell);
|
||||
g_hFwd_OnClientItemCanActivate = CreateGlobalForward("EW_OnClientItemCanActivate", ET_Hook, Param_Cell, Param_Cell);
|
||||
|
||||
g_hArray_Items = new ArrayList(512);
|
||||
g_hArray_Config = new ArrayList(512);
|
||||
g_hArray_Items = new ArrayList();
|
||||
g_hArray_Configs = new ArrayList();
|
||||
|
||||
HookEvent("player_death", OnClientDeath);
|
||||
HookEvent("round_start", OnRoundStart);
|
||||
@ -100,7 +101,7 @@ public void OnPluginStart()
|
||||
public void OnMapStart()
|
||||
{
|
||||
g_hArray_Items.Clear();
|
||||
g_hArray_Config.Clear();
|
||||
g_hArray_Configs.Clear();
|
||||
|
||||
char sCurrentMap[128];
|
||||
GetCurrentMap(sCurrentMap, sizeof(sCurrentMap));
|
||||
@ -141,21 +142,28 @@ public void OnMapStart()
|
||||
{
|
||||
do
|
||||
{
|
||||
any itemArray[items];
|
||||
hConfig.GetString("name", itemArray[item_name], sizeof(itemArray[item_name]));
|
||||
hConfig.GetString("short", itemArray[item_short], sizeof(itemArray[item_short]));
|
||||
hConfig.GetString("color", itemArray[item_color], sizeof(itemArray[item_color]));
|
||||
hConfig.GetString("filter", itemArray[item_filter], sizeof(itemArray[item_filter]));
|
||||
CItem item = new CItem();
|
||||
|
||||
itemArray[item_weaponid] = hConfig.GetNum("weaponid");
|
||||
itemArray[item_buttonid] = hConfig.GetNum("buttonid");
|
||||
itemArray[item_triggerid] = hConfig.GetNum("triggerid");
|
||||
itemArray[item_display] = hConfig.GetNum("display");
|
||||
itemArray[item_mode] = hConfig.GetNum("mode");
|
||||
itemArray[item_maxuses] = hConfig.GetNum("maxuses");
|
||||
itemArray[item_cooldown] = hConfig.GetNum("cooldown");
|
||||
char sName[64], sShort[64], sColor[64], sFilter[64];
|
||||
hConfig.GetString("name", sName, sizeof(sName));
|
||||
hConfig.GetString("short", sShort, sizeof(sShort));
|
||||
hConfig.GetString("color", sColor, sizeof(sColor));
|
||||
hConfig.GetString("filter", sFilter, sizeof(sFilter));
|
||||
|
||||
g_hArray_Config.PushArray(itemArray, sizeof(itemArray));
|
||||
item.SetName(sName);
|
||||
item.SetShort(sShort);
|
||||
item.SetColor(sColor);
|
||||
item.SetFilter(sFilter);
|
||||
|
||||
item.iWeaponID = hConfig.GetNum("weaponid");
|
||||
item.iButtonID = hConfig.GetNum("buttonid");
|
||||
item.iTriggerID = hConfig.GetNum("triggerid");
|
||||
item.iDisplay = hConfig.GetNum("display");
|
||||
item.iMode = hConfig.GetNum("mode");
|
||||
item.iMaxUses = hConfig.GetNum("maxuses");
|
||||
item.iCooldown = hConfig.GetNum("cooldown");
|
||||
|
||||
g_hArray_Configs.Push(item);
|
||||
}
|
||||
while (hConfig.GotoNextKey());
|
||||
}
|
||||
@ -180,7 +188,7 @@ public void OnRoundEnd(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
if (g_hArray_Items.Length)
|
||||
g_hArray_Items.Clear();
|
||||
|
||||
G_bIntermission = true;
|
||||
g_bIntermission = true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
@ -199,28 +207,26 @@ public void OnEntityCreated(int entity, const char[] sClassname)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnEntitySpawned(int entity)
|
||||
{
|
||||
if (Entity_IsValid(entity) && g_hArray_Config.Length)
|
||||
if (Entity_IsValid(entity) && g_hArray_Configs.Length)
|
||||
{
|
||||
for (int index; index < g_hArray_Items.Length; index++)
|
||||
{
|
||||
any itemArray[items];
|
||||
g_hArray_Items.GetArray(index, itemArray, sizeof(itemArray));
|
||||
CItem item = g_hArray_Items.Get(index);
|
||||
|
||||
if (RegisterItem(itemArray, entity))
|
||||
if (RegisterItem(item, entity))
|
||||
{
|
||||
g_hArray_Items.SetArray(index, itemArray, sizeof(itemArray));
|
||||
g_hArray_Items.Set(index, item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (int index; index < g_hArray_Config.Length; index++)
|
||||
for (int index; index < g_hArray_Configs.Length; index++)
|
||||
{
|
||||
any itemArray[items];
|
||||
g_hArray_Config.GetArray(index, itemArray, sizeof(itemArray));
|
||||
CItem item = g_hArray_Configs.Get(index);
|
||||
|
||||
if (RegisterItem(itemArray, entity))
|
||||
if (RegisterItem(item, entity))
|
||||
{
|
||||
g_hArray_Items.PushArray(itemArray, sizeof(itemArray));
|
||||
g_hArray_Items.Push(item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -230,39 +236,37 @@ public void OnEntitySpawned(int entity)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
stock bool RegisterItem(any[] itemArray, int entity)
|
||||
stock bool RegisterItem(CItem item, int entity)
|
||||
{
|
||||
if (Entity_IsValid(entity))
|
||||
{
|
||||
if (itemArray[item_weaponid] && itemArray[item_weaponid] == Entity_GetHammerId(entity))
|
||||
if (item.iWeaponID && item.iWeaponID == Entity_GetHammerId(entity))
|
||||
{
|
||||
if (!itemArray[item_weapon] && (Entity_GetOwner(entity) == INVALID_ENT_REFERENCE))
|
||||
if (!item.bWeapon && (Entity_GetOwner(entity) == INVALID_ENT_REFERENCE))
|
||||
{
|
||||
itemArray[item_weapon] = entity;
|
||||
item.iWeapon = entity;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (itemArray[item_buttonid] && itemArray[item_buttonid] == Entity_GetHammerId(entity))
|
||||
else if (item.iButtonID && item.iButtonID == Entity_GetHammerId(entity))
|
||||
{
|
||||
if (!itemArray[item_button] && (Entity_GetParent(entity) == INVALID_ENT_REFERENCE ||
|
||||
(itemArray[item_weapon] && Entity_GetParent(entity) == itemArray[item_weapon])))
|
||||
if (!item.bButton && (Entity_GetParent(entity) == INVALID_ENT_REFERENCE || (item.bWeapon && Entity_GetParent(entity) == item.iWeapon)))
|
||||
{
|
||||
SDKHook(entity, SDKHook_Use, OnButtonPress);
|
||||
|
||||
itemArray[item_button] = entity;
|
||||
item.iButton = entity;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (itemArray[item_triggerid] && itemArray[item_triggerid] == Entity_GetHammerId(entity))
|
||||
else if (item.iTriggerID && item.iTriggerID == Entity_GetHammerId(entity))
|
||||
{
|
||||
if (!itemArray[item_trigger] && (Entity_GetParent(entity) == INVALID_ENT_REFERENCE ||
|
||||
(itemArray[item_weapon] && Entity_GetParent(entity) == itemArray[item_weapon])))
|
||||
if (!item.bTrigger && (Entity_GetParent(entity) == INVALID_ENT_REFERENCE || (item.bWeapon && Entity_GetParent(entity) == item.iWeapon)))
|
||||
{
|
||||
SDKHook(entity, SDKHook_StartTouch, OnTriggerTouch);
|
||||
SDKHook(entity, SDKHook_EndTouch, OnTriggerTouch);
|
||||
SDKHook(entity, SDKHook_Touch, OnTriggerTouch);
|
||||
|
||||
itemArray[item_trigger] = entity;
|
||||
item.iTrigger = entity;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -279,28 +283,27 @@ public void OnEntityDestroyed(int entity)
|
||||
{
|
||||
for (int index; index < g_hArray_Items.Length; index++)
|
||||
{
|
||||
any itemArray[items];
|
||||
g_hArray_Items.GetArray(index, itemArray, sizeof(itemArray));
|
||||
CItem item = g_hArray_Items.Get(index);
|
||||
|
||||
if (itemArray[item_weapon] && itemArray[item_weapon] == entity)
|
||||
if (item.bWeapon && item.iWeapon == entity)
|
||||
{
|
||||
g_hArray_Items.Erase(index);
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemArray[item_button] && itemArray[item_button] == entity)
|
||||
if (item.bButton && item.iButton == entity)
|
||||
{
|
||||
itemArray[item_button] = INVALID_ENT_REFERENCE;
|
||||
item.iButton = INVALID_ENT_REFERENCE;
|
||||
|
||||
g_hArray_Items.SetArray(index, itemArray, sizeof(itemArray));
|
||||
g_hArray_Items.Set(index, item);
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemArray[item_trigger] && itemArray[item_trigger] == entity)
|
||||
if (item.bTrigger && item.iTrigger == entity)
|
||||
{
|
||||
itemArray[item_trigger] = INVALID_ENT_REFERENCE;
|
||||
item.iTrigger = INVALID_ENT_REFERENCE;
|
||||
|
||||
g_hArray_Items.SetArray(index, itemArray, sizeof(itemArray));
|
||||
g_hArray_Items.Set(index, item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -329,21 +332,18 @@ public void OnClientDisconnect(int client)
|
||||
{
|
||||
for (int index; index < g_hArray_Items.Length; index++)
|
||||
{
|
||||
any itemArray[items];
|
||||
g_hArray_Items.GetArray(index, itemArray, sizeof(itemArray));
|
||||
CItem item = g_hArray_Items.Get(index);
|
||||
|
||||
if (itemArray[item_owned] && itemArray[item_owner] == client)
|
||||
if (item.bOwner && item.iOwner == client)
|
||||
{
|
||||
itemArray[item_owner] = INVALID_ENT_REFERENCE;
|
||||
itemArray[item_owned] = false;
|
||||
item.iOwner = INVALID_ENT_REFERENCE;
|
||||
|
||||
Call_StartForward(g_hFwd_OnClientItemDisconnect);
|
||||
Call_PushArray(itemArray, sizeof(itemArray));
|
||||
Call_PushCell(client);
|
||||
Call_PushCell(index);
|
||||
Call_Finish();
|
||||
|
||||
g_hArray_Items.SetArray(index, itemArray, sizeof(itemArray));
|
||||
g_hArray_Items.Set(index, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -360,21 +360,18 @@ public void OnClientDeath(Event hEvent, const char[] sEvent, bool bDontBroadcast
|
||||
{
|
||||
for (int index; index < g_hArray_Items.Length; index++)
|
||||
{
|
||||
any itemArray[items];
|
||||
g_hArray_Items.GetArray(index, itemArray, sizeof(itemArray));
|
||||
CItem item = g_hArray_Items.Get(index);
|
||||
|
||||
if (itemArray[item_owned] && itemArray[item_owner] == client)
|
||||
if (item.bOwner && item.iOwner == client)
|
||||
{
|
||||
itemArray[item_owner] = INVALID_ENT_REFERENCE;
|
||||
itemArray[item_owned] = false;
|
||||
item.iOwner = INVALID_ENT_REFERENCE;
|
||||
|
||||
Call_StartForward(g_hFwd_OnClientItemDeath);
|
||||
Call_PushArray(itemArray, sizeof(itemArray));
|
||||
Call_PushCell(client);
|
||||
Call_PushCell(index);
|
||||
Call_Finish();
|
||||
|
||||
g_hArray_Items.SetArray(index, itemArray, sizeof(itemArray));
|
||||
g_hArray_Items.Set(index, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -389,21 +386,18 @@ public Action OnWeaponPickup(int client, int weapon)
|
||||
{
|
||||
for (int index; index < g_hArray_Items.Length; index++)
|
||||
{
|
||||
any itemArray[items];
|
||||
g_hArray_Items.GetArray(index, itemArray, sizeof(itemArray));
|
||||
CItem item = g_hArray_Items.Get(index);
|
||||
|
||||
if (itemArray[item_weapon] && itemArray[item_weapon] == weapon)
|
||||
if (item.bWeapon && item.iWeapon == weapon)
|
||||
{
|
||||
itemArray[item_owner] = client;
|
||||
itemArray[item_owned] = true;
|
||||
item.iOwner = client;
|
||||
|
||||
Call_StartForward(g_hFwd_OnClientItemPickup);
|
||||
Call_PushArray(itemArray, sizeof(itemArray));
|
||||
Call_PushCell(client);
|
||||
Call_PushCell(index);
|
||||
Call_Finish();
|
||||
|
||||
g_hArray_Items.SetArray(index, itemArray, sizeof(itemArray));
|
||||
g_hArray_Items.Set(index, item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -419,21 +413,18 @@ public Action OnWeaponDrop(int client, int weapon)
|
||||
{
|
||||
for (int index; index < g_hArray_Items.Length; index++)
|
||||
{
|
||||
any itemArray[items];
|
||||
g_hArray_Items.GetArray(index, itemArray, sizeof(itemArray));
|
||||
CItem item = g_hArray_Items.Get(index);
|
||||
|
||||
if (itemArray[item_weapon] && itemArray[item_weapon] == weapon)
|
||||
if (item.bWeapon && item.iWeapon == weapon)
|
||||
{
|
||||
itemArray[item_owner] = INVALID_ENT_REFERENCE;
|
||||
itemArray[item_owned] = false;
|
||||
item.iOwner = INVALID_ENT_REFERENCE;
|
||||
|
||||
Call_StartForward(g_hFwd_OnClientItemDrop);
|
||||
Call_PushArray(itemArray, sizeof(itemArray));
|
||||
Call_PushCell(client);
|
||||
Call_PushCell(index);
|
||||
Call_Finish();
|
||||
|
||||
g_hArray_Items.SetArray(index, itemArray, sizeof(itemArray));
|
||||
g_hArray_Items.Set(index, item);
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -453,75 +444,72 @@ public Action OnButtonPress(int button, int client)
|
||||
|
||||
for (int index; index < g_hArray_Items.Length; index++)
|
||||
{
|
||||
any itemArray[items];
|
||||
g_hArray_Items.GetArray(index, itemArray, sizeof(itemArray));
|
||||
CItem item = g_hArray_Items.Get(index);
|
||||
|
||||
if (itemArray[item_button] && itemArray[item_button] == button &&
|
||||
itemArray[item_owned] && itemArray[item_owner] == client)
|
||||
if (item.bButton && item.iButton == button && item.bOwner && item.iOwner == client)
|
||||
{
|
||||
Action aResult;
|
||||
Call_StartForward(g_hFwd_OnClientItemCanActivate);
|
||||
Call_PushArray(itemArray, sizeof(itemArray));
|
||||
Call_PushCell(client);
|
||||
Call_PushCell(index);
|
||||
Call_Finish(aResult);
|
||||
|
||||
if ((aResult == Plugin_Continue) || (aResult == Plugin_Changed))
|
||||
{
|
||||
switch(itemArray[item_mode])
|
||||
switch(item.iMode)
|
||||
{
|
||||
case(1):
|
||||
{
|
||||
if (itemArray[item_nextuse] < RoundToCeil(GetEngineTime()))
|
||||
if (item.iTimeReady < RoundToCeil(GetEngineTime()))
|
||||
{
|
||||
itemArray[item_nextuse] = RoundToCeil(GetEngineTime()) + itemArray[item_cooldown];
|
||||
item.iTimeReady = RoundToCeil(GetEngineTime()) + item.iCooldown;
|
||||
}
|
||||
else return Plugin_Handled;
|
||||
}
|
||||
case(2):
|
||||
{
|
||||
if (itemArray[item_uses] < itemArray[item_maxuses])
|
||||
if (item.iTimesUsed < item.iMaxUses)
|
||||
{
|
||||
itemArray[item_uses]++;
|
||||
item.iTimesUsed++;
|
||||
}
|
||||
else return Plugin_Handled;
|
||||
}
|
||||
case(3):
|
||||
{
|
||||
if (itemArray[item_nextuse] < RoundToCeil(GetEngineTime()) && itemArray[item_uses] < itemArray[item_maxuses])
|
||||
if (item.iTimeReady < RoundToCeil(GetEngineTime()) && item.iTimesUsed < item.iMaxUses)
|
||||
{
|
||||
itemArray[item_nextuse] = RoundToCeil(GetEngineTime()) + itemArray[item_cooldown];
|
||||
itemArray[item_uses]++;
|
||||
item.iTimeReady = RoundToCeil(GetEngineTime()) + item.iCooldown;
|
||||
item.iTimesUsed++;
|
||||
}
|
||||
else return Plugin_Handled;
|
||||
}
|
||||
case(4):
|
||||
{
|
||||
if (itemArray[item_nextuse] < RoundToCeil(GetEngineTime()))
|
||||
if (item.iTimeReady < RoundToCeil(GetEngineTime()))
|
||||
{
|
||||
itemArray[item_uses]++;
|
||||
item.iTimesUsed++;
|
||||
|
||||
if (itemArray[item_uses] >= itemArray[item_maxuses])
|
||||
if (item.iTimesUsed >= item.iMaxUses)
|
||||
{
|
||||
itemArray[item_nextuse] = RoundToCeil(GetEngineTime()) + itemArray[item_cooldown];
|
||||
itemArray[item_uses] = 0;
|
||||
item.iTimeReady = RoundToCeil(GetEngineTime()) + item.iCooldown;
|
||||
item.iTimesUsed = 0;
|
||||
}
|
||||
}
|
||||
else return Plugin_Handled;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemArray[item_filter][0])
|
||||
Entity_SetName(client, itemArray[item_filter]);
|
||||
char sFilter[64];
|
||||
if (item.GetFilter(sFilter, sizeof(sFilter)))
|
||||
Entity_SetName(client, sFilter);
|
||||
|
||||
Call_StartForward(g_hFwd_OnClientItemActivate);
|
||||
Call_PushArray(itemArray, sizeof(itemArray));
|
||||
Call_PushCell(client);
|
||||
Call_PushCell(index);
|
||||
Call_Finish();
|
||||
}
|
||||
|
||||
g_hArray_Items.SetArray(index, itemArray, sizeof(itemArray));
|
||||
g_hArray_Items.Set(index, item);
|
||||
return aResult;
|
||||
}
|
||||
}
|
||||
@ -538,22 +526,20 @@ public Action OnTriggerTouch(int trigger, int client)
|
||||
{
|
||||
for (int index; index < g_hArray_Items.Length; index++)
|
||||
{
|
||||
any itemArray[items];
|
||||
g_hArray_Items.GetArray(index, itemArray, sizeof(itemArray));
|
||||
CItem item = g_hArray_Items.Get(index);
|
||||
|
||||
if (itemArray[item_trigger] && itemArray[item_trigger] == trigger)
|
||||
if (item.bTrigger && item.iTrigger == trigger)
|
||||
{
|
||||
if (g_bIntermission)
|
||||
return Plugin_Handled;
|
||||
|
||||
Action aResult;
|
||||
Call_StartForward(g_hFwd_OnClientItemCanPickup);
|
||||
Call_PushArray(itemArray, sizeof(itemArray));
|
||||
Call_PushCell(client);
|
||||
Call_PushCell(index);
|
||||
Call_Finish(aResult);
|
||||
|
||||
g_hArray_Items.SetArray(index, itemArray, sizeof(itemArray));
|
||||
g_hArray_Items.Set(index, item);
|
||||
return aResult;
|
||||
}
|
||||
}
|
||||
@ -570,22 +556,20 @@ public Action OnWeaponTouch(int client, int weapon)
|
||||
{
|
||||
for (int index; index < g_hArray_Items.Length; index++)
|
||||
{
|
||||
any itemArray[items];
|
||||
g_hArray_Items.GetArray(index, itemArray, sizeof(itemArray));
|
||||
CItem item = g_hArray_Items.Get(index);
|
||||
|
||||
if (itemArray[item_weapon] && itemArray[item_weapon] == weapon)
|
||||
if (item.bWeapon && item.iWeapon == weapon)
|
||||
{
|
||||
if (g_bIntermission)
|
||||
return Plugin_Handled;
|
||||
|
||||
Action aResult;
|
||||
Call_StartForward(g_hFwd_OnClientItemCanPickup);
|
||||
Call_PushArray(itemArray, sizeof(itemArray));
|
||||
Call_PushCell(client);
|
||||
Call_PushCell(index);
|
||||
Call_Finish(aResult);
|
||||
|
||||
g_hArray_Items.SetArray(index, itemArray, sizeof(itemArray));
|
||||
g_hArray_Items.Set(index, item);
|
||||
return aResult;
|
||||
}
|
||||
}
|
||||
@ -599,34 +583,4 @@ public Action OnWeaponTouch(int client, int weapon)
|
||||
public int Native_GetItemCount(Handle hPlugin, int numParams)
|
||||
{
|
||||
return g_hArray_Items.Length;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public int Native_GetItemArray(Handle hPlugin, int numParams)
|
||||
{
|
||||
any itemArray[items];
|
||||
|
||||
int index = GetNativeCell(1);
|
||||
int size = GetNativeCell(3);
|
||||
|
||||
g_hArray_Items.GetArray(index, itemArray, size);
|
||||
|
||||
SetNativeArray(2, itemArray, size);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public int Native_SetItemArray(Handle hPlugin, int numParams)
|
||||
{
|
||||
any itemArray[items];
|
||||
|
||||
int index = GetNativeCell(1);
|
||||
int size = GetNativeCell(3);
|
||||
|
||||
GetNativeArray(2, itemArray, size);
|
||||
|
||||
g_hArray_Items.SetArray(index, itemArray, size);
|
||||
}
|
@ -34,35 +34,35 @@ public void OnPluginStart()
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void EW_OnClientItemDrop(any[] itemArray, int client, int index)
|
||||
public void EW_OnClientItemDrop(int client, int index)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void EW_OnClientItemDeath(any[] itemArray, int client, int index)
|
||||
public void EW_OnClientItemDeath(int client, int index)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void EW_OnClientItemPickup(any[] itemArray, int client, int index)
|
||||
public void EW_OnClientItemPickup(int client, int index)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void EW_OnClientItemDisconnect(any[] itemArray, int client, int index)
|
||||
public void EW_OnClientItemDisconnect(int client, int index)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void EW_OnClientItemActivate(any[] itemArray, int client, int index)
|
||||
public void EW_OnClientItemActivate(int client, int index)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -160,7 +160,7 @@ public Action Command_ClientUnrestrict(int client, int args)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action EW_OnClientItemCanPickup(any[] itemArray, int client, int index)
|
||||
public Action EW_OnClientItemCanPickup(int client, int index)
|
||||
{
|
||||
return ClientRestricted(client)?Plugin_Handled:Plugin_Continue;
|
||||
}
|
||||
@ -168,7 +168,7 @@ public Action EW_OnClientItemCanPickup(any[] itemArray, int client, int index)
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action EW_OnClientItemCanActivate(any[] itemArray, int client, int index)
|
||||
public Action EW_OnClientItemCanActivate(int client, int index)
|
||||
{
|
||||
return ClientRestricted(client)?Plugin_Handled:Plugin_Continue;
|
||||
}
|
||||
|
@ -4,46 +4,6 @@
|
||||
|
||||
#define entWatch_core_included
|
||||
|
||||
#define DISPLAY_CHAT (1 << 0)
|
||||
#define DISPLAY_HUD (1 << 1)
|
||||
#define DISPLAY_USE (1 << 2)
|
||||
|
||||
enum items
|
||||
{
|
||||
String:item_name[32],
|
||||
String:item_short[32],
|
||||
String:item_color[32],
|
||||
String:item_filter[32],
|
||||
bool:item_owned,
|
||||
item_buttonid,
|
||||
item_weaponid,
|
||||
item_triggerid,
|
||||
item_owner,
|
||||
item_button,
|
||||
item_weapon,
|
||||
item_trigger,
|
||||
item_display,
|
||||
item_mode,
|
||||
item_uses,
|
||||
item_maxuses,
|
||||
item_nextuse,
|
||||
item_cooldown,
|
||||
};
|
||||
|
||||
native int EW_GetItemCount();
|
||||
|
||||
native void EW_GetItemArray(int index, any[] itemArray, int size);
|
||||
native void EW_SetItemArray(int index, any[] itemArray, int size);
|
||||
|
||||
forward void EW_OnClientItemDrop(any[] itemArray, int client, int index);
|
||||
forward void EW_OnClientItemDeath(any[] itemArray, int client, int index);
|
||||
forward void EW_OnClientItemPickup(any[] itemArray, int client, int index);
|
||||
forward void EW_OnClientItemActivate(any[] itemArray, int client, int index);
|
||||
forward void EW_OnClientItemDisconnect(any[] itemArray, int client, int index);
|
||||
|
||||
forward Action EW_OnClientItemCanPickup(any[] itemArray, int client, int index);
|
||||
forward Action EW_OnClientItemCanActivate(any[] itemArray, int client, int index);
|
||||
|
||||
public SharedPlugin __pl_entWatch_core =
|
||||
{
|
||||
name = "entWatch-core",
|
||||
@ -60,7 +20,16 @@ public SharedPlugin __pl_entWatch_core =
|
||||
public void __pl_entWatch_core_SetNTVOptional()
|
||||
{
|
||||
MarkNativeAsOptional("EW_GetItemCount");
|
||||
MarkNativeAsOptional("EW_GetItemArray");
|
||||
MarkNativeAsOptional("EW_SetItemArray");
|
||||
}
|
||||
#endif
|
||||
#endif
|
||||
|
||||
native int EW_GetItemCount();
|
||||
|
||||
forward void EW_OnClientItemDrop(int client, int index);
|
||||
forward void EW_OnClientItemDeath(int client, int index);
|
||||
forward void EW_OnClientItemPickup(int client, int index);
|
||||
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);
|
@ -8,7 +8,7 @@ public SharedPlugin __pl_entWatch_core =
|
||||
{
|
||||
name = "entWatch-restrictions",
|
||||
file = "entWatch-restrictions.smx",
|
||||
|
||||
|
||||
#if defined REQUIRE_PLUGIN
|
||||
required = 1
|
||||
#else
|
||||
|
Loading…
Reference in New Issue
Block a user