FilterTriggerTouchPlayers

This commit is contained in:
BotoX 2019-10-07 23:59:59 +02:00
parent c13be80196
commit 94c4240638
3 changed files with 26 additions and 4 deletions

View File

@ -462,12 +462,14 @@ void Physics_SimulateEntity_CustomLoop(CBaseEntity **ppList, int Count, float St
} }
} }
int g_TriggerEntityMoved;
char *g_aFilterTriggerTouchPlayers = NULL;
int g_FilterTriggerMoved = -1; int g_FilterTriggerMoved = -1;
// void IVEngineServer::TriggerMoved( edict_t *pTriggerEnt, bool testSurroundingBoundsOnly ) = 0; // void IVEngineServer::TriggerMoved( edict_t *pTriggerEnt, bool testSurroundingBoundsOnly ) = 0;
SH_DECL_HOOK2_void(IVEngineServer, TriggerMoved, SH_NOATTRIB, 0, edict_t *, bool); SH_DECL_HOOK2_void(IVEngineServer, TriggerMoved, SH_NOATTRIB, 0, edict_t *, bool);
void TriggerMoved(edict_t *pTriggerEnt, bool testSurroundingBoundsOnly) void TriggerMoved(edict_t *pTriggerEnt, bool testSurroundingBoundsOnly)
{ {
int index = gamehelpers->IndexOfEdict(pTriggerEnt); g_TriggerEntityMoved = gamehelpers->IndexOfEdict(pTriggerEnt);
// Allow all // Allow all
if(g_FilterTriggerMoved == -1) if(g_FilterTriggerMoved == -1)
@ -488,7 +490,7 @@ void TriggerMoved(edict_t *pTriggerEnt, bool testSurroundingBoundsOnly)
SH_DECL_HOOK1(CTriggerMoved, EnumElement, SH_NOATTRIB, 0, IterationRetval_t, IHandleEntity *); SH_DECL_HOOK1(CTriggerMoved, EnumElement, SH_NOATTRIB, 0, IterationRetval_t, IHandleEntity *);
IterationRetval_t TriggerMoved_EnumElement(IHandleEntity *pHandleEntity) IterationRetval_t TriggerMoved_EnumElement(IHandleEntity *pHandleEntity)
{ {
if(g_FilterTriggerMoved <= 0) if(g_FilterTriggerMoved <= 0 && !g_aFilterTriggerTouchPlayers)
{ {
RETURN_META_VALUE(MRES_IGNORED, ITERATION_CONTINUE); RETURN_META_VALUE(MRES_IGNORED, ITERATION_CONTINUE);
} }
@ -503,7 +505,13 @@ IterationRetval_t TriggerMoved_EnumElement(IHandleEntity *pHandleEntity)
RETURN_META_VALUE(MRES_IGNORED, ITERATION_CONTINUE); RETURN_META_VALUE(MRES_IGNORED, ITERATION_CONTINUE);
} }
// only allow touching his player if filter is active // block touching any clients here if map exists and evaluates to true
if(g_aFilterTriggerTouchPlayers && g_aFilterTriggerTouchPlayers[g_TriggerEntityMoved])
{
RETURN_META_VALUE(MRES_SUPERCEDE, ITERATION_CONTINUE);
}
// only allow touching this player if filter is active
if(index == g_FilterTriggerMoved) if(index == g_FilterTriggerMoved)
{ {
RETURN_META_VALUE(MRES_IGNORED, ITERATION_CONTINUE); RETURN_META_VALUE(MRES_IGNORED, ITERATION_CONTINUE);
@ -519,6 +527,16 @@ cell_t FilterTriggerMoved(IPluginContext *pContext, const cell_t *params)
return 0; return 0;
} }
cell_t FilterTriggerTouchPlayers(IPluginContext *pContext, const cell_t *params)
{
if(params[2])
pContext->LocalToPhysAddr(params[1], (cell_t **)&g_aFilterTriggerTouchPlayers);
else
g_aFilterTriggerTouchPlayers = NULL;
return 0;
}
int g_SolidEntityMoved; int g_SolidEntityMoved;
int g_BlockSolidMoved = -1; int g_BlockSolidMoved = -1;
char *g_pFilterClientEntityMap = NULL; char *g_pFilterClientEntityMap = NULL;
@ -873,6 +891,7 @@ const sp_nativeinfo_t MyNatives[] =
{ "FilterTriggerMoved", FilterTriggerMoved }, { "FilterTriggerMoved", FilterTriggerMoved },
{ "BlockSolidMoved", BlockSolidMoved }, { "BlockSolidMoved", BlockSolidMoved },
{ "FilterClientEntityMap", FilterClientEntityMap }, { "FilterClientEntityMap", FilterClientEntityMap },
{ "FilterTriggerTouchPlayers", FilterTriggerTouchPlayers },
{ NULL, NULL } { NULL, NULL }
}; };

View File

@ -23,6 +23,9 @@ native void BlockSolidMoved(int entity);
// Block clients SolidMoved from touching an entity by setting it to 1 in the clients map. // Block clients SolidMoved from touching an entity by setting it to 1 in the clients map.
native void FilterClientEntityMap(char map[MAXPLAYERS + 1][2048], bool set); native void FilterClientEntityMap(char map[MAXPLAYERS + 1][2048], bool set);
// Block triggers TriggerMoved from touching any client by setting it to 1 for the entity index.
native void FilterTriggerTouchPlayers(char map[2048], bool set);
public Extension __ext_CSSFixes = public Extension __ext_CSSFixes =
{ {
name = "CSSFixes", name = "CSSFixes",

View File

@ -40,7 +40,7 @@
/* Basic information exposed publicly */ /* Basic information exposed publicly */
#define SMEXT_CONF_NAME "CSSFixes" #define SMEXT_CONF_NAME "CSSFixes"
#define SMEXT_CONF_DESCRIPTION "Patches bugs in the CSS server binary and more..." #define SMEXT_CONF_DESCRIPTION "Patches bugs in the CSS server binary and more..."
#define SMEXT_CONF_VERSION "1.10" #define SMEXT_CONF_VERSION "1.11"
#define SMEXT_CONF_AUTHOR "BotoX" #define SMEXT_CONF_AUTHOR "BotoX"
#define SMEXT_CONF_URL "" #define SMEXT_CONF_URL ""
#define SMEXT_CONF_LOGTAG "CSSFIXES" #define SMEXT_CONF_LOGTAG "CSSFIXES"