Skip to content

Commit

Permalink
new ConVars: redm_tickets, redm_tickets_count
Browse files Browse the repository at this point in the history
  • Loading branch information
SergeyShorokhov committed Apr 15, 2024
1 parent eba5647 commit 62af7a4
Show file tree
Hide file tree
Showing 3 changed files with 70 additions and 0 deletions.
1 change: 1 addition & 0 deletions cstrike/addons/amxmodx/scripting/ReDeathmatch.sma
Original file line number Diff line number Diff line change
Expand Up @@ -137,6 +137,7 @@ public CSGameRules_RestartRound() {
return

RoundModes_RestartRound()
Tickets_RestartRound()
}

public CSGameRules_PlayerKilled_Post(const victim, const killer, const inflictor) {
Expand Down
67 changes: 67 additions & 0 deletions cstrike/addons/amxmodx/scripting/ReDeathmatch/Features/Tickets.inc
Original file line number Diff line number Diff line change
@@ -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)
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
#include "ReDeathmatch/Features/AimBarriers.inc"
#include "ReDeathmatch/Features/Tickets.inc"

static g_fwdPrecacheEvent = -1
static g_gunsEventsId
Expand Down Expand Up @@ -51,6 +52,7 @@ Features_Init() {
RegisterHookChain(RG_HandleMenu_ChooseTeam, "HandleMenu_ChooseTeam", .post = true)

AimBarriers_Init()
Tickets_Init()

bind_pcvar_num(
create_cvar(
Expand Down

0 comments on commit 62af7a4

Please sign in to comment.