Daemon666 / CSB Deathmatch Respawn Публичный

CSDM-style respawning: players come back a moment after death, with spawn protection and topped-up ammo.

v1.0.0 129 загрузок GPL-3.0 Обновлено Aug 25, 2026
csb_csdm_respawn.sma v1.0.0 148 строк · 4.2 KB Исходный текст
1 /*
2 * CSB Deathmatch Respawn
3 * Copyright (C) 2026 counter-strike-boost.com
4 *
5 * A lightweight CSDM-style deathmatch core: players respawn after a short,
6 * configurable delay, receive temporary spawn protection (godmode + a glow
7 * shell) and get their backpack ammo topped up so the action never stops.
8 *
9 * Inspired by CSDM (Counter-Strike Deathmatch) by Alfred "BAILOPAN" Reynolds
10 * and the AMX Mod X team. This is an independent GPL re-implementation written
11 * from scratch against fakemeta/hamsandwich, not a copy of their source.
12 *
13 * This program is free software: you can redistribute it and/or modify it
14 * under the terms of the GNU General Public License as published by the Free
15 * Software Foundation, either version 3 of the License, or (at your option)
16 * any later version. Distributed WITHOUT ANY WARRANTY. See the GNU General
17 * Public License for more details: <https://www.gnu.org/licenses/>.
18 */
19
20 #include <amxmodx>
21 #include <fakemeta>
22 #include <hamsandwich>
23 #include <cstrike>
24 #include <fun>
25
26 new const PLUGIN[] = "CSB Deathmatch Respawn"
27 new const VERSION[] = "1.0.0"
28 new const AUTHOR[] = "counter-strike-boost.com"
29
30 #define TASK_RESPAWN 7000
31 #define TASK_PROTECT 8000
32 #define is_valid_id(%1) (1 <= %1 && %1 <= g_iMaxPlayers)
33
34 new g_pEnabled, g_pDelay, g_pProtect, g_pArmor, g_pRefill
35 new bool:g_bProtected[33]
36 new g_iMaxPlayers
37
38 // weapon -> backpack ammo the refill tops players up to
39 new const g_iRefill[][2] =
40 {
41 { CSW_AK47, 90 }, { CSW_M4A1, 90 }, { CSW_AWP, 30 }, { CSW_DEAGLE, 35 },
42 { CSW_MP5NAVY, 120 }, { CSW_M3, 32 }, { CSW_XM1014, 32 }, { CSW_SCOUT, 90 },
43 { CSW_SG552, 90 }, { CSW_AUG, 90 }, { CSW_P90, 100 }, { CSW_UMP45, 100 },
44 { CSW_MAC10, 100 }, { CSW_TMP, 100 }, { CSW_GALIL, 90 }, { CSW_FAMAS, 90 },
45 { CSW_USP, 24 }, { CSW_GLOCK18, 40 }, { CSW_P228, 52 }, { CSW_FIVESEVEN, 100 },
46 { CSW_ELITE, 120 }, { CSW_M249, 200 }
47 }
48
49 public plugin_init()
50 {
51 register_plugin(PLUGIN, VERSION, AUTHOR)
52
53 g_pEnabled = register_cvar("csb_csdm_enabled", "1")
54 g_pDelay = register_cvar("csb_csdm_respawn_delay", "1.5")
55 g_pProtect = register_cvar("csb_csdm_protection", "3.0")
56 g_pArmor = register_cvar("csb_csdm_armor", "100")
57 g_pRefill = register_cvar("csb_csdm_refill", "1")
58
59 RegisterHam(Ham_Killed, "player", "fwPlayerKilled", 1)
60 RegisterHam(Ham_Spawn, "player", "fwPlayerSpawnPost", 1)
61
62 g_iMaxPlayers = get_maxplayers()
63 }
64
65 public client_disconnected(id)
66 {
67 g_bProtected[id] = false
68 remove_task(id + TASK_RESPAWN)
69 remove_task(id + TASK_PROTECT)
70 }
71
72 public fwPlayerKilled(victim, attacker, shouldgib)
73 {
74 if (!get_pcvar_num(g_pEnabled) || !is_valid_id(victim))
75 return
76
77 if (!onPlayingTeam(victim))
78 return
79
80 remove_task(victim + TASK_RESPAWN)
81 set_task(get_pcvar_float(g_pDelay), "taskRespawn", victim + TASK_RESPAWN)
82 }
83
84 public taskRespawn(taskid)
85 {
86 new id = taskid - TASK_RESPAWN
87
88 if (!is_user_connected(id) || is_user_alive(id) || !onPlayingTeam(id))
89 return
90
91 ExecuteHamB(Ham_CS_RoundRespawn, id)
92 }
93
94 public fwPlayerSpawnPost(id)
95 {
96 if (!get_pcvar_num(g_pEnabled) || !is_user_alive(id) || !onPlayingTeam(id))
97 return
98
99 new armor = get_pcvar_num(g_pArmor)
100 if (armor > 0)
101 set_user_armor(id, armor)
102
103 if (get_pcvar_num(g_pRefill))
104 refillAmmo(id)
105
106 new Float:prot = get_pcvar_float(g_pProtect)
107 if (prot > 0.0)
108 {
109 g_bProtected[id] = true
110 set_user_godmode(id, 1)
111 set_user_rendering(id, kRenderFxGlowShell, 0, 128, 255, kRenderNormal, 16)
112
113 remove_task(id + TASK_PROTECT)
114 set_task(prot, "taskUnprotect", id + TASK_PROTECT)
115 }
116 }
117
118 public taskUnprotect(taskid)
119 {
120 new id = taskid - TASK_PROTECT
121
122 if (!is_user_connected(id))
123 return
124
125 g_bProtected[id] = false
126 set_user_godmode(id, 0)
127 set_user_rendering(id, kRenderFxNone, 0, 0, 0, kRenderNormal, 16)
128 }
129
130 refillAmmo(id)
131 {
132 new weapons = pev(id, pev_weapons)
133
134 for (new i = 0; i < sizeof(g_iRefill); i++)
135 {
136 new csw = g_iRefill[i][0]
137
138 if (weapons & (1 << csw))
139 cs_set_user_bpammo(id, csw, g_iRefill[i][1])
140 }
141 }
142
143 bool:onPlayingTeam(id)
144 {
145 new CsTeams:team = cs_get_user_team(id)
146 return (team == CS_TEAM_T || team == CS_TEAM_CT)
147 }
148