From cb947258b967a382be72b9a46e252762f7b1dc0b Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Wed, 27 Mar 2024 17:08:19 +0300 Subject: [PATCH] ConVar `redm_spawn_preset` hot change support --- cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_api.inc | 2 ++ .../amxmodx/scripting/ReDeathmatch/ReDM_spawn_manager.inc | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_api.inc b/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_api.inc index aa15650..7dd2186 100644 --- a/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_api.inc +++ b/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_api.inc @@ -161,6 +161,8 @@ public bool: native_redm_setstyle(const plugin_id, const argc) { } } + // TODO: rework + log_error(AMX_ERR_NOTFOUND, "Spawn preset style `%s` not found!", name) return false } diff --git a/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_spawn_manager.inc b/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_spawn_manager.inc index a8b0192..844c808 100644 --- a/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_spawn_manager.inc +++ b/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_spawn_manager.inc @@ -20,12 +20,17 @@ SpawnManager_Init() { redm_spawn_preset, charsmax(redm_spawn_preset) ) + hook_cvar_change(get_cvar_pointer("redm_spawn_preset"), "CvarChange_redm_spawn_preset") RegisterHookChain(RG_CSGameRules_GetPlayerSpawnSpot, "CSGameRules_GetPlayerSpawnSpot", .post = false) redm_setstyle(redm_spawn_preset) } +public CvarChange_redm_spawn_preset(const cvar, const oldValue[], const value[]) { + redm_setstyle(value) +} + public CSGameRules_GetPlayerSpawnSpot(const player) { if (!IsActive()) return HC_CONTINUE