Add entWatch4
This is still a beta thing. ¯\_(ツ)_/¯
This commit is contained in:
parent
f5265b9612
commit
08ac49923d
596
entWatch4/scripting/entWatch-core.sp
Normal file
596
entWatch4/scripting/entWatch-core.sp
Normal file
@ -0,0 +1,596 @@
|
||||
//====================================================================================================
|
||||
//
|
||||
// Name: [entWatch] Core
|
||||
// Author: zaCade & Prometheum
|
||||
// Description: Handle the core functions of [entWatch]
|
||||
//
|
||||
//====================================================================================================
|
||||
#include <smlib>
|
||||
|
||||
#pragma newdecls required
|
||||
|
||||
#include <sourcemod>
|
||||
#include <sdkhooks>
|
||||
#include <entWatch>
|
||||
|
||||
/* BOOLS */
|
||||
bool g_bLate;
|
||||
|
||||
/* HANDLES */
|
||||
ArrayList g_hArray_Items;
|
||||
ArrayList g_hArray_Config;
|
||||
|
||||
/* FORWARDS */
|
||||
Handle g_hFwd_OnClientItemDrop;
|
||||
Handle g_hFwd_OnClientItemDeath;
|
||||
Handle g_hFwd_OnClientItemPickup;
|
||||
Handle g_hFwd_OnClientItemActivate;
|
||||
Handle g_hFwd_OnClientItemDisconnect;
|
||||
|
||||
/* HOOKS */
|
||||
Handle g_hFwd_OnClientItemCanPickup;
|
||||
Handle g_hFwd_OnClientItemCanActivate;
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "[entWatch] Core",
|
||||
author = "zaCade & Prometheum",
|
||||
description = "Handle the core functions of [entWatch]",
|
||||
version = "4.0.0"
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public APLRes AskPluginLoad2(Handle hMyself, bool bLate, char[] sError, int errorSize)
|
||||
{
|
||||
g_bLate = bLate;
|
||||
|
||||
CreateNative("EW_GetItemCount", Native_GetItemCount);
|
||||
CreateNative("EW_GetItemArray", Native_GetItemArray);
|
||||
CreateNative("EW_SetItemArray", Native_SetItemArray);
|
||||
|
||||
RegPluginLibrary("entWatch-core");
|
||||
return APLRes_Success;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
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_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);
|
||||
|
||||
if (g_bLate)
|
||||
{
|
||||
for (int client = 1; client <= MaxClients; client++)
|
||||
{
|
||||
if (!IsClientInGame(client) || IsFakeClient(client))
|
||||
continue;
|
||||
|
||||
SDKHook(client, SDKHook_WeaponEquipPost, OnWeaponPickup);
|
||||
SDKHook(client, SDKHook_WeaponDropPost, OnWeaponDrop);
|
||||
SDKHook(client, SDKHook_WeaponCanUse, OnWeaponTouch);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnMapStart()
|
||||
{
|
||||
g_hArray_Items.Clear();
|
||||
g_hArray_Config.Clear();
|
||||
|
||||
char sCurrentMap[128];
|
||||
GetCurrentMap(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);
|
||||
|
||||
KeyValues hConfig = new KeyValues("items");
|
||||
|
||||
if (FileExists(sFilePathOverride))
|
||||
{
|
||||
if (!hConfig.ImportFromFile(sFilePathOverride))
|
||||
{
|
||||
LogMessage("Unable to load config \"%s\"!", sFilePathOverride);
|
||||
|
||||
delete hConfig;
|
||||
return;
|
||||
}
|
||||
else LogMessage("Loaded config \"%s\"", sFilePathOverride);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!hConfig.ImportFromFile(sFilePathDefault))
|
||||
{
|
||||
LogMessage("Unable to load config \"%s\"!", sFilePathDefault);
|
||||
|
||||
delete hConfig;
|
||||
return;
|
||||
}
|
||||
else LogMessage("Loaded config \"%s\"", sFilePathDefault);
|
||||
}
|
||||
|
||||
if (hConfig.GotoFirstSubKey())
|
||||
{
|
||||
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]));
|
||||
|
||||
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");
|
||||
|
||||
g_hArray_Config.PushArray(itemArray, sizeof(itemArray));
|
||||
}
|
||||
while (hConfig.GotoNextKey());
|
||||
}
|
||||
|
||||
delete hConfig;
|
||||
return;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnEntityCreated(int entity, const char[] sClassname)
|
||||
{
|
||||
if (Entity_IsValid(entity))
|
||||
{
|
||||
SDKHook(entity, SDKHook_SpawnPost, OnEntitySpawned);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnEntitySpawned(int entity)
|
||||
{
|
||||
if (Entity_IsValid(entity) && g_hArray_Config.Length)
|
||||
{
|
||||
for (int index; index < g_hArray_Items.Length; index++)
|
||||
{
|
||||
any itemArray[items];
|
||||
g_hArray_Items.GetArray(index, itemArray, sizeof(itemArray));
|
||||
|
||||
if (RegisterItem(itemArray, entity))
|
||||
{
|
||||
g_hArray_Items.SetArray(index, itemArray, sizeof(itemArray));
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
for (int index; index < g_hArray_Config.Length; index++)
|
||||
{
|
||||
any itemArray[items];
|
||||
g_hArray_Config.GetArray(index, itemArray, sizeof(itemArray));
|
||||
|
||||
if (RegisterItem(itemArray, entity))
|
||||
{
|
||||
g_hArray_Items.PushArray(itemArray, sizeof(itemArray));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
stock bool RegisterItem(any[] itemArray, int entity)
|
||||
{
|
||||
if (Entity_IsValid(entity))
|
||||
{
|
||||
if (itemArray[item_weaponid] && itemArray[item_weaponid] == Entity_GetHammerId(entity))
|
||||
{
|
||||
if (!itemArray[item_weapon])
|
||||
{
|
||||
itemArray[item_weapon] = entity;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (itemArray[item_buttonid] && itemArray[item_buttonid] == Entity_GetHammerId(entity))
|
||||
{
|
||||
if (!itemArray[item_button] && (Entity_GetParent(entity) == INVALID_ENT_REFERENCE ||
|
||||
(itemArray[item_weapon] && Entity_GetParent(entity) == itemArray[item_weapon])))
|
||||
{
|
||||
SDKHook(entity, SDKHook_Use, OnButtonPress);
|
||||
|
||||
itemArray[item_button] = entity;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
else if (itemArray[item_triggerid] && itemArray[item_triggerid] == Entity_GetHammerId(entity))
|
||||
{
|
||||
if (!itemArray[item_trigger] && (Entity_GetParent(entity) == INVALID_ENT_REFERENCE ||
|
||||
(itemArray[item_weapon] && Entity_GetParent(entity) == itemArray[item_weapon])))
|
||||
{
|
||||
SDKHook(entity, SDKHook_StartTouch, OnTriggerTouch);
|
||||
SDKHook(entity, SDKHook_EndTouch, OnTriggerTouch);
|
||||
SDKHook(entity, SDKHook_Touch, OnTriggerTouch);
|
||||
|
||||
itemArray[item_trigger] = entity;
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnEntityDestroyed(int entity)
|
||||
{
|
||||
if (Entity_IsValid(entity) && 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_weapon] && itemArray[item_weapon] == entity)
|
||||
{
|
||||
g_hArray_Items.Erase(index);
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemArray[item_button] && itemArray[item_button] == entity)
|
||||
{
|
||||
itemArray[item_button] = INVALID_ENT_REFERENCE;
|
||||
|
||||
g_hArray_Items.SetArray(index, itemArray, sizeof(itemArray));
|
||||
return;
|
||||
}
|
||||
|
||||
if (itemArray[item_trigger] && itemArray[item_trigger] == entity)
|
||||
{
|
||||
itemArray[item_trigger] = INVALID_ENT_REFERENCE;
|
||||
|
||||
g_hArray_Items.SetArray(index, itemArray, sizeof(itemArray));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnClientPutInServer(int client)
|
||||
{
|
||||
if (!IsFakeClient(client))
|
||||
{
|
||||
SDKHook(client, SDKHook_WeaponEquipPost, OnWeaponPickup);
|
||||
SDKHook(client, SDKHook_WeaponDropPost, OnWeaponDrop);
|
||||
SDKHook(client, SDKHook_WeaponCanUse, OnWeaponTouch);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnClientDisconnect(int client)
|
||||
{
|
||||
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)
|
||||
{
|
||||
itemArray[item_owner] = 0;
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnClientDeath(Event hEvent, const char[] sEvent, bool bDontBroadcast)
|
||||
{
|
||||
int client = GetClientOfUserId(hEvent.GetInt("userid"))
|
||||
|
||||
if (Client_IsValid(client) && !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)
|
||||
{
|
||||
itemArray[item_owner] = 0;
|
||||
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action OnWeaponPickup(int client, int weapon)
|
||||
{
|
||||
if (Client_IsValid(client) && Entity_IsValid(weapon) && 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_weapon] && itemArray[item_weapon] == weapon)
|
||||
{
|
||||
itemArray[item_owner] = 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));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action OnWeaponDrop(int client, int weapon)
|
||||
{
|
||||
if (Client_IsValid(client) && Entity_IsValid(weapon) && 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_weapon] && itemArray[item_weapon] == weapon)
|
||||
{
|
||||
itemArray[item_owner] = 0;
|
||||
|
||||
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));
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action OnButtonPress(int button, int client)
|
||||
{
|
||||
if (Client_IsValid(client) && Entity_IsValid(button) && 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_button] && itemArray[item_button] == button)
|
||||
{
|
||||
if (itemArray[item_owner] && itemArray[item_owner] == 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])
|
||||
{
|
||||
case(1):
|
||||
{
|
||||
if (itemArray[item_nextuse] < RoundToCeil(GetEngineTime()))
|
||||
{
|
||||
itemArray[item_nextuse] = RoundToCeil(GetEngineTime()) + itemArray[item_cooldown];
|
||||
}
|
||||
else return Plugin_Handled;
|
||||
}
|
||||
case(2):
|
||||
{
|
||||
if (itemArray[item_uses] < itemArray[item_maxuses])
|
||||
{
|
||||
itemArray[item_uses]++;
|
||||
}
|
||||
else return Plugin_Handled;
|
||||
}
|
||||
case(3):
|
||||
{
|
||||
if (itemArray[item_nextuse] < RoundToCeil(GetEngineTime()) && itemArray[item_uses] < itemArray[item_maxuses])
|
||||
{
|
||||
itemArray[item_nextuse] = RoundToCeil(GetEngineTime()) + itemArray[item_cooldown];
|
||||
itemArray[item_uses]++;
|
||||
}
|
||||
else return Plugin_Handled;
|
||||
}
|
||||
case(4):
|
||||
{
|
||||
if (itemArray[item_nextuse] < RoundToCeil(GetEngineTime()))
|
||||
{
|
||||
itemArray[item_uses]++;
|
||||
|
||||
if (itemArray[item_uses] >= itemArray[item_maxuses])
|
||||
{
|
||||
itemArray[item_nextuse] = RoundToCeil(GetEngineTime()) + itemArray[item_cooldown];
|
||||
itemArray[item_uses] = 0;
|
||||
}
|
||||
}
|
||||
else return Plugin_Handled;
|
||||
}
|
||||
}
|
||||
|
||||
if (itemArray[item_filter][0])
|
||||
Entity_SetName(client, itemArray[item_filter]);
|
||||
|
||||
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));
|
||||
return aResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action OnTriggerTouch(int trigger, int client)
|
||||
{
|
||||
if (Client_IsValid(client) && Entity_IsValid(trigger) && 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_trigger] && itemArray[item_trigger] == trigger)
|
||||
{
|
||||
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));
|
||||
return aResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action OnWeaponTouch(int client, int weapon)
|
||||
{
|
||||
if (Client_IsValid(client) && Entity_IsValid(weapon) && 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_weapon] && itemArray[item_weapon] == weapon)
|
||||
{
|
||||
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));
|
||||
return aResult;
|
||||
}
|
||||
}
|
||||
}
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
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);
|
||||
}
|
119
entWatch4/scripting/entWatch-interface.sp
Normal file
119
entWatch4/scripting/entWatch-interface.sp
Normal file
@ -0,0 +1,119 @@
|
||||
//====================================================================================================
|
||||
//
|
||||
// Name: [entWatch] Interface
|
||||
// Author: zaCade & Prometheum
|
||||
// Description: Handle the interface of [entWatch]
|
||||
//
|
||||
//====================================================================================================
|
||||
#include <smlib>
|
||||
|
||||
#pragma newdecls required
|
||||
|
||||
#include <sourcemod>
|
||||
#include <entWatch>
|
||||
#include <entWatch_core>
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "[entWatch] Interface",
|
||||
author = "zaCade & Prometheum",
|
||||
description = "Handle the interface of [entWatch]",
|
||||
version = "4.0.0"
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnGameFrame()
|
||||
{
|
||||
if (EW_GetItemCount())
|
||||
{
|
||||
char sHUDFormat[250];
|
||||
char sHUDBuffer[64];
|
||||
|
||||
for (int index; index < EW_GetItemCount(); index++)
|
||||
{
|
||||
any itemArray[items];
|
||||
EW_GetItemArray(index, itemArray, sizeof(itemArray));
|
||||
|
||||
if (itemArray[item_display] & DISPLAY_HUD)
|
||||
{
|
||||
if (itemArray[item_owner] && Client_IsValid(itemArray[item_owner]))
|
||||
{
|
||||
switch(itemArray[item_mode])
|
||||
{
|
||||
case(1):
|
||||
{
|
||||
if (itemArray[item_nextuse] > RoundToCeil(GetEngineTime()))
|
||||
{
|
||||
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d]: %N", itemArray[item_short], itemArray[item_nextuse] - RoundToCeil(GetEngineTime()), itemArray[item_owner]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", itemArray[item_short], "R", itemArray[item_owner]);
|
||||
}
|
||||
}
|
||||
case(2):
|
||||
{
|
||||
if (itemArray[item_uses] < itemArray[item_maxuses])
|
||||
{
|
||||
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d/%d]: %N", itemArray[item_short], itemArray[item_uses], itemArray[item_maxuses], itemArray[item_owner]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", itemArray[item_short], "D", itemArray[item_owner]);
|
||||
}
|
||||
}
|
||||
case(3):
|
||||
{
|
||||
if (itemArray[item_uses] < itemArray[item_maxuses])
|
||||
{
|
||||
if (itemArray[item_nextuse] > RoundToCeil(GetEngineTime()))
|
||||
{
|
||||
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d]: %N", itemArray[item_short], itemArray[item_nextuse] - RoundToCeil(GetEngineTime()), itemArray[item_owner]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d/%d]: %N", itemArray[item_short], itemArray[item_uses], itemArray[item_maxuses], itemArray[item_owner]);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", itemArray[item_short], "D", itemArray[item_owner]);
|
||||
}
|
||||
}
|
||||
case(4):
|
||||
{
|
||||
if (itemArray[item_nextuse] > RoundToCeil(GetEngineTime()))
|
||||
{
|
||||
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d]: %N", itemArray[item_short], itemArray[item_nextuse] - RoundToCeil(GetEngineTime()), itemArray[item_owner]);
|
||||
}
|
||||
else
|
||||
{
|
||||
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d/%d]: %N", itemArray[item_short], itemArray[item_uses], itemArray[item_maxuses], itemArray[item_owner]);
|
||||
}
|
||||
}
|
||||
default:
|
||||
{
|
||||
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", itemArray[item_short], "N/A", itemArray[item_owner]);
|
||||
}
|
||||
}
|
||||
|
||||
if (strlen(sHUDFormat) + strlen(sHUDBuffer) <= sizeof(sHUDFormat) - 2)
|
||||
{
|
||||
Format(sHUDFormat, sizeof(sHUDFormat), "%s\n%s", sHUDFormat, sHUDBuffer);
|
||||
}
|
||||
else break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Handle hMessage = StartMessageAll("KeyHintText");
|
||||
BfWriteByte(hMessage, 1);
|
||||
BfWriteString(hMessage, sHUDFormat);
|
||||
EndMessage();
|
||||
}
|
||||
}
|
82
entWatch4/scripting/entWatch-logs.sp
Normal file
82
entWatch4/scripting/entWatch-logs.sp
Normal file
@ -0,0 +1,82 @@
|
||||
//====================================================================================================
|
||||
//
|
||||
// Name: [entWatch] Logs
|
||||
// Author: Prometheum & zaCade
|
||||
// Description: Handle the logs of [entWatch]
|
||||
//
|
||||
//====================================================================================================
|
||||
#include <smlib>
|
||||
|
||||
#pragma newdecls required
|
||||
|
||||
#include <sourcemod>
|
||||
#include <entWatch>
|
||||
#include <entWatch_core>
|
||||
#include <entWatch_restrictions>
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "[entWatch] Logs",
|
||||
author = "Prometheum & zaCade",
|
||||
description = "Handle the logs of [entWatch]",
|
||||
version = "4.0.0"
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnPluginStart()
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void EW_OnClientItemDrop(any[] itemArray, int client, int index)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void EW_OnClientItemDeath(any[] itemArray, int client, int index)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void EW_OnClientItemPickup(any[] itemArray, int client, int index)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void EW_OnClientItemDisconnect(any[] itemArray, int client, int index)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void EW_OnClientItemActivate(any[] itemArray, int client, int index)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void EW_OnClientRestricted(int client, int target, int length)
|
||||
{
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void EW_OnClientUnrestricted(int client, int target)
|
||||
{
|
||||
}
|
126
entWatch4/scripting/entWatch-messages.sp
Normal file
126
entWatch4/scripting/entWatch-messages.sp
Normal file
@ -0,0 +1,126 @@
|
||||
//====================================================================================================
|
||||
//
|
||||
// Name: [entWatch] Messages
|
||||
// Author: zaCade & Prometheum
|
||||
// Description: Handle the chat messages of [entWatch]
|
||||
//
|
||||
//====================================================================================================
|
||||
#include <morecolors>
|
||||
#include <smlib>
|
||||
|
||||
#pragma newdecls required
|
||||
|
||||
#include <sourcemod>
|
||||
#include <entWatch>
|
||||
#include <entWatch_core>
|
||||
|
||||
#define MESSAGEFORMAT "\x07%s[entWatch] \x07%s%s \x07%s(\x07%s%s\x07%s) %t \x07%s%s"
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "[entWatch] Messages",
|
||||
author = "zaCade & Prometheum",
|
||||
description = "Handle the chat messages of [entWatch]",
|
||||
version = "4.0.0"
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnPluginStart()
|
||||
{
|
||||
LoadTranslations("entWatch.messages.phrases");
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void EW_OnClientItemDrop(any[] itemArray, int client, int index)
|
||||
{
|
||||
if (itemArray[item_display] & DISPLAY_CHAT)
|
||||
{
|
||||
char sName[32];
|
||||
GetClientName(client, sName, sizeof(sName));
|
||||
|
||||
char sAuth[32];
|
||||
GetClientAuthId(client, AuthId_Steam2, sAuth, sizeof(sAuth));
|
||||
|
||||
CRemoveTags(sName, sizeof(sName));
|
||||
CPrintToChatAll(MESSAGEFORMAT, "E01B5D", "EDEDED", sName, "E562BA", "B2B2B2", sAuth, "E562BA", "Item Drop", itemArray[item_color], itemArray[item_name]);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void EW_OnClientItemDeath(any[] itemArray, int client, int index)
|
||||
{
|
||||
if (itemArray[item_display] & DISPLAY_CHAT)
|
||||
{
|
||||
char sName[32];
|
||||
GetClientName(client, sName, sizeof(sName));
|
||||
|
||||
char sAuth[32];
|
||||
GetClientAuthId(client, AuthId_Steam2, sAuth, sizeof(sAuth));
|
||||
|
||||
CRemoveTags(sName, sizeof(sName));
|
||||
CPrintToChatAll(MESSAGEFORMAT, "E01B5D", "EDEDED", sName, "F1B567", "B2B2B2", sAuth, "F1B567", "Item Death", itemArray[item_color], itemArray[item_name]);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void EW_OnClientItemPickup(any[] itemArray, int client, int index)
|
||||
{
|
||||
if (itemArray[item_display] & DISPLAY_CHAT)
|
||||
{
|
||||
char sName[32];
|
||||
GetClientName(client, sName, sizeof(sName));
|
||||
|
||||
char sAuth[32];
|
||||
GetClientAuthId(client, AuthId_Steam2, sAuth, sizeof(sAuth));
|
||||
|
||||
CRemoveTags(sName, sizeof(sName));
|
||||
CPrintToChatAll(MESSAGEFORMAT, "E01B5D", "EDEDED", sName, "C9EF66", "B2B2B2", sAuth, "C9EF66", "Item Pickup", itemArray[item_color], itemArray[item_name]);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void EW_OnClientItemDisconnect(any[] itemArray, int client, int index)
|
||||
{
|
||||
if (itemArray[item_display] & DISPLAY_CHAT)
|
||||
{
|
||||
char sName[32];
|
||||
GetClientName(client, sName, sizeof(sName));
|
||||
|
||||
char sAuth[32];
|
||||
GetClientAuthId(client, AuthId_Steam2, sAuth, sizeof(sAuth));
|
||||
|
||||
CRemoveTags(sName, sizeof(sName));
|
||||
CPrintToChatAll(MESSAGEFORMAT, "E01B5D", "EDEDED", sName, "F1B567", "B2B2B2", sAuth, "F1B567", "Item Disconnect", itemArray[item_color], itemArray[item_name]);
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void EW_OnClientItemActivate(any[] itemArray, int client, int index)
|
||||
{
|
||||
if (itemArray[item_display] & DISPLAY_USE)
|
||||
{
|
||||
char sName[32];
|
||||
GetClientName(client, sName, sizeof(sName));
|
||||
|
||||
char sAuth[32];
|
||||
GetClientAuthId(client, AuthId_Steam2, sAuth, sizeof(sAuth));
|
||||
|
||||
CRemoveTags(sName, sizeof(sName));
|
||||
CPrintToChatAll(MESSAGEFORMAT, "E01B5D", "EDEDED", sName, "67ADDF", "B2B2B2", sAuth, "67ADDF", "Item Activate", itemArray[item_color], itemArray[item_name]);
|
||||
}
|
||||
}
|
297
entWatch4/scripting/entWatch-restrictions.sp
Normal file
297
entWatch4/scripting/entWatch-restrictions.sp
Normal file
@ -0,0 +1,297 @@
|
||||
//====================================================================================================
|
||||
//
|
||||
// Name: [entWatch] Restrictions
|
||||
// Author: zaCade & Prometheum
|
||||
// Description: Handle the restrictions of [entWatch]
|
||||
//
|
||||
//====================================================================================================
|
||||
#include <smlib>
|
||||
#include <morecolors>
|
||||
|
||||
#pragma newdecls required
|
||||
|
||||
#include <sourcemod>
|
||||
#include <clientprefs>
|
||||
#include <entWatch>
|
||||
#include <entWatch_core>
|
||||
|
||||
/* FORWARDS */
|
||||
Handle g_hFwd_OnClientRestricted;
|
||||
Handle g_hFwd_OnClientUnrestricted;
|
||||
|
||||
/* COOKIES */
|
||||
Handle g_hCookie_RestrictedIssued;
|
||||
Handle g_hCookie_RestrictedLength;
|
||||
Handle g_hCookie_RestrictedExpire;
|
||||
|
||||
/* INTERGERS */
|
||||
int g_iRestrictedIssued[MAXPLAYERS+1];
|
||||
int g_iRestrictedLength[MAXPLAYERS+1];
|
||||
int g_iRestrictedExpire[MAXPLAYERS+1];
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Plugin myinfo =
|
||||
{
|
||||
name = "[entWatch] Restrictions",
|
||||
author = "zaCade & Prometheum",
|
||||
description = "Handle the restrictions of [entWatch]",
|
||||
version = "4.0.0"
|
||||
};
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public APLRes AskPluginLoad2(Handle hMyself, bool bLate, char[] sError, int errorSize)
|
||||
{
|
||||
CreateNative("EW_ClientRestrict", Native_ClientRestrict);
|
||||
CreateNative("EW_ClientUnrestrict", Native_ClientUnrestrict);
|
||||
CreateNative("EW_ClientRestricted", Native_ClientRestricted);
|
||||
|
||||
RegPluginLibrary("entWatch-restrictions");
|
||||
return APLRes_Success;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
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_OnClientUnrestricted = CreateGlobalForward("EW_OnClientUnrestricted", ET_Ignore, Param_Cell, Param_Cell);
|
||||
|
||||
g_hCookie_RestrictedIssued = RegClientCookie("EW_RestrictedIssued", "", CookieAccess_Private);
|
||||
g_hCookie_RestrictedLength = RegClientCookie("EW_RestrictedLength", "", CookieAccess_Private);
|
||||
g_hCookie_RestrictedExpire = RegClientCookie("EW_RestrictedExpire", "", CookieAccess_Private);
|
||||
|
||||
RegAdminCmd("sm_eban", Command_ClientRestrict, ADMFLAG_BAN);
|
||||
RegAdminCmd("sm_eunban", Command_ClientUnrestrict, ADMFLAG_UNBAN);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnClientCookiesCached(int client)
|
||||
{
|
||||
g_iRestrictedIssued[client] = GetClientCookieInt(client, g_hCookie_RestrictedIssued);
|
||||
g_iRestrictedLength[client] = GetClientCookieInt(client, g_hCookie_RestrictedLength);
|
||||
g_iRestrictedExpire[client] = GetClientCookieInt(client, g_hCookie_RestrictedExpire);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public void OnClientDisconnect(int client)
|
||||
{
|
||||
g_iRestrictedIssued[client] = 0;
|
||||
g_iRestrictedLength[client] = 0;
|
||||
g_iRestrictedExpire[client] = 0;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action Command_ClientRestrict(int client, int args)
|
||||
{
|
||||
if (!GetCmdArgs())
|
||||
{
|
||||
CReplyToCommand(client, "\x07%s[entWatch] \x07%sUsage: sm_eban <#userid/name> [duration]", "E01B5D", "F16767");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
char sTarget[32];
|
||||
char sLength[32];
|
||||
GetCmdArg(1, sTarget, sizeof(sTarget));
|
||||
GetCmdArg(2, sLength, sizeof(sLength));
|
||||
|
||||
int target;
|
||||
if ((target = FindTarget(client, sTarget, true)) == -1)
|
||||
return Plugin_Handled;
|
||||
|
||||
int length = StringToInt(sLength);
|
||||
|
||||
if (ClientRestrict(client, target, length))
|
||||
{
|
||||
if (length)
|
||||
{
|
||||
CPrintToChatAll("\x07%s[entWatch] \x07%s%N\x07%s restricted \x07%s%N\x07%s for \x07%s%d\x07%s minutes.", "E01B5D", "EDEDED", client, "F16767", "EDEDED", target, "F16767", "EDEDED", length, "F16767");
|
||||
LogAction(client, target, "%L restricted %L for %d minutes.", client, target, length);
|
||||
}
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action Command_ClientUnrestrict(int client, int args)
|
||||
{
|
||||
if (!GetCmdArgs())
|
||||
{
|
||||
CReplyToCommand(client, "\x07%s[entWatch] \x07%sUsage: sm_eunban <#userid/name>", "E01B5D", "F16767");
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
char sTarget[32];
|
||||
GetCmdArg(1, sTarget, sizeof(sTarget));
|
||||
|
||||
int target;
|
||||
if ((target = FindTarget(client, sTarget, true)) == -1)
|
||||
return Plugin_Handled;
|
||||
|
||||
if (ClientUnrestrict(client, target))
|
||||
{
|
||||
CPrintToChatAll("\x07%s[entWatch] \x07%s%N\x07%s unrestricted \x07%s%N\x07%s.", "E01B5D", "EDEDED", client, "F16767", "EDEDED", target, "F16767");
|
||||
LogAction(client, target, "%L unrestricted %L.", client, target);
|
||||
}
|
||||
|
||||
return Plugin_Handled;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action EW_OnClientItemCanPickup(any[] itemArray, int client, int index)
|
||||
{
|
||||
return ClientRestricted(client)?Plugin_Handled:Plugin_Continue;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public Action EW_OnClientItemCanActivate(any[] itemArray, int client, int index)
|
||||
{
|
||||
return ClientRestricted(client)?Plugin_Handled:Plugin_Continue;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
stock bool ClientRestrict(int client, int target, int length)
|
||||
{
|
||||
if (!Client_IsValid(client) || !Client_IsValid(target) || !AreClientCookiesCached(target) || ClientRestricted(target))
|
||||
return false;
|
||||
|
||||
int issued = GetTime();
|
||||
int second = length * 60;
|
||||
int expire = issued + second;
|
||||
|
||||
g_iRestrictedIssued[target] = issued;
|
||||
g_iRestrictedLength[target] = length;
|
||||
g_iRestrictedExpire[target] = expire;
|
||||
|
||||
SetClientCookieInt(target, g_hCookie_RestrictedIssued, issued);
|
||||
SetClientCookieInt(target, g_hCookie_RestrictedLength, length);
|
||||
SetClientCookieInt(target, g_hCookie_RestrictedExpire, expire);
|
||||
|
||||
Call_StartForward(g_hFwd_OnClientRestricted);
|
||||
Call_PushCell(client);
|
||||
Call_PushCell(target);
|
||||
Call_PushCell(length);
|
||||
Call_Finish();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
stock bool ClientUnrestrict(int client, int target)
|
||||
{
|
||||
if (!Client_IsValid(client) || !Client_IsValid(target) || !AreClientCookiesCached(target) || !ClientRestricted(target))
|
||||
return false;
|
||||
|
||||
g_iRestrictedIssued[target] = 0;
|
||||
g_iRestrictedLength[target] = 0;
|
||||
g_iRestrictedExpire[target] = 0;
|
||||
|
||||
SetClientCookieInt(target, g_hCookie_RestrictedIssued, 0);
|
||||
SetClientCookieInt(target, g_hCookie_RestrictedLength, 0);
|
||||
SetClientCookieInt(target, g_hCookie_RestrictedExpire, 0);
|
||||
|
||||
Call_StartForward(g_hFwd_OnClientUnrestricted);
|
||||
Call_PushCell(client);
|
||||
Call_PushCell(target);
|
||||
Call_Finish();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
stock bool ClientRestricted(int client)
|
||||
{
|
||||
if (!Client_IsValid(client))
|
||||
return false;
|
||||
|
||||
//Block them when loading cookies..
|
||||
if (!AreClientCookiesCached(client))
|
||||
return true;
|
||||
|
||||
//Permanent restriction..
|
||||
if (g_iRestrictedExpire[client] && g_iRestrictedLength[client] == 0)
|
||||
return true;
|
||||
|
||||
//Limited restriction..
|
||||
if (g_iRestrictedExpire[client] && g_iRestrictedExpire[client] >= GetTime())
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public int Native_ClientRestrict(Handle hPlugin, int numParams)
|
||||
{
|
||||
return ClientRestrict(GetNativeCell(1), GetNativeCell(2), GetNativeCell(3));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public int Native_ClientUnrestrict(Handle hPlugin, int numParams)
|
||||
{
|
||||
return ClientUnrestrict(GetNativeCell(1), GetNativeCell(2));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
public int Native_ClientRestricted(Handle hPlugin, int numParams)
|
||||
{
|
||||
return ClientRestricted(GetNativeCell(1));
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
stock void SetClientCookieInt(int client, Handle hCookie, int value)
|
||||
{
|
||||
char sValue[32];
|
||||
IntToString(value, sValue, sizeof(sValue));
|
||||
|
||||
SetClientCookie(client, hCookie, sValue);
|
||||
}
|
||||
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
// Purpose:
|
||||
//----------------------------------------------------------------------------------------------------
|
||||
stock int GetClientCookieInt(int client, Handle hCookie)
|
||||
{
|
||||
char sValue[32];
|
||||
GetClientCookie(client, hCookie, sValue, sizeof(sValue));
|
||||
|
||||
return StringToInt(sValue);
|
||||
}
|
289
entWatch4/scripting/include/entWatch.inc
Normal file
289
entWatch4/scripting/include/entWatch.inc
Normal file
@ -0,0 +1,289 @@
|
||||
#if defined entWatch_included
|
||||
#endinput
|
||||
#endif
|
||||
|
||||
#define entWatch_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],
|
||||
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,
|
||||
};
|
||||
|
||||
/*
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
40
entWatch4/scripting/include/entWatch_core.inc
Normal file
40
entWatch4/scripting/include/entWatch_core.inc
Normal file
@ -0,0 +1,40 @@
|
||||
#if defined entWatch_core_included
|
||||
#endinput
|
||||
#endif
|
||||
|
||||
#define entWatch_core_included
|
||||
|
||||
public SharedPlugin __pl_entWatch_core =
|
||||
{
|
||||
name = "entWatch-core",
|
||||
file = "entWatch-core.smx",
|
||||
|
||||
#if defined REQUIRE_PLUGIN
|
||||
required = 1
|
||||
#else
|
||||
required = 0
|
||||
#endif
|
||||
};
|
||||
|
||||
#if !defined REQUIRE_PLUGIN
|
||||
public void __pl_entWatch_core_SetNTVOptional()
|
||||
{
|
||||
MarkNativeAsOptional("EW_GetItemCount");
|
||||
MarkNativeAsOptional("EW_GetItemArray");
|
||||
MarkNativeAsOptional("EW_SetItemArray");
|
||||
}
|
||||
#endif
|
||||
|
||||
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);
|
33
entWatch4/scripting/include/entWatch_restrictions.inc
Normal file
33
entWatch4/scripting/include/entWatch_restrictions.inc
Normal file
@ -0,0 +1,33 @@
|
||||
#if defined entWatch_restrictions_included
|
||||
#endinput
|
||||
#endif
|
||||
|
||||
#define entWatch_restrictions_included
|
||||
|
||||
public SharedPlugin __pl_entWatch_core =
|
||||
{
|
||||
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_core_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 length);
|
||||
forward void EW_OnClientUnrestricted(int client, int target);
|
Loading…
Reference in New Issue
Block a user