From a3f57690585241eb12eb0c6c81c26962b1772d57 Mon Sep 17 00:00:00 2001 From: OciXCrom Date: Tue, 2 Jan 2018 14:52:49 +0100 Subject: [PATCH] Added param availability check + 2 more params in the forward --- amxmodx/amxmodx.cpp | 10 +++++++--- amxmodx/meta_api.cpp | 2 +- plugins/include/amxmodx.inc | 6 ++++-- 3 files changed, 12 insertions(+), 6 deletions(-) diff --git a/amxmodx/amxmodx.cpp b/amxmodx/amxmodx.cpp index bf6717c7..7b430d85 100755 --- a/amxmodx/amxmodx.cpp +++ b/amxmodx/amxmodx.cpp @@ -2861,12 +2861,14 @@ static cell AMX_NATIVE_CALL set_user_flags(AMX *amx, cell *params) /* 4 param */ if (id > 31) id = 31; - if(params[4]) + int oldflags = pPlayer->flags[id]; + + if((*params / sizeof(cell) >= 4) && params[4]) pPlayer->flags[id] = flag; else pPlayer->flags[id] |= flag; - executeForwards(FF_ClientFlagsUpdated, static_cast(pPlayer->index), pPlayer->flags[id]); + executeForwards(FF_ClientFlagsUpdated, static_cast(pPlayer->index), oldflags, pPlayer->flags[id], id); return 1; } @@ -2890,9 +2892,11 @@ static cell AMX_NATIVE_CALL remove_user_flags(AMX *amx, cell *params) /* 3 param if (id > 31) id = 31; + + int oldflags = pPlayer->flags[id]; pPlayer->flags[id] &= ~flag; - executeForwards(FF_ClientFlagsUpdated, static_cast(pPlayer->index), pPlayer->flags[id]); + executeForwards(FF_ClientFlagsUpdated, static_cast(pPlayer->index), oldflags, pPlayer->flags[id], id); return 1; } diff --git a/amxmodx/meta_api.cpp b/amxmodx/meta_api.cpp index e68d135b..f31138b5 100755 --- a/amxmodx/meta_api.cpp +++ b/amxmodx/meta_api.cpp @@ -517,7 +517,7 @@ int C_Spawn(edict_t *pent) FF_ClientAuthorized = registerForward("client_authorized", ET_IGNORE, FP_CELL, FP_STRING, FP_DONE); FF_ChangeLevel = registerForward("server_changelevel", ET_STOP, FP_STRING, FP_DONE); FF_ClientConnectEx = registerForward("client_connectex", ET_STOP, FP_CELL, FP_STRING, FP_STRING, FP_ARRAY, FP_DONE); - FF_ClientFlagsUpdated = registerForward("client_flags_updated", ET_IGNORE, FP_CELL, FP_CELL, FP_DONE); + FF_ClientFlagsUpdated = registerForward("client_flags_updated", ET_IGNORE, FP_CELL, FP_CELL, FP_CELL, FP_CELL, FP_DONE); CoreCfg.OnAmxxInitialized(); diff --git a/plugins/include/amxmodx.inc b/plugins/include/amxmodx.inc index 81350fa9..04f85de5 100755 --- a/plugins/include/amxmodx.inc +++ b/plugins/include/amxmodx.inc @@ -163,11 +163,13 @@ forward client_connectex(id, const name[], const ip[], reason[128]); * Called after the client's admin flags are changed. * * @param id Client index - * @param flags New client flags + * @param oldflags Old client flags + * @param newflags New client flags + * @param set Flag set id * * @noreturn */ -forward client_flags_updated(id, flags); +forward client_flags_updated(id, oldflags, newflags, set); /** * Called when the client gets a valid SteamID.