Serverul tău aici Licitează în licitația săptămânală Promoveaza serverul

Initial release 1.0.0

Browse Source
1.0.0 - Initial release.
Daemon666 committed commit 4560b5027909c75f22147e5720024bbc959627bf
4 changed files with 321 additions and 0 deletions
+3 -0 CHANGELOG.md A
@@ -0,0 +1,3 @@
1 +## 1.0.0 (2025-10-26)
2 +
3 +1.0.0 - Initial release.
+1 -0 README.md A
@@ -0,0 +1 @@
1 +<p><strong>CSB Capture The Flag</strong> turns any map into CTF. Two flag entities are spawned at base coordinates read from a per-map data file (<code>addons/amxmodx/configs/csb_ctf/&lt;map&gt;.ini</code>, two <code>x y z</code> lines: Terrorist base then CT base). Touching the enemy flag picks it up (a <code>Ham_Touch</code> hook) and it then follows the carrier; bringing it to your own base while your flag is home scores a capture. Dropped flags auto-return after a delay, and the score is shown on a HUD.</p><p>Inspired by CTF by Avalanche. Independent GPL re-implementation.</p><h2>Features</h2><ul><li>Two flags placed from a per-map data file.</li><li>Pick up by touch, carry, and capture at your home base.</li><li>Flags drop on death and auto-return after a timeout.</li><li>Live capture scoreboard on the HUD.</li></ul><h2>Installation</h2><ol><li>Enable the <code>fakemeta</code> and <code>hamsandwich</code> modules in <code>modules.ini</code>.</li><li>Create <code>addons/amxmodx/configs/csb_ctf/&lt;map&gt;.ini</code> with two <code>x y z</code> base lines.</li><li>Compile <code>csb_ctf.sma</code>, copy it to <code>addons/amxmodx/plugins/</code> and add it to <code>plugins.ini</code>.</li><li>Change the map.</li></ol>
+286 -0 addons/amxmodx/scripting/csb_ctf.sma A
@@ -0,0 +1,286 @@
1 +/*
2 + * CSB Capture The Flag
3 + * Copyright (C) 2026 counter-strike-boost.com
4 + *
5 + * A capture-the-flag layer for any map. Two flag entities are spawned at base
6 + * coordinates read from a per-map data file (addons/amxmodx/configs/csb_ctf/
7 + * <map>.ini, two "x y z" lines: Terrorist base then CT base). Touching the enemy
8 + * flag picks it up (Ham_Touch); it then follows the carrier. Bringing it to your
9 + * own base while your flag is home scores a capture. Dropped flags auto-return,
10 + * and captures are tracked on the HUD.
11 + *
12 + * Inspired by CTF by Avalanche. Independent GPL re-implementation.
13 + *
14 + * This program is free software: you can redistribute it and/or modify it under
15 + * the terms of the GNU General Public License as published by the Free Software
16 + * Foundation, either version 3 of the License, or (at your option) any later
17 + * version. It is distributed in the hope that it will be useful, but WITHOUT
18 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 + * FOR A PARTICULAR PURPOSE. See <https://www.gnu.org/licenses/> for details.
20 + */
21 +
22 +#include <amxmodx>
23 +#include <fakemeta>
24 +#include <hamsandwich>
25 +
26 +new const PLUGIN[] = "CSB Capture The Flag"
27 +new const VERSION[] = "1.0.0"
28 +new const AUTHOR[] = "counter-strike-boost.com"
29 +
30 +#define FLAG_CLASS "csb_ctf_flag"
31 +#define FLAG_MODEL "models/w_backpack.mdl"
32 +#define CAP_RANGE2 6400.0 /* 80 units */
33 +
34 +new g_pEnabled
35 +
36 +new g_iFlagEnt[2]
37 +new Float:g_fHome[2][3]
38 +new g_iCarrier[2]
39 +new bool:g_bAtHome[2]
40 +new g_iScore[2]
41 +new bool:g_bReady
42 +new g_iHudSync
43 +
44 +public plugin_init()
45 +{
46 + register_plugin(PLUGIN, VERSION, AUTHOR)
47 +
48 + g_pEnabled = register_cvar("csb_ctf_enabled", "1")
49 +
50 + RegisterHam(Ham_Touch, FLAG_CLASS, "fwFlagTouch")
51 + register_event("DeathMsg", "eventDeath", "a", "1>0")
52 +
53 + g_iHudSync = CreateHudSyncObj()
54 +
55 + set_task(0.1, "taskFlags", 0, _, _, "b")
56 +}
57 +
58 +public plugin_precache()
59 +{
60 + engfunc(EngFunc_PrecacheModel, FLAG_MODEL)
61 +}
62 +
63 +public plugin_cfg()
64 +{
65 + if (loadBases())
66 + spawnFlags()
67 +}
68 +
69 +bool:loadBases()
70 +{
71 + new map[32]
72 + get_mapname(map, charsmax(map))
73 +
74 + new dir[128], path[192]
75 + get_localinfo("amxx_configsdir", dir, charsmax(dir))
76 +
77 + if (!dir[0])
78 + copy(dir, charsmax(dir), "addons/amxmodx/configs")
79 +
80 + formatex(path, charsmax(path), "%s/csb_ctf/%s.ini", dir, map)
81 +
82 + if (!file_exists(path))
83 + return false
84 +
85 + new line[96], len, pos = 0, n = 0
86 +
87 + while (n < 2 && (pos = read_file(path, pos, line, charsmax(line), len)))
88 + {
89 + trim(line)
90 +
91 + if (!line[0] || line[0] == ';' || line[0] == '#')
92 + continue
93 +
94 + new sx[16], sy[16], sz[16]
95 + parse(line, sx, charsmax(sx), sy, charsmax(sy), sz, charsmax(sz))
96 +
97 + if (!sx[0] || !sy[0] || !sz[0])
98 + continue
99 +
100 + g_fHome[n][0] = str_to_float(sx)
101 + g_fHome[n][1] = str_to_float(sy)
102 + g_fHome[n][2] = str_to_float(sz)
103 + n++
104 + }
105 +
106 + return (n == 2)
107 +}
108 +
109 +spawnFlags()
110 +{
111 + for (new i = 0; i < 2; i++)
112 + {
113 + new ent = engfunc(EngFunc_CreateNamedEntity, engfunc(EngFunc_AllocString, "info_target"))
114 +
115 + if (!ent)
116 + return
117 +
118 + set_pev(ent, pev_classname, FLAG_CLASS)
119 + engfunc(EngFunc_SetModel, ent, FLAG_MODEL)
120 + set_pev(ent, pev_solid, SOLID_TRIGGER)
121 + set_pev(ent, pev_movetype, MOVETYPE_NONE)
122 + set_pev(ent, pev_iuser1, i)
123 +
124 + engfunc(EngFunc_SetOrigin, ent, g_fHome[i])
125 +
126 + g_iFlagEnt[i] = ent
127 + g_iCarrier[i] = 0
128 + g_bAtHome[i] = true
129 + }
130 +
131 + g_bReady = true
132 +}
133 +
134 +/* flag i belongs to team (i==0 -> T(1), i==1 -> CT(2)) */
135 +flagTeam(i)
136 +{
137 + return i == 0 ? 1 : 2
138 +}
139 +
140 +public fwFlagTouch(flag, other)
141 +{
142 + if (!g_bReady || other < 1 || other > 32 || !is_user_alive(other))
143 + return HAM_IGNORED
144 +
145 + new i = pev(flag, pev_iuser1)
146 +
147 + if (i < 0 || i > 1)
148 + return HAM_IGNORED
149 +
150 + new team = get_user_team(other)
151 +
152 + /* touching your own flag returns it if it was dropped away from home */
153 + if (team == flagTeam(i))
154 + {
155 + if (!g_bAtHome[i] && g_iCarrier[i] == 0)
156 + returnFlag(i)
157 +
158 + return HAM_IGNORED
159 + }
160 +
161 + /* enemy flag: pick it up */
162 + if (g_iCarrier[i] == 0)
163 + {
164 + g_iCarrier[i] = other
165 + g_bAtHome[i] = false
166 +
167 + new name[32]
168 + get_user_name(other, name, charsmax(name))
169 + client_print(0, print_chat, "^x04[CTF]^x01 %s picked up the %s flag!", name, i == 0 ? "Terrorist" : "CT")
170 + }
171 +
172 + return HAM_IGNORED
173 +}
174 +
175 +returnFlag(i)
176 +{
177 + g_iCarrier[i] = 0
178 + g_bAtHome[i] = true
179 +
180 + if (pev_valid(g_iFlagEnt[i]))
181 + engfunc(EngFunc_SetOrigin, g_iFlagEnt[i], g_fHome[i])
182 +}
183 +
184 +public taskFlags()
185 +{
186 + if (!g_bReady || !get_pcvar_num(g_pEnabled))
187 + return
188 +
189 + for (new i = 0; i < 2; i++)
190 + {
191 + new c = g_iCarrier[i]
192 +
193 + if (c == 0 || !pev_valid(g_iFlagEnt[i]))
194 + continue
195 +
196 + if (!is_user_alive(c))
197 + {
198 + dropFlag(i)
199 + continue
200 + }
201 +
202 + /* flag follows the carrier */
203 + static Float:fPos[3]
204 + pev(c, pev_origin, fPos)
205 + fPos[2] += 20.0
206 + engfunc(EngFunc_SetOrigin, g_iFlagEnt[i], fPos)
207 +
208 + /* capture check: carrier at their own base with own flag home */
209 + new own = get_user_team(c) == 1 ? 0 : 1
210 +
211 + if (g_bAtHome[own])
212 + {
213 + static Float:fMe[3]
214 + pev(c, pev_origin, fMe)
215 +
216 + new Float:dx = fMe[0] - g_fHome[own][0]
217 + new Float:dy = fMe[1] - g_fHome[own][1]
218 + new Float:dz = fMe[2] - g_fHome[own][2]
219 +
220 + if (dx*dx + dy*dy + dz*dz < CAP_RANGE2)
221 + capture(c, i, own)
222 + }
223 + }
224 +
225 + drawHud()
226 +}
227 +
228 +capture(player, enemyFlag, ownIndex)
229 +{
230 + g_iScore[ownIndex]++
231 +
232 + new name[32]
233 + get_user_name(player, name, charsmax(name))
234 + client_print(0, print_chat, "^x04[CTF]^x01 %s captured the flag! Score - T:%d CT:%d", name, g_iScore[0], g_iScore[1])
235 +
236 + returnFlag(enemyFlag)
237 +}
238 +
239 +dropFlag(i)
240 +{
241 + new c = g_iCarrier[i]
242 + g_iCarrier[i] = 0
243 +
244 + if (c >= 1 && c <= 32)
245 + {
246 + static Float:fPos[3]
247 + pev(c, pev_origin, fPos)
248 + engfunc(EngFunc_SetOrigin, g_iFlagEnt[i], fPos)
249 + }
250 +
251 + /* auto-return after a delay */
252 + set_task(12.0, "taskAutoReturn", 3000 + i)
253 +}
254 +
255 +public taskAutoReturn(taskid)
256 +{
257 + new i = taskid - 3000
258 +
259 + if (i >= 0 && i <= 1 && g_iCarrier[i] == 0 && !g_bAtHome[i])
260 + {
261 + returnFlag(i)
262 + client_print(0, print_chat, "^x04[CTF]^x01 The %s flag returned to base.", i == 0 ? "Terrorist" : "CT")
263 + }
264 +}
265 +
266 +public eventDeath()
267 +{
268 + new victim = read_data(2)
269 +
270 + for (new i = 0; i < 2; i++)
271 + if (g_iCarrier[i] == victim)
272 + dropFlag(i)
273 +}
274 +
275 +public client_disconnected(id)
276 +{
277 + for (new i = 0; i < 2; i++)
278 + if (g_iCarrier[i] == id)
279 + dropFlag(i)
280 +}
281 +
282 +drawHud()
283 +{
284 + set_hudmessage(0, 200, 255, 0.02, 0.10, 0, 0.0, 0.3, 0.0, 0.0, -1)
285 + ShowSyncHudMsg(0, g_iHudSync, "CTF T:%d CT:%d", g_iScore[0], g_iScore[1])
286 +}
+31 -0 csb.json A
@@ -0,0 +1,31 @@
1 +{
2 + "name": "CSB Capture The Flag",
3 + "category": "gameplay",
4 + "tags": "ctf, flags, objective",
5 + "image": "",
6 + "original_author": "Avalanche",
7 + "original_url": "",
8 + "license": "GPL-3.0",
9 + "title": "CSB Capture The Flag",
10 + "short_desc": "A capture-the-flag layer: two flags at per-map bases, pick up the enemy flag by touch, carry it home to score, with auto-return and a HUD scoreboard.",
11 + "version": "1.0.0",
12 + "amxx_min": "1.9",
13 + "amxx_compile_default": "1.9",
14 + "rehlds_ok": true,
15 + "hlds_ok": true,
16 + "regamedll_required": false,
17 + "metamod_flavor": "any",
18 + "reapi_required": false,
19 + "modules": "fakemeta,hamsandwich",
20 + "install_notes": "1. Enable the fakemeta and hamsandwich modules in addons/amxmodx/configs/modules.ini\n2. Create addons/amxmodx/configs/csb_ctf/<map>.ini with two x y z base lines\n3. Put csb_ctf.amxx in addons/amxmodx/plugins/ and add it to plugins.ini\n4. Change map",
21 + "known_conflicts": "Without a per-map data file the plugin stays idle; the flag model must exist on the server.",
22 + "cvars": [
23 + {
24 + "name": "csb_ctf_enabled",
25 + "default": "1",
26 + "description": "Enable or disable capture the flag."
27 + }
28 + ],
29 + "commands": [],
30 + "main": "addons/amxmodx/scripting/csb_ctf.sma"
31 +}
0 32