From 62af7a4a91f652c7080130d8aec35e9fa956a427 Mon Sep 17 00:00:00 2001 From: Sergey Shorokhov Date: Mon, 15 Apr 2024 17:59:09 +0300 Subject: [PATCH] new ConVars: `redm_tickets`, `redm_tickets_count` --- .../addons/amxmodx/scripting/ReDeathmatch.sma | 1 + .../ReDeathmatch/Features/Tickets.inc | 67 +++++++++++++++++++ .../scripting/ReDeathmatch/ReDM_features.inc | 2 + 3 files changed, 70 insertions(+) create mode 100644 cstrike/addons/amxmodx/scripting/ReDeathmatch/Features/Tickets.inc diff --git a/cstrike/addons/amxmodx/scripting/ReDeathmatch.sma b/cstrike/addons/amxmodx/scripting/ReDeathmatch.sma index f07001f..13b5cf2 100644 --- a/cstrike/addons/amxmodx/scripting/ReDeathmatch.sma +++ b/cstrike/addons/amxmodx/scripting/ReDeathmatch.sma @@ -137,6 +137,7 @@ public CSGameRules_RestartRound() { return RoundModes_RestartRound() + Tickets_RestartRound() } public CSGameRules_PlayerKilled_Post(const victim, const killer, const inflictor) { diff --git a/cstrike/addons/amxmodx/scripting/ReDeathmatch/Features/Tickets.inc b/cstrike/addons/amxmodx/scripting/ReDeathmatch/Features/Tickets.inc new file mode 100644 index 0000000..04c8160 --- /dev/null +++ b/cstrike/addons/amxmodx/scripting/ReDeathmatch/Features/Tickets.inc @@ -0,0 +1,67 @@ +static bool: redm_tickets +static redm_tickets_count + +static g_respawnsCount[TeamName] + +Tickets_Init() { + RegisterHookChain(RG_CBasePlayer_Killed, "CBasePlayer_Killed", .post = true) + + set_task(1.0, "Think_UpdateHUD", .flags = "b") + + bind_pcvar_num( + create_cvar( + "redm_tickets", "0", + .has_min = true, .min_val = 0.0, + .has_max = true, .max_val = 1.0, + .flags = _FCVAR_BOOLEAN, + .description = "Is round ticketing enabled?" + ), + redm_tickets + ) + bind_pcvar_num( + create_cvar( + "redm_tickets_count", "150", + .has_min = true, .min_val = 0.0, + .has_max = false, + .flags = _FCVAR_INTEGER, + .description = "Number of times a team can ^n\ + have players respawn before they stop ^n\ + being able to respawn." + ), + redm_tickets_count + ) +} + +Tickets_RestartRound() { + arrayset(g_respawnsCount, 0, sizeof(g_respawnsCount)) + Think_UpdateHUD() +} + +public CBasePlayer_Killed(const player, const killer, const gib) { + new TeamName: team = get_member(player, m_iTeam) + if (g_respawnsCount[team]++ < redm_tickets_count) + return + + // Prevent player spawn + set_member(player, m_flRespawnPending, 99999999.0) +} + +public Think_UpdateHUD() { + set_dhudmessage( + .red = 200, + .green = 200, + .blue = 200, + .y = 0.15, + .effects = 0, + .fadeintime = 0.0, + .fadeouttime = 0.0, + .holdtime = 1.1 + ) + + new ticketsLeft_CT = max(0, redm_tickets_count - g_respawnsCount[TEAM_CT]) + new ticketsLeft_T = max(0, redm_tickets_count - g_respawnsCount[TEAM_TERRORIST]) + + new message[192] + format(message, 100, "T [ %03d - %03d ] CT", ticketsLeft_T, ticketsLeft_CT) + show_dhudmessage(0, "%s", message) +} \ No newline at end of file diff --git a/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_features.inc b/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_features.inc index df8136c..f09b996 100644 --- a/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_features.inc +++ b/cstrike/addons/amxmodx/scripting/ReDeathmatch/ReDM_features.inc @@ -1,4 +1,5 @@ #include "ReDeathmatch/Features/AimBarriers.inc" +#include "ReDeathmatch/Features/Tickets.inc" static g_fwdPrecacheEvent = -1 static g_gunsEventsId @@ -51,6 +52,7 @@ Features_Init() { RegisterHookChain(RG_HandleMenu_ChooseTeam, "HandleMenu_ChooseTeam", .post = true) AimBarriers_Init() + Tickets_Init() bind_pcvar_num( create_cvar(