From 0d291c85bba66b11fe29260eeee5d317ae5971a1 Mon Sep 17 00:00:00 2001 From: Shorokhov Sergey Date: Sun, 17 Dec 2023 18:24:56 +0300 Subject: [PATCH 1/5] Core: replace `reapi` by `fakemeta` --- .../amxmodx/scripting/ChatAdditions_Core.sma | 49 +++++++++++-------- 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/cstrike/addons/amxmodx/scripting/ChatAdditions_Core.sma b/cstrike/addons/amxmodx/scripting/ChatAdditions_Core.sma index a765b7e..2ad2b97 100644 --- a/cstrike/addons/amxmodx/scripting/ChatAdditions_Core.sma +++ b/cstrike/addons/amxmodx/scripting/ChatAdditions_Core.sma @@ -1,6 +1,6 @@ #include #include -#include +#include #include #include @@ -65,8 +65,8 @@ public plugin_init() { register_clcmd("say", "ClCmd_Say", ADMIN_ALL) register_clcmd("say_team", "ClCmd_Say", ADMIN_ALL) - RegisterHookChain(RG_CSGameRules_CanPlayerHearPlayer, "CSGameRules_CanPlayerHearPlayer", .post = false) - RegisterHookChain(RG_CBasePlayer_SetClientUserInfoName, "CBasePlayer_SetClientUserInfoName", .post = false) + register_forward(FM_Voice_SetClientListening, "Voice_SetClientListening_Pre", ._post = false) + register_forward(FM_ClientUserInfoChanged, "ClientUserInfoChanged_Pre", ._post = false) register_clcmd("VModEnable", "ClCmd_VModEnable", ADMIN_ALL, .FlagManager = false) register_clcmd("vban", "ClCmd_vban", ADMIN_ALL, .FlagManager = false) @@ -218,32 +218,41 @@ public ClCmd_Say(const id) { return (g_retVal == CA_SUPERCEDE) ? PLUGIN_HANDLED : PLUGIN_CONTINUE } -public CSGameRules_CanPlayerHearPlayer(const listener, const sender) { - if(listener == sender /* || !g_PlayerModEnable[listener] */) { - return HC_CONTINUE - } +public Voice_SetClientListening_Pre(const receiver, const sender, bool: canListen) { + if(receiver == sender) + return FMRES_IGNORED - ExecuteForward(g_fwdClientVoice, g_retVal, listener, sender) + if(!g_PlayerModEnable[receiver]) + return FMRES_IGNORED - if(g_retVal == CA_SUPERCEDE) { - SetHookChainReturn(ATYPE_BOOL, false) + if (!is_user_connected(receiver) || !is_user_connected(sender)) + return FMRES_IGNORED - return HC_BREAK - } + ExecuteForward(g_fwdClientVoice, g_retVal, receiver, sender) + if(g_retVal != CA_SUPERCEDE) + return FMRES_IGNORED - return HC_CONTINUE + // Block voice + engfunc(EngFunc_SetClientListening, receiver, sender, (canListen = false)) + return FMRES_SUPERCEDE } -public CBasePlayer_SetClientUserInfoName(const id, const infobuffer[], newName[]) { - ExecuteForward(g_fwdClientChangeName, g_retVal, id, newName) +public ClientUserInfoChanged_Pre(const player, const infobuffer) { + new currentName[32] + get_user_name(player, currentName, charsmax(currentName)) - if(g_retVal == CA_SUPERCEDE) { - SetHookChainReturn(ATYPE_BOOL, false) + new newName[32] + engfunc(EngFunc_InfoKeyValue, infobuffer, "name", newName, charsmax(newName)) - return HC_SUPERCEDE - } + if(strcmp(currentName, newName) == 0) + return + + ExecuteForward(g_fwdClientChangeName, g_retVal, player, newName) + if(g_retVal != CA_SUPERCEDE) + return - return HC_CONTINUE + // Change back name + engfunc(EngFunc_SetClientKeyValue, player, infobuffer, "name", currentName) } public ClCmd_VModEnable(const id) { From eab402f4327555c769691b479b2c6d619b8029b4 Mon Sep 17 00:00:00 2001 From: Shorokhov Sergey Date: Sun, 17 Dec 2023 18:58:51 +0300 Subject: [PATCH 2/5] DeathMute: use `hamsandwich` instead `reapi` --- .../addons/amxmodx/scripting/CA_Addon_DeathMute.sma | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/cstrike/addons/amxmodx/scripting/CA_Addon_DeathMute.sma b/cstrike/addons/amxmodx/scripting/CA_Addon_DeathMute.sma index c46e43c..06fff73 100644 --- a/cstrike/addons/amxmodx/scripting/CA_Addon_DeathMute.sma +++ b/cstrike/addons/amxmodx/scripting/CA_Addon_DeathMute.sma @@ -1,6 +1,6 @@ #include #include -#include +#include #include @@ -43,8 +43,9 @@ public plugin_init() { AutoExecConfig(true, "CA_Addon_DeathMute", "ChatAdditions") - RegisterHookChain(RG_CBasePlayer_Killed, "CBasePlayer_Killed", .post = true) - RegisterHookChain(RG_CSGameRules_PlayerSpawn, "CBasePlayer_Spawn", .post = true) + // RegisterHam(Ham_TFC_Killed, "player", "CBasePlayer_Killed", .Post = true) // Does it need ?! + RegisterHam(Ham_Killed, "player", "CBasePlayer_Killed", .Post = true) + RegisterHam(Ham_Spawn, "player", "CBasePlayer_Spawn", .Post = true) g_syncHudOj = CreateHudSyncObj() } @@ -132,6 +133,9 @@ public client_disconnected(id) { } public CBasePlayer_Spawn(const id) { + if(!is_user_alive(id)) + return + g_canSpeakWithAlive[id] = true remove_task(id) From 39f9c34a6a584819e567afca87ad90c7463cea04 Mon Sep 17 00:00:00 2001 From: Shorokhov Sergey Date: Sun, 17 Dec 2023 18:59:57 +0300 Subject: [PATCH 3/5] RankRestrictions: add is_user_steam if ReAPI not found --- .../scripting/CA_Addon_RankRestrictions.sma | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/cstrike/addons/amxmodx/scripting/CA_Addon_RankRestrictions.sma b/cstrike/addons/amxmodx/scripting/CA_Addon_RankRestrictions.sma index 20f95ce..1e5cad7 100644 --- a/cstrike/addons/amxmodx/scripting/CA_Addon_RankRestrictions.sma +++ b/cstrike/addons/amxmodx/scripting/CA_Addon_RankRestrictions.sma @@ -1,5 +1,5 @@ #include -#include +#tryinclude #include @@ -286,3 +286,21 @@ GetUserFragsFromStats(const player) { return 0 } + +#if !defined _reapi_reunion_included +static stock bool: is_user_steam(const id) { + static dp_r_id_provider + if (dp_r_id_provider || (dp_r_id_provider = get_cvar_pointer("dp_r_id_provider"))) { + server_cmd("dp_clientinfo %i", id) + server_exec() + + #define DP_AUTH_STEAM 2 + if(get_pcvar_num(dp_r_id_provider) == DP_AUTH_STEAM) + return true + + return false + } + + return false +} +#endif From cd587b64f5a7ce5c11dc60f2c4d0b77ba55f4f84 Mon Sep 17 00:00:00 2001 From: Shorokhov Sergey Date: Sun, 17 Dec 2023 19:07:13 +0300 Subject: [PATCH 4/5] RankRestrictions: allow to work without ReAPI module installed --- .../scripting/CA_Addon_RankRestrictions.sma | 15 +++++++++------ 1 file changed, 9 insertions(+), 6 deletions(-) diff --git a/cstrike/addons/amxmodx/scripting/CA_Addon_RankRestrictions.sma b/cstrike/addons/amxmodx/scripting/CA_Addon_RankRestrictions.sma index 1e5cad7..a3bf274 100644 --- a/cstrike/addons/amxmodx/scripting/CA_Addon_RankRestrictions.sma +++ b/cstrike/addons/amxmodx/scripting/CA_Addon_RankRestrictions.sma @@ -1,5 +1,5 @@ #include -#tryinclude +#tryinclude #include @@ -189,7 +189,7 @@ bool: CanCommunicate(const player, const bool: print, chatType) { return true } - if(ca_rankrestrictions_steam_immunity && is_user_steam(player)) { + if(ca_rankrestrictions_steam_immunity && _is_user_steam(player)) { return true } @@ -287,11 +287,15 @@ GetUserFragsFromStats(const player) { return 0 } -#if !defined _reapi_reunion_included -static stock bool: is_user_steam(const id) { +static stock bool: _is_user_steam(const player) { + #if (defined _reapi_reunion_included) + if(has_reunion()) + return (REU_GetAuthtype(player) == CA_TYPE_STEAM) + #endif + static dp_r_id_provider if (dp_r_id_provider || (dp_r_id_provider = get_cvar_pointer("dp_r_id_provider"))) { - server_cmd("dp_clientinfo %i", id) + server_cmd("dp_clientinfo %i", player) server_exec() #define DP_AUTH_STEAM 2 @@ -303,4 +307,3 @@ static stock bool: is_user_steam(const id) { return false } -#endif From 5d5d57d0e16cb7f495c4e848718e26e902e82a07 Mon Sep 17 00:00:00 2001 From: Shorokhov Sergey Date: Sun, 17 Dec 2023 19:09:05 +0300 Subject: [PATCH 5/5] README: reapi is `optional` now --- .github/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/README.md b/.github/README.md index a21e7d3..ba8d69c 100644 --- a/.github/README.md +++ b/.github/README.md @@ -49,7 +49,7 @@ Rich API capabilities allow the system to connect any functionality (work with p - HLDS installed; - [ReGameDLL](https://github.com/s1lentq/ReGameDLL_CS) installed; - Installed AMXModX ([`v1.9`](https://www.amxmodx.org/downloads-new.php) or [`v1.10`](https://www.amxmodx.org/downloads-new.php?branch=master)); - - Installed [ReAPI](https://github.com/s1lentq/reapi) module; + - Installed [ReAPI](https://github.com/s1lentq/reapi) module (optional, but not required); ## Installation - [Download the latest](https://github.com/ChatAdditions/ChatAdditions_AMXX/releases/latest) stable version from the release section.