Remove CSGO and Cleanup required folders.

This commit is contained in:
zaCade
2019-06-09 11:11:04 +02:00
parent f3808e1027
commit 94bd0035f2
210 changed files with 93 additions and 1760 deletions
+209
View File
@@ -0,0 +1,209 @@
#if defined entWatch_class_config_included
#endinput
#endif
#define entWatch_class_config_included
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("iConfigID", 0);
myclass.SetInt("iWeaponID", 0);
myclass.SetInt("iTriggerID", 0);
myclass.SetInt("iDisplay", 0);
myclass.SetInt("iSlot", 0);
myclass.SetInt("iMode", 0);
myclass.SetInt("iMaxUses", 0);
myclass.SetInt("iCooldown", 0);
return view_as<CConfig>(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 iConfigID
{
public get()
{
return this.GetInt("iConfigID");
}
public set(int value)
{
this.SetInt("iConfigID", 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 iSlot
{
public get()
{
return this.GetInt("iSlot");
}
public set(int value)
{
this.SetInt("iSlot", 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 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));
}
}
}
+159
View File
@@ -0,0 +1,159 @@
#if defined entWatch_class_item_included
#endinput
#endif
#define entWatch_class_item_included
methodmap CItem < Basic
{
public CItem(CConfig value = view_as<CConfig>(INVALID_HANDLE))
{
Basic myclass = new Basic();
myclass.SetHandle("dConfig", value);
myclass.SetInt("iClient", INVALID_ENT_REFERENCE);
myclass.SetInt("iButton", INVALID_ENT_REFERENCE);
myclass.SetInt("iWeapon", INVALID_ENT_REFERENCE);
myclass.SetInt("iTrigger", INVALID_ENT_REFERENCE);
myclass.SetInt("iTimesUsed", 0);
myclass.SetInt("iTimeReady", 0);
myclass.SetFloat("flWait", 0.0);
return view_as<CItem>(myclass);
}
property CConfig dConfig
{
public get()
{
return view_as<CConfig>(this.GetHandle("dConfig"));
}
public set(CConfig value)
{
this.SetHandle("dConfig", value);
}
}
property int iClient
{
public get()
{
return this.GetInt("iClient");
}
public set(int value)
{
this.SetInt("iClient", 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 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 float flWait
{
public get()
{
return this.GetFloat("flWait");
}
public set(float value)
{
this.SetFloat("flWait", value);
}
}
property bool bClient
{
public get()
{
return view_as<bool>(this.iClient != 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);
}
}
}
+764
View File
@@ -0,0 +1,764 @@
//====================================================================================================
//
// Name: [entWatch] Core
// Author: zaCade & Prometheum
// Description: Handle the core functions of [entWatch]
//
//====================================================================================================
#include <multicolors>
#pragma newdecls required
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#include <entWatch_core>
#include <entWatch_helpers>
/* BOOLS */
bool g_bLate;
bool g_bLoaded;
bool g_bLoadPending;
bool g_bIntermission;
/* ARRAYS */
ArrayList g_hArray_Items;
ArrayList g_hArray_Configs;
/* 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_GetItemData", Native_GetItemData);
RegPluginLibrary("entWatch-core");
return APLRes_Success;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnPluginStart()
{
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_Cell, Param_Cell);
g_hFwd_OnClientItemCanActivate = CreateGlobalForward("EW_OnClientItemCanActivate", ET_Hook, Param_Cell, Param_Cell);
g_hArray_Items = new ArrayList();
g_hArray_Configs = new ArrayList();
RegAdminCmd("sm_ereload", Command_ReloadConfig, ADMFLAG_BAN);
HookEvent("player_death", OnClientDeath);
HookEvent("round_start", OnRoundStart);
HookEvent("round_end", OnRoundEnd);
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 Action Command_ReloadConfig(int client, int args)
{
if (g_bLoaded)
{
g_bLoadPending = !g_bLoadPending;
if (g_bLoadPending)
{
CReplyToCommand(client, "\x07%s[entWatch] \x07%sConfig load pending, loading at roundstart.", "E01B5D", "F16767");
return Plugin_Handled;
}
else
{
CReplyToCommand(client, "\x07%s[entWatch] \x07%sPending config load cancelled!", "E01B5D", "F16767");
return Plugin_Handled;
}
}
else
{
g_bLoaded = LoadConfig();
if (g_bLoaded)
{
CReplyToCommand(client, "\x07%s[entWatch] \x07%sConfig load successfull.", "E01B5D", "F16767");
return Plugin_Handled;
}
else
{
CReplyToCommand(client, "\x07%s[entWatch] \x07%sConfig load failed!", "E01B5D", "F16767");
return Plugin_Handled;
}
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnMapStart()
{
g_bLoaded = LoadConfig();
g_bLoadPending = false;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock bool LoadConfig()
{
g_hArray_Items.Clear();
g_hArray_Configs.Clear();
char sCurrentMap[128];
GetCurrentMap(sCurrentMap, sizeof(sCurrentMap));
String_ToLower(sCurrentMap, sCurrentMap, sizeof(sCurrentMap));
char sFilePathDefault[PLATFORM_MAX_PATH];
char sFilePathOverride[PLATFORM_MAX_PATH];
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");
if (FileExists(sFilePathOverride))
{
if (!hConfig.ImportFromFile(sFilePathOverride))
{
LogMessage("Unable to load config \"%s\"!", sFilePathOverride);
delete hConfig;
return false;
}
else LogMessage("Loaded config \"%s\"", sFilePathOverride);
}
else
{
if (!hConfig.ImportFromFile(sFilePathDefault))
{
LogMessage("Unable to load config \"%s\"!", sFilePathDefault);
delete hConfig;
return false;
}
else LogMessage("Loaded config \"%s\"", sFilePathDefault);
}
if (hConfig.GotoFirstSubKey())
{
int iConfigID;
do
{
CConfig config = new CConfig();
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));
config.SetName(sName);
config.SetShort(sShort);
config.SetColor(sColor);
config.SetFilter(sFilter);
config.iConfigID = iConfigID++;
config.iWeaponID = hConfig.GetNum("weaponid");
config.iButtonID = hConfig.GetNum("buttonid");
config.iTriggerID = hConfig.GetNum("triggerid");
config.iDisplay = hConfig.GetNum("display");
config.iSlot = hConfig.GetNum("slot");
config.iMode = hConfig.GetNum("mode");
config.iMaxUses = hConfig.GetNum("maxuses");
config.iCooldown = hConfig.GetNum("cooldown");
g_hArray_Configs.Push(config);
}
while (hConfig.GotoNextKey());
}
if (g_bLate)
{
int entity = INVALID_ENT_REFERENCE;
while ((entity = FindEntityByClassname(entity, "*")) != INVALID_ENT_REFERENCE)
{
OnEntitySpawned(entity);
}
}
delete hConfig;
return true;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnRoundStart(Event hEvent, const char[] sEvent, bool bDontBroadcast)
{
if (g_bLoadPending)
{
g_bLoaded = LoadConfig();
if (g_bLoaded)
{
CPrintToChatAll("\x07%s[entWatch] \x07%sPending config load successfull.", "E01B5D", "F16767");
}
}
g_bLoadPending = false;
g_bIntermission = false;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnRoundEnd(Event hEvent, const char[] sEvent, bool bDontBroadcast)
{
if (g_hArray_Items.Length)
g_hArray_Items.Clear();
g_bIntermission = true;
}
//----------------------------------------------------------------------------------------------------
// 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_Configs.Length)
{
int iHammerID = Entity_GetHammerID(entity);
for (int index; index < g_hArray_Configs.Length; index++)
{
CConfig config = g_hArray_Configs.Get(index);
if (config.iWeaponID && config.iWeaponID == iHammerID)
{
if (!RegisterExistingItem(config, entity, REGISTER_WEAPON))
{
CItem item = new CItem(config);
if (RegisterItemEntity(item, entity, REGISTER_WEAPON))
{
g_hArray_Items.Push(item);
SortADTArrayCustom(g_hArray_Items, SortItemsArray);
}
}
}
else if (config.iButtonID && config.iButtonID == iHammerID)
{
if (!RegisterExistingItem(config, entity, REGISTER_BUTTON))
{
CItem item = new CItem(config);
if (RegisterItemEntity(item, entity, REGISTER_BUTTON))
{
g_hArray_Items.Push(item);
SortADTArrayCustom(g_hArray_Items, SortItemsArray);
}
}
}
else if (config.iTriggerID && config.iTriggerID == iHammerID)
{
if (!RegisterExistingItem(config, entity, REGISTER_TRIGGER))
{
CItem item = new CItem(config);
if (RegisterItemEntity(item, entity, REGISTER_TRIGGER))
{
g_hArray_Items.Push(item);
SortADTArrayCustom(g_hArray_Items, SortItemsArray);
}
}
}
}
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock bool RegisterExistingItem(CConfig config, int entity, int type)
{
if (Entity_IsValid(entity) && g_hArray_Items.Length)
{
for (int index; index < g_hArray_Items.Length; index++)
{
CItem item = g_hArray_Items.Get(index);
if (item.dConfig == config)
{
if (RegisterItemEntity(item, entity, type))
return true;
}
}
}
return false;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock bool RegisterItemEntity(CItem item, int entity, int type)
{
if (Entity_IsValid(entity))
{
int iOwner = Entity_GetOwner(entity);
int iParent = Entity_GetParent(entity);
switch(type)
{
case REGISTER_WEAPON:
{
if (!item.bWeapon && (iOwner == INVALID_ENT_REFERENCE))
{
item.iWeapon = entity;
return true;
}
}
case REGISTER_BUTTON:
{
if (!item.bButton && (iParent == INVALID_ENT_REFERENCE || (item.bWeapon && iParent == item.iWeapon)))
{
SDKHook(entity, SDKHook_Use, OnButtonPress);
item.iButton = entity;
return true;
}
}
case REGISTER_TRIGGER:
{
if (!item.bTrigger && (iParent == INVALID_ENT_REFERENCE || (item.bWeapon && iParent == item.iWeapon)))
{
SDKHook(entity, SDKHook_StartTouch, OnTriggerTouch);
SDKHook(entity, SDKHook_EndTouch, OnTriggerTouch);
SDKHook(entity, SDKHook_Touch, OnTriggerTouch);
item.iTrigger = 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++)
{
CItem item = g_hArray_Items.Get(index);
if (item.bWeapon && item.iWeapon == entity)
{
item.iClient = INVALID_ENT_REFERENCE;
item.iWeapon = INVALID_ENT_REFERENCE;
return;
}
else if (item.bButton && item.iButton == entity)
{
item.iButton = INVALID_ENT_REFERENCE;
return;
}
else if (item.bTrigger && item.iTrigger == entity)
{
item.iTrigger = INVALID_ENT_REFERENCE;
return;
}
}
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public int SortItemsArray(int index1, int index2, Handle array, Handle hndl)
{
CConfig config1 = view_as<CItem>(g_hArray_Items.Get(index1)).dConfig;
CConfig config2 = view_as<CItem>(g_hArray_Items.Get(index2)).dConfig;
if (config1.iConfigID < config2.iConfigID) return -1;
if (config1.iConfigID > config2.iConfigID) return 1;
return 0;
}
//----------------------------------------------------------------------------------------------------
// 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++)
{
CItem item = g_hArray_Items.Get(index);
if (item.bClient && item.iClient == client)
{
if (item.bWeapon && !(item.dConfig.iSlot == SLOT_NONE || item.dConfig.iSlot == SLOT_KNIFE))
{
SDKHooks_DropWeapon(item.iClient, item.iWeapon, NULL_VECTOR, NULL_VECTOR);
}
item.iClient = INVALID_ENT_REFERENCE;
Call_StartForward(g_hFwd_OnClientItemDisconnect);
Call_PushCell(client);
Call_PushCell(index);
Call_Finish();
}
}
}
}
//----------------------------------------------------------------------------------------------------
// 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++)
{
CItem item = g_hArray_Items.Get(index);
if (item.bClient && item.iClient == client)
{
if (item.bWeapon && !(item.dConfig.iSlot == SLOT_NONE || item.dConfig.iSlot == SLOT_KNIFE))
{
SDKHooks_DropWeapon(item.iClient, item.iWeapon, NULL_VECTOR, NULL_VECTOR);
}
item.iClient = INVALID_ENT_REFERENCE;
Call_StartForward(g_hFwd_OnClientItemDeath);
Call_PushCell(client);
Call_PushCell(index);
Call_Finish();
}
}
}
}
//----------------------------------------------------------------------------------------------------
// 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++)
{
CItem item = g_hArray_Items.Get(index);
if (item.bWeapon && item.iWeapon == weapon)
{
item.iClient = client;
Call_StartForward(g_hFwd_OnClientItemPickup);
Call_PushCell(client);
Call_PushCell(index);
Call_Finish();
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++)
{
CItem item = g_hArray_Items.Get(index);
if (item.bWeapon && item.iWeapon == weapon)
{
item.iClient = INVALID_ENT_REFERENCE;
Call_StartForward(g_hFwd_OnClientItemDrop);
Call_PushCell(client);
Call_PushCell(index);
Call_Finish();
return;
}
}
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
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++)
{
CItem item = g_hArray_Items.Get(index);
if ((item.bButton && item.iButton == button) &&
(item.bClient && item.iClient == client))
{
Action aResult;
Call_StartForward(g_hFwd_OnClientItemCanActivate);
Call_PushCell(client);
Call_PushCell(index);
Call_Finish(aResult);
switch(aResult)
{
case Plugin_Continue, Plugin_Changed:
{
if (HasEntProp(button, Prop_Data, "m_flWait"))
{
if (item.flWait < GetEngineTime())
{
item.flWait = GetEngineTime() + GetEntPropFloat(button, Prop_Data, "m_flWait");
}
else return Plugin_Handled;
}
switch(item.dConfig.iMode)
{
case MODE_COOLDOWN:
{
if (item.iTimeReady < RoundToCeil(GetEngineTime()))
{
item.iTimeReady = RoundToCeil(GetEngineTime()) + item.dConfig.iCooldown;
}
else return Plugin_Handled;
}
case MODE_MAXUSES:
{
if (item.iTimesUsed < item.dConfig.iMaxUses)
{
item.iTimesUsed++;
}
else return Plugin_Handled;
}
case MODE_COOLDOWNMAXUSES:
{
if (item.iTimeReady < RoundToCeil(GetEngineTime()) && item.iTimesUsed < item.dConfig.iMaxUses)
{
item.iTimeReady = RoundToCeil(GetEngineTime()) + item.dConfig.iCooldown;
item.iTimesUsed++;
}
else return Plugin_Handled;
}
case MODE_COOLDOWNCHARGES:
{
if (item.iTimeReady < RoundToCeil(GetEngineTime()))
{
item.iTimesUsed++;
if (item.iTimesUsed >= item.dConfig.iMaxUses)
{
item.iTimeReady = RoundToCeil(GetEngineTime()) + item.dConfig.iCooldown;
item.iTimesUsed = 0;
}
}
else return Plugin_Handled;
}
}
char sFilter[64];
if (item.dConfig.GetFilter(sFilter, sizeof(sFilter)) && sFilter[0])
Entity_SetName(client, sFilter);
Call_StartForward(g_hFwd_OnClientItemActivate);
Call_PushCell(client);
Call_PushCell(index);
Call_Finish();
}
}
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++)
{
CItem item = g_hArray_Items.Get(index);
if (item.bTrigger && item.iTrigger == trigger)
{
if (g_bIntermission)
return Plugin_Handled;
Action aResult;
Call_StartForward(g_hFwd_OnClientItemCanPickup);
Call_PushCell(client);
Call_PushCell(index);
Call_Finish(aResult);
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++)
{
CItem item = g_hArray_Items.Get(index);
if (item.bWeapon && item.iWeapon == weapon)
{
if (g_bIntermission)
return Plugin_Handled;
Action aResult;
Call_StartForward(g_hFwd_OnClientItemCanPickup);
Call_PushCell(client);
Call_PushCell(index);
Call_Finish(aResult);
return aResult;
}
}
}
return Plugin_Continue;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public int Native_GetItemCount(Handle hPlugin, int numParams)
{
return g_hArray_Items.Length;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public int Native_GetItemData(Handle hPlugin, int numParams)
{
int index = GetNativeCell(1);
if ((index < 0) || (index > g_hArray_Items.Length))
{
return ThrowNativeError(SP_ERROR_INDEX, "Item index %d is invalid.", index);
}
return view_as<int>(g_hArray_Items.Get(index));
}
+255
View File
@@ -0,0 +1,255 @@
//====================================================================================================
//
// Name: [entWatch] Interface
// Author: zaCade & Prometheum
// Description: Handle the interface of [entWatch]
//
//====================================================================================================
#include <multicolors>
#pragma newdecls required
#include <sourcemod>
#include <clientprefs>
#include <entWatch_core>
#include <entWatch_helpers>
/* COOKIES */
Handle g_hCookie_InterfaceHidden;
/* BOOLEANS */
bool g_bInterfaceHidden[MAXPLAYERS+1];
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Plugin myinfo =
{
name = "[entWatch] Interface",
author = "zaCade & Prometheum",
description = "Handle the interface of [entWatch]",
version = "4.0.0"
};
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnPluginStart()
{
LoadTranslations("entWatch.interface.phrases");
g_hCookie_InterfaceHidden = RegClientCookie("EW_InterfaceHidden", "", CookieAccess_Private);
RegConsoleCmd("sm_hud", Command_ToggleHUD);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnMapStart()
{
CreateTimer(1.0, OnDisplayHUD, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClientCookiesCached(int client)
{
g_bInterfaceHidden[client] = GetClientCookieBool(client, g_hCookie_InterfaceHidden);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClientDisconnect(int client)
{
g_bInterfaceHidden[client] = false;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Command_ToggleHUD(int client, int args)
{
g_bInterfaceHidden[client] = !g_bInterfaceHidden[client];
if (g_bInterfaceHidden[client])
{
SetClientCookieBool(client, g_hCookie_InterfaceHidden, true);
CReplyToCommand(client, "\x07%s[entWatch] \x07%sYou will now no longer see the HUD.", "E01B5D", "F16767");
return Plugin_Handled;
}
else
{
SetClientCookieBool(client, g_hCookie_InterfaceHidden, false);
CReplyToCommand(client, "\x07%s[entWatch] \x07%sYou will now see the HUD again.", "E01B5D", "F16767");
return Plugin_Handled;
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action OnDisplayHUD(Handle timer)
{
int iHUDPages[3];
char sHUDPanels[3][8][255]
for (int index; index < EW_GetItemCount(); index++)
{
CItem item = EW_GetItemData(index);
if (item.bClient && item.dConfig.bDisplayInterface)
{
char sShort[32];
item.dConfig.GetShort(sShort, sizeof(sShort));
char sLine[96];
switch(item.dConfig.iMode)
{
case MODE_COOLDOWN:
{
if (item.iTimeReady > RoundToCeil(GetEngineTime()))
{
Format(sLine, sizeof(sLine), "%s [%d]: %N", sShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient);
}
else
{
Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "R", item.iClient);
}
}
case MODE_MAXUSES:
{
if (item.iTimesUsed < item.dConfig.iMaxUses)
{
Format(sLine, sizeof(sLine), "%s [%d/%d]: %N", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient);
}
else
{
Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "D", item.iClient);
}
}
case MODE_COOLDOWNMAXUSES:
{
if (item.iTimesUsed < item.dConfig.iMaxUses)
{
if (item.iTimeReady > RoundToCeil(GetEngineTime()))
{
Format(sLine, sizeof(sLine), "%s [%d]: %N", sShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient);
}
else
{
Format(sLine, sizeof(sLine), "%s [%d/%d]: %N", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient);
}
}
else
{
Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "D", item.iClient);
}
}
case MODE_COOLDOWNCHARGES:
{
if (item.iTimeReady > RoundToCeil(GetEngineTime()))
{
Format(sLine, sizeof(sLine), "%s [%d]: %N", sShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient);
}
else
{
Format(sLine, sizeof(sLine), "%s [%d/%d]: %N", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient);
}
}
default:
{
Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "N/A", item.iClient);
}
}
switch(GetClientTeam(item.iClient))
{
case(2):
{
if (strlen(sHUDPanels[1][iHUDPages[1]]) + strlen(sLine) + 2 >= sizeof(sHUDPanels[][])) iHUDPages[1]++;
StrCat(sHUDPanels[1][iHUDPages[1]], sizeof(sHUDPanels[][]), sLine);
StrCat(sHUDPanels[1][iHUDPages[1]], sizeof(sHUDPanels[][]), "\n");
}
case(3):
{
if (strlen(sHUDPanels[2][iHUDPages[2]]) + strlen(sLine) + 2 >= sizeof(sHUDPanels[][])) iHUDPages[2]++;
StrCat(sHUDPanels[2][iHUDPages[2]], sizeof(sHUDPanels[][]), sLine);
StrCat(sHUDPanels[2][iHUDPages[2]], sizeof(sHUDPanels[][]), "\n");
}
}
if (strlen(sHUDPanels[0][iHUDPages[0]]) + strlen(sLine) + 2 >= sizeof(sHUDPanels[][])) iHUDPages[0]++;
StrCat(sHUDPanels[0][iHUDPages[0]], sizeof(sHUDPanels[][]), sLine);
StrCat(sHUDPanels[0][iHUDPages[0]], sizeof(sHUDPanels[][]), "\n");
}
}
static int iPageUpdate;
static int iPageCurrent[3];
if (iPageUpdate >= 5)
{
for (int iPageID; iPageID < 3; iPageID++)
{
if (iPageCurrent[iPageID] >= iHUDPages[iPageID])
iPageCurrent[iPageID] = 0;
else
iPageCurrent[iPageID]++;
}
iPageUpdate = 0;
}
else
iPageUpdate++;
for (int client = 1; client <= MaxClients; client++)
{
if (!IsClientInGame(client) || IsFakeClient(client) || g_bInterfaceHidden[client])
continue;
int iPanelID;
switch(GetClientTeam(client))
{
case(2): iPanelID = 1;
case(3): iPanelID = 2;
}
if (sHUDPanels[iPanelID][iPageCurrent[iPanelID]][0])
{
Handle hMessage = StartMessageOne("KeyHintText", client);
BfWriteByte(hMessage, 1);
BfWriteString(hMessage, sHUDPanels[iPanelID][iPageCurrent[iPanelID]]);
EndMessage();
}
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock void SetClientCookieBool(int client, Handle hCookie, bool value)
{
char sValue[32];
IntToString(view_as<int>(value), sValue, sizeof(sValue));
SetClientCookie(client, hCookie, sValue);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
stock bool GetClientCookieBool(int client, Handle hCookie)
{
char sValue[32];
GetClientCookie(client, hCookie, sValue, sizeof(sValue));
return view_as<bool>(StringToInt(sValue));
}
+175
View File
@@ -0,0 +1,175 @@
//====================================================================================================
//
// Name: [entWatch] Messages
// Author: zaCade & Prometheum
// Description: Handle the chat messages of [entWatch]
//
//====================================================================================================
#include <multicolors>
#pragma newdecls required
#include <sourcemod>
#include <entWatch_core>
#include <entWatch_helpers>
#define MESSAGEFORMAT "\x07%s[entWatch] \x07%s%s \x07%s(\x07%s%s\x07%s) %t \x07%6s%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(int client, int index)
{
CItem item = EW_GetItemData(index);
if (item.dConfig.bDisplayEventMessages)
{
SetGlobalTransTarget(LANG_SERVER);
char sClientName[32];
GetClientName(client, sClientName, sizeof(sClientName));
char sClientAuth[32];
GetClientAuthId(client, AuthId_Steam2, sClientAuth, sizeof(sClientAuth));
char sItemName[32];
item.dConfig.GetName(sItemName, sizeof(sItemName));
char sItemColor[6];
item.dConfig.GetColor(sItemColor, sizeof(sItemColor));
CRemoveTags(sClientName, sizeof(sClientName));
CPrintToChatAll(MESSAGEFORMAT, "E01B5D", "EDEDED", sClientName, "E562BA", "B2B2B2", sClientAuth, "E562BA", "Item Drop", sItemColor, sItemName);
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void EW_OnClientItemDeath(int client, int index)
{
CItem item = EW_GetItemData(index);
if (item.dConfig.bDisplayEventMessages)
{
SetGlobalTransTarget(LANG_SERVER);
char sClientName[32];
GetClientName(client, sClientName, sizeof(sClientName));
char sClientAuth[32];
GetClientAuthId(client, AuthId_Steam2, sClientAuth, sizeof(sClientAuth));
char sItemName[32];
item.dConfig.GetName(sItemName, sizeof(sItemName));
char sItemColor[6];
item.dConfig.GetColor(sItemColor, sizeof(sItemColor));
CRemoveTags(sClientName, sizeof(sClientName));
CPrintToChatAll(MESSAGEFORMAT, "E01B5D", "EDEDED", sClientName, "F1B567", "B2B2B2", sClientAuth, "F1B567", "Item Death", sItemColor, sItemName);
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void EW_OnClientItemPickup(int client, int index)
{
CItem item = EW_GetItemData(index);
if (item.dConfig.bDisplayEventMessages)
{
SetGlobalTransTarget(LANG_SERVER);
char sClientName[32];
GetClientName(client, sClientName, sizeof(sClientName));
char sClientAuth[32];
GetClientAuthId(client, AuthId_Steam2, sClientAuth, sizeof(sClientAuth));
char sItemName[32];
item.dConfig.GetName(sItemName, sizeof(sItemName));
char sItemColor[6];
item.dConfig.GetColor(sItemColor, sizeof(sItemColor));
CRemoveTags(sClientName, sizeof(sClientName));
CPrintToChatAll(MESSAGEFORMAT, "E01B5D", "EDEDED", sClientName, "C9EF66", "B2B2B2", sClientAuth, "C9EF66", "Item Pickup", sItemColor, sItemName);
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void EW_OnClientItemDisconnect(int client, int index)
{
CItem item = EW_GetItemData(index);
if (item.dConfig.bDisplayEventMessages)
{
SetGlobalTransTarget(LANG_SERVER);
char sClientName[32];
GetClientName(client, sClientName, sizeof(sClientName));
char sClientAuth[32];
GetClientAuthId(client, AuthId_Steam2, sClientAuth, sizeof(sClientAuth));
char sItemName[32];
item.dConfig.GetName(sItemName, sizeof(sItemName));
char sItemColor[6];
item.dConfig.GetColor(sItemColor, sizeof(sItemColor));
CRemoveTags(sClientName, sizeof(sClientName));
CPrintToChatAll(MESSAGEFORMAT, "E01B5D", "EDEDED", sClientName, "F1B567", "B2B2B2", sClientAuth, "F1B567", "Item Disconnect", sItemColor, sItemName);
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void EW_OnClientItemActivate(int client, int index)
{
CItem item = EW_GetItemData(index);
if (item.dConfig.bDisplayActivateMessages)
{
SetGlobalTransTarget(LANG_SERVER);
char sClientName[32];
GetClientName(client, sClientName, sizeof(sClientName));
char sClientAuth[32];
GetClientAuthId(client, AuthId_Steam2, sClientAuth, sizeof(sClientAuth));
char sItemName[32];
item.dConfig.GetName(sItemName, sizeof(sItemName));
char sItemColor[6];
item.dConfig.GetColor(sItemColor, sizeof(sItemColor));
CRemoveTags(sClientName, sizeof(sClientName));
CPrintToChatAll(MESSAGEFORMAT, "E01B5D", "EDEDED", sClientName, "67ADDF", "B2B2B2", sClientAuth, "67ADDF", "Item Activate", sItemColor, sItemName);
}
}
@@ -0,0 +1,409 @@
//====================================================================================================
//
// Name: [entWatch] Restrictions
// Author: zaCade & Prometheum
// Description: Handle the restrictions of [entWatch]
//
//====================================================================================================
#include <multicolors>
#pragma newdecls required
#include <sourcemod>
#include <clientprefs>
#include <entWatch_core>
#include <entWatch_helpers>
/* FORWARDS */
Handle g_hFwd_OnClientRestricted;
Handle g_hFwd_OnClientUnrestricted;
/* COOKIES */
Handle g_hCookie_RestrictIssued;
Handle g_hCookie_RestrictExpire;
Handle g_hCookie_RestrictLength;
/* BOOLEANS */
bool g_bRestrictedTemp[MAXPLAYERS+1];
/* INTERGERS */
int g_iRestrictIssued[MAXPLAYERS+1];
int g_iRestrictLength[MAXPLAYERS+1];
int g_iRestrictExpire[MAXPLAYERS+1];
/* STRINGMAPS */
StringMap g_hTrie_Storage;
//----------------------------------------------------------------------------------------------------
// 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_RestrictIssued = RegClientCookie("EW_RestrictIssued", "", CookieAccess_Private);
g_hCookie_RestrictExpire = RegClientCookie("EW_RestrictExpire", "", CookieAccess_Private);
g_hCookie_RestrictLength = RegClientCookie("EW_RestrictLength", "", CookieAccess_Private);
g_hTrie_Storage = new StringMap();
RegAdminCmd("sm_eban", Command_ClientRestrict, ADMFLAG_BAN);
RegAdminCmd("sm_eunban", Command_ClientUnrestrict, ADMFLAG_UNBAN);
RegConsoleCmd("sm_restrictions", Command_DisplayRestrictions);
RegConsoleCmd("sm_status", Command_DisplayStatus);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnMapStart()
{
g_hTrie_Storage.Clear();
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClientPutInServer(int client)
{
char sAddress[32];
GetClientIP(client, sAddress, sizeof(sAddress));
bool bRestrictedTemp;
if (g_hTrie_Storage.GetValue(sAddress, bRestrictedTemp))
{
g_bRestrictedTemp[client] = bRestrictedTemp;
}
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClientCookiesCached(int client)
{
g_iRestrictIssued[client] = GetClientCookieInt(client, g_hCookie_RestrictIssued);
g_iRestrictExpire[client] = GetClientCookieInt(client, g_hCookie_RestrictExpire);
g_iRestrictLength[client] = GetClientCookieInt(client, g_hCookie_RestrictLength);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnClientDisconnect(int client)
{
if (g_bRestrictedTemp[client])
{
char sAddress[32];
GetClientIP(client, sAddress, sizeof(sAddress));
g_hTrie_Storage.SetArray(sAddress, g_bRestrictedTemp[client], true);
}
g_bRestrictedTemp[client] = false;
g_iRestrictIssued[client] = 0;
g_iRestrictExpire[client] = 0;
g_iRestrictLength[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 sArguments[2][32];
GetCmdArg(1, sArguments[0], sizeof(sArguments[]));
GetCmdArg(2, sArguments[1], sizeof(sArguments[]));
int target;
if ((target = FindTarget(client, sArguments[0], true)) == -1)
return Plugin_Handled;
if (GetCmdArgs() >= 2)
{
int length = StringToInt(sArguments[1]);
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);
}
}
}
else
{
if (ClientRestrict(client, target, -1))
{
CPrintToChatAll("\x07%s[entWatch] \x07%s%N\x07%s restricted \x07%s%N\x07%s temporarily.", "E01B5D", "EDEDED", client, "F16767", "EDEDED", target, "F16767");
LogAction(client, target, "%L restricted %L temporarily.", 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 sArguments[1][32];
GetCmdArg(1, sArguments[0], sizeof(sArguments[]));
int target;
if ((target = FindTarget(client, sArguments[0], 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 Command_DisplayRestrictions(int client, int args)
{
char aBuf[1024];
char aBuf2[MAX_NAME_LENGTH];
for(int i = 1; i <= MaxClients; i++)
{
if(IsClientInGame(i) && !IsFakeClient(i))
{
if(ClientRestricted(i))
{
GetClientName(i, aBuf2, sizeof(aBuf2));
StrCat(aBuf, sizeof(aBuf), aBuf2);
StrCat(aBuf, sizeof(aBuf), ", ");
}
}
}
if(strlen(aBuf))
{
aBuf[strlen(aBuf) - 2] = 0;
ReplyToCommand(client, "[SM] Currently restricted clients: %s", aBuf);
}
else
ReplyToCommand(client, "[SM] Currently restricted clients: none");
return Plugin_Handled;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Command_DisplayStatus(int client, int args)
{
return Plugin_Handled;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action EW_OnClientItemCanPickup(int client, int index)
{
return ClientRestricted(client)?Plugin_Handled:Plugin_Continue;
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action EW_OnClientItemCanActivate(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;
if (length == -1)
{
g_bRestrictedTemp[target] = true;
}
else if (length == 0)
{
g_bRestrictedTemp[target] = false;
g_iRestrictIssued[target] = GetTime();
g_iRestrictExpire[target] = 0;
g_iRestrictLength[target] = 0;
SetClientCookieInt(target, g_hCookie_RestrictIssued, GetTime());
SetClientCookieInt(target, g_hCookie_RestrictExpire, 0);
SetClientCookieInt(target, g_hCookie_RestrictLength, 0);
}
else
{
g_bRestrictedTemp[target] = false;
g_iRestrictIssued[target] = GetTime();
g_iRestrictExpire[target] = GetTime() + (length * 60);
g_iRestrictLength[target] = length;
SetClientCookieInt(target, g_hCookie_RestrictIssued, GetTime());
SetClientCookieInt(target, g_hCookie_RestrictExpire, GetTime() + (length * 60));
SetClientCookieInt(target, g_hCookie_RestrictLength, length);
}
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_bRestrictedTemp[target] = false;
g_iRestrictIssued[target] = 0;
g_iRestrictExpire[target] = 0;
g_iRestrictLength[target] = 0;
SetClientCookieInt(target, g_hCookie_RestrictIssued, 0);
SetClientCookieInt(target, g_hCookie_RestrictExpire, 0);
SetClientCookieInt(target, g_hCookie_RestrictLength, 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;
//Temporary restriction.
if (g_bRestrictedTemp[client])
return true;
//Permanent restriction.
if (g_iRestrictIssued[client] && g_iRestrictLength[client] == 0)
return true;
//Normal restriction.
if (g_iRestrictIssued[client] && g_iRestrictExpire[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);
}
+165
View File
@@ -0,0 +1,165 @@
//====================================================================================================
//
// Name: [entWatch] Tools
// Author: zaCade & Prometheum
// Description: Handle the tools of [entWatch]
//
//====================================================================================================
#include <multicolors>
#pragma newdecls required
#include <sourcemod>
#include <sdkhooks>
#include <sdktools>
#include <entWatch_core>
#include <entWatch_helpers>
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Plugin myinfo =
{
name = "[entWatch] Tools",
author = "zaCade & Prometheum",
description = "Handle the tools of [entWatch]",
version = "4.0.0"
};
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public void OnPluginStart()
{
LoadTranslations("common.phrases");
LoadTranslations("entWatch.tools.phrases");
RegAdminCmd("sm_etransfer", Command_TransferItem, ADMFLAG_BAN);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action Command_TransferItem(int client, int args)
{
if (GetCmdArgs() < 2)
{
CReplyToCommand(client, "\x07%s[entWatch] \x07%sUsage: sm_etransfer <#userid/name> <#userid/name>", "E01B5D", "F16767");
return Plugin_Handled;
}
char sArguments[2][32];
GetCmdArg(1, sArguments[0], sizeof(sArguments[]));
GetCmdArg(2, sArguments[1], sizeof(sArguments[]));
if (strncmp(sArguments[0], "$", 1, false) == 0)
{
strcopy(sArguments[0], sizeof(sArguments[]), sArguments[0][1]);
int reciever;
if ((reciever = FindTarget(client, sArguments[1], true)) == -1)
return Plugin_Handled;
char sName[32];
char sShort[32];
char sColor[32];
bool bTransfered;
for (int index; index < EW_GetItemCount(); index++)
{
CItem item = EW_GetItemData(index);
item.dConfig.GetName(sName, sizeof(sName));
item.dConfig.GetShort(sShort, sizeof(sShort));
item.dConfig.GetColor(sColor, sizeof(sColor));
if (StrContains(sName, sArguments[0], false) != -1 || StrContains(sShort, sArguments[0], false) != -1)
{
if (item.bWeapon && !(item.dConfig.iSlot == SLOT_NONE || item.dConfig.iSlot == SLOT_KNIFE))
{
int iDisplay = item.dConfig.iDisplay;
if (item.bClient)
{
SDKHooks_DropWeapon(item.iClient, item.iWeapon, NULL_VECTOR, NULL_VECTOR);
char sWeaponClass[32];
GetEntityClassname(item.iWeapon, sWeaponClass, sizeof(sWeaponClass));
GivePlayerItem(item.iClient, sWeaponClass);
}
item.dConfig.iDisplay &= ~(1<<0);
EquipPlayerWeapon(reciever, item.iWeapon);
item.dConfig.iDisplay &= iDisplay;
bTransfered = true;
break;
}
}
}
if (!bTransfered)
{
CReplyToCommand(client, "\x07%s[entWatch] \x07%sError: no transferable items found!", "E01B5D", "F16767");
return Plugin_Handled;
}
CPrintToChatAll("\x07%s[entWatch] \x07%s%N\x07%s transfered \x07%s%s\x07%s to \x07%s%N\x07%s.", "E01B5D", "EDEDED", client, "F16767", sColor, sName, "F16767", "EDEDED", reciever, "F16767");
LogAction(client, -1, "%L transfered %s to %L.", client, sName, reciever);
}
else
{
int target;
if ((target = FindTarget(client, sArguments[0], true)) == -1)
return Plugin_Handled;
int reciever;
if ((reciever = FindTarget(client, sArguments[1], true)) == -1)
return Plugin_Handled;
if (GetClientTeam(target) != GetClientTeam(reciever))
{
CReplyToCommand(client, "\x07%s[entWatch] \x07%sError: teams dont match!", "E01B5D", "F16767");
return Plugin_Handled;
}
bool bTransfered;
for (int index; index < EW_GetItemCount(); index++)
{
CItem item = EW_GetItemData(index);
if (item.bClient && item.iClient == target)
{
if (item.bWeapon && !(item.dConfig.iSlot == SLOT_NONE || item.dConfig.iSlot == SLOT_KNIFE))
{
int iDisplay = item.dConfig.iDisplay;
SDKHooks_DropWeapon(item.iClient, item.iWeapon, NULL_VECTOR, NULL_VECTOR);
char sWeaponClass[32];
GetEntityClassname(item.iWeapon, sWeaponClass, sizeof(sWeaponClass));
GivePlayerItem(item.iClient, sWeaponClass);
item.dConfig.iDisplay &= ~(1<<0);
EquipPlayerWeapon(reciever, item.iWeapon);
item.dConfig.iDisplay &= iDisplay;
bTransfered = true;
}
}
}
if (!bTransfered)
{
CReplyToCommand(client, "\x07%s[entWatch] \x07%sError: target has no transferable items!", "E01B5D", "F16767");
return Plugin_Handled;
}
CPrintToChatAll("\x07%s[entWatch] \x07%s%N\x07%s transfered all items from \x07%s%N\x07%s to \x07%s%N\x07%s.", "E01B5D", "EDEDED", client, "F16767", "EDEDED", target, "F16767", "EDEDED", reciever, "F16767");
LogAction(client, target, "%L transfered all items from %L to %L.", client, target, reciever);
}
return Plugin_Handled;
}
@@ -0,0 +1,61 @@
#if defined entWatch_core_included
#endinput
#endif
#define entWatch_core_included
/* REGISTERS */
#define REGISTER_WEAPON 1
#define REGISTER_BUTTON 2
#define REGISTER_TRIGGER 3
/* SLOTS */
#define SLOT_NONE 0
#define SLOT_PRIMARY 1
#define SLOT_SECONDARY 2
#define SLOT_KNIFE 3
#define SLOT_GRENADES 4
/* MODES */
#define MODE_COOLDOWN 1
#define MODE_MAXUSES 2
#define MODE_COOLDOWNMAXUSES 3
#define MODE_COOLDOWNCHARGES 4
/* CLASSES */
#include <basic>
#include "../classes/CConfig.inc"
#include "../classes/CItem.inc"
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_GetItemData");
}
#endif
native int EW_GetItemCount();
native CItem EW_GetItemData(int index);
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);
@@ -0,0 +1,132 @@
#if defined entWatch_helpers_included
#endinput
#endif
#define entWatch_helpers_included
/**
* Converts the whole String to lower case.
* Only works with alphabetical characters (not ײִ) because Sourcemod suxx !
* The Output String can be the same as the Input String.
*
* @param input Input String.
* @param output Output String.
* @param size Max Size of the Output string
* @noreturn
*/
stock void String_ToLower(const char[] input, char[] output, int size)
{
size--;
int x;
while (input[x] != '\0' || x < size) {
if (IsCharUpper(input[x])) {
output[x] = CharToLower(input[x]);
}
else {
output[x] = input[x];
}
x++;
}
output[x] = '\0';
}
/**
* Checks if the specified index is a player and connected.
*
* @param entity An entity index.
* @param checkConnected Set to false to skip the IsClientConnected check
* @return Returns true if the specified entity index is a player connected, false otherwise.
*/
stock bool Client_IsValid(int client, bool checkConnected=true)
{
if (client > 4096) {
client = EntRefToEntIndex(client);
}
if (client < 1 || client > MaxClients) {
return false;
}
if (checkConnected && !IsClientConnected(client)) {
return false;
}
return true;
}
/**
* Gets the client's current observer target entity.
*
* @param client Client Index.
* @return Observed Entity Index.
*/
stock int Client_GetObserverTarget(int client)
{
return GetEntPropEnt(client, Prop_Send, "m_hObserverTarget");
}
/*
* Checks if an entity is valid and exists.
*
* @param entity Entity Index.
* @return True if the entity is valid, false otherwise.
*/
stock bool Entity_IsValid(int entity)
{
return IsValidEntity(entity);
}
/**
* Gets the Hammer-ID of an entity.
* The Hammer Editor gives every entity a unique ID.
* Note: Old maps don't have Hammer-ID's set for entities
*
* @param entity Entity index.
* @return Hammer ID.
*/
stock int Entity_GetHammerID(int entity)
{
return GetEntProp(entity, Prop_Data, "m_iHammerID");
}
/**
* Gets the owner of an entity.
* For example the owner of a weapon entity.
*
* @param entity Entity index.
* @return Ground Entity or -1
*/
stock int Entity_GetOwner(int entity)
{
return GetEntPropEnt(entity, Prop_Data, "m_hOwnerEntity");
}
/*
* Gets the parent entity of an entity.
*
* @param entity Entity Index.
* @return Entity Index of the parent.
*/
stock int Entity_GetParent(int entity)
{
return GetEntPropEnt(entity, Prop_Data, "m_pParent");
}
/**
* Sets the Name of an entity.
*
* @param entity Entity index.
* @param name The name you want to give.
* @noreturn
*/
stock void Entity_SetName(int entity, const char[] name, any ...)
{
char format[128];
VFormat(format, sizeof(format), name, 3);
DispatchKeyValue(entity, "targetname", format);
}
@@ -0,0 +1,33 @@
#if defined entWatch_restrictions_included
#endinput
#endif
#define entWatch_restrictions_included
public SharedPlugin __pl_entWatch_restrictions =
{
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_restrictions_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);