Initial release 1.0.0
Browse Source1.0.0 - Initial release.
4 changed files
with 206 additions and 0 deletions
A
CHANGELOG.md
+3 -0
A
README.md
+3 -0
A
addons/amxmodx/scripting/csb_weapon_models.sma
+163 -0
A
csb.json
+37 -0
CHANGELOG.md
A
| @@ -0,0 +1,3 @@ | ||
| 1 | +## 1.0.0 (2025-10-25) | |
| 2 | + | |
| 3 | +1.0.0 - Initial release. |
README.md
A
| @@ -0,0 +1,3 @@ | ||
| 1 | +<p><strong>CSB Weapon Models</strong> swaps the view (<code>v_</code>) and world (<code>p_</code>) models of any weapon for your own, driven by a plain ini file. Models are precached at map start; on every <code>CurWeapon</code> the plugin writes the custom model into <code>pev_viewmodel2</code> / <code>pev_weaponmodel2</code>. Players who prefer the stock look can turn it off for themselves with <code>/wmodels</code>.</p><h2>Configuration</h2><p>Create <code>addons/amxmodx/configs/csb_weapon_models.ini</code> with one weapon per line:</p><pre>ak47 models/csb/v_ak47.mdl models/csb/p_ak47.mdl | |
| 2 | +awp models/csb/v_awp.mdl models/csb/p_awp.mdl | |
| 3 | +knife models/csb/v_knife.mdl models/csb/p_knife.mdl</pre><p>Accepted names: knife, usp, glock, deagle, p228, elite, fiveseven, m4a1, ak47, awp, scout, aug, sg552, galil, famas, m3, xm1014, mp5, tmp, mac10, ump45, p90, m249, sg550, g3sg1. Only entries whose model files exist are precached.</p><h2>Features</h2><ul><li>ini-driven, no recompile to change models.</li><li>View and world models both supported per weapon.</li><li>Per-player <code>/wmodels</code> toggle back to the default models.</li><li>Missing files are logged and skipped, never crashing the server.</li></ul><h2>Installation</h2><ol><li>Enable the <code>fakemeta</code> module in <code>modules.ini</code> (default on).</li><li>Put your <code>.mdl</code> files where the ini points and add them to your fastdl.</li><li>Compile, copy <code>csb_weapon_models.amxx</code> into <code>plugins/</code>, add it to <code>plugins.ini</code>, change map.</li></ol><p>Inspired by the classic "Weapon Model Replacement" by Emp`; independent GPL re-implementation.</p> |
addons/amxmodx/scripting/csb_weapon_models.sma
A
| @@ -0,0 +1,163 @@ | ||
| 1 | +/* | |
| 2 | + * CSB Weapon Models | |
| 3 | + * Copyright (C) 2026 counter-strike-boost.com | |
| 4 | + * | |
| 5 | + * Replaces the view (v_) and world/weapon (p_) models per weapon from a simple | |
| 6 | + * ini file. Models are precached at map start; on every CurWeapon the plugin | |
| 7 | + * writes the custom model into pev_viewmodel2 / pev_weaponmodel2. Players can | |
| 8 | + * toggle back to the default models for themselves. | |
| 9 | + * | |
| 10 | + * Inspired by "Weapon Model Replacement" by Emp`. This is an independent GPL | |
| 11 | + * re-implementation; no original code is reused. | |
| 12 | + * | |
| 13 | + * This program is free software: you can redistribute it and/or modify it under | |
| 14 | + * the terms of the GNU General Public License as published by the Free Software | |
| 15 | + * Foundation, either version 3 of the License, or (at your option) any later | |
| 16 | + * version. It is distributed in the hope that it will be useful, but WITHOUT ANY | |
| 17 | + * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR | |
| 18 | + * A PARTICULAR PURPOSE. See <https://www.gnu.org/licenses/> for details. | |
| 19 | + */ | |
| 20 | + | |
| 21 | +#include <amxmodx> | |
| 22 | +#include <amxmisc> | |
| 23 | +#include <fakemeta> | |
| 24 | + | |
| 25 | +new const PLUGIN[] = "CSB Weapon Models" | |
| 26 | +new const VERSION[] = "1.0.0" | |
| 27 | +new const AUTHOR[] = "counter-strike-boost.com" | |
| 28 | + | |
| 29 | +#define MAX_WEAPONS 31 | |
| 30 | +#define INI_FILE "csb_weapon_models.ini" | |
| 31 | + | |
| 32 | +new g_szView[MAX_WEAPONS + 1][64] | |
| 33 | +new g_szWorld[MAX_WEAPONS + 1][64] | |
| 34 | +new bool:g_bDefault[33] | |
| 35 | + | |
| 36 | +new g_pEnabled | |
| 37 | + | |
| 38 | +/* human-friendly names accepted in the ini, mapped to CSW_* ids */ | |
| 39 | +new const g_szNames[][] = | |
| 40 | +{ | |
| 41 | + "knife", "usp", "glock", "glock18", "deagle", "p228", "elite", | |
| 42 | + "fiveseven", "m4a1", "ak47", "awp", "scout", "aug", "sg552", | |
| 43 | + "galil", "famas", "m3", "xm1014", "mp5", "mp5navy", "tmp", "mac10", | |
| 44 | + "ump45", "p90", "m249", "sg550", "g3sg1" | |
| 45 | +} | |
| 46 | + | |
| 47 | +new const g_iNameCsw[] = | |
| 48 | +{ | |
| 49 | + CSW_KNIFE, CSW_USP, CSW_GLOCK18, CSW_GLOCK18, CSW_DEAGLE, CSW_P228, CSW_ELITE, | |
| 50 | + CSW_FIVESEVEN, CSW_M4A1, CSW_AK47, CSW_AWP, CSW_SCOUT, CSW_AUG, CSW_SG552, | |
| 51 | + CSW_GALIL, CSW_FAMAS, CSW_M3, CSW_XM1014, CSW_MP5NAVY, CSW_MP5NAVY, CSW_TMP, CSW_MAC10, | |
| 52 | + CSW_UMP45, CSW_P90, CSW_M249, CSW_SG550, CSW_G3SG1 | |
| 53 | +} | |
| 54 | + | |
| 55 | +public plugin_init() | |
| 56 | +{ | |
| 57 | + register_plugin(PLUGIN, VERSION, AUTHOR) | |
| 58 | + | |
| 59 | + g_pEnabled = register_cvar("csb_wmodels_enabled", "1") | |
| 60 | + | |
| 61 | + register_clcmd("say /wmodels", "cmdToggle") | |
| 62 | + register_clcmd("say_team /wmodels", "cmdToggle") | |
| 63 | + | |
| 64 | + register_event("CurWeapon", "fwCurWeapon", "be", "1=1") | |
| 65 | +} | |
| 66 | + | |
| 67 | +public plugin_precache() | |
| 68 | +{ | |
| 69 | + loadModels() | |
| 70 | +} | |
| 71 | + | |
| 72 | +loadModels() | |
| 73 | +{ | |
| 74 | + new configsDir[128], path[192] | |
| 75 | + get_configsdir(configsDir, charsmax(configsDir)) | |
| 76 | + formatex(path, charsmax(path), "%s/%s", configsDir, INI_FILE) | |
| 77 | + | |
| 78 | + if (!file_exists(path)) | |
| 79 | + { | |
| 80 | + log_amx("[CSB Weapon Models] %s not found - no custom models loaded.", path) | |
| 81 | + return | |
| 82 | + } | |
| 83 | + | |
| 84 | + new line[192], name[32], vmodel[64], pmodel[64], lineNum = 0, loaded = 0, tlen | |
| 85 | + | |
| 86 | + while (read_file(path, lineNum++, line, charsmax(line), tlen)) | |
| 87 | + { | |
| 88 | + trim(line) | |
| 89 | + | |
| 90 | + if (!line[0] || line[0] == ';' || line[0] == '/' || line[0] == '#') | |
| 91 | + continue | |
| 92 | + | |
| 93 | + /* format: <weaponname> <v_model.mdl> <p_model.mdl> */ | |
| 94 | + new count = parse(line, name, charsmax(name), vmodel, charsmax(vmodel), pmodel, charsmax(pmodel)) | |
| 95 | + | |
| 96 | + if (count < 2) | |
| 97 | + continue | |
| 98 | + | |
| 99 | + new csw = nameToCsw(name) | |
| 100 | + | |
| 101 | + if (csw < 0) | |
| 102 | + continue | |
| 103 | + | |
| 104 | + if (vmodel[0] && file_exists(vmodel)) | |
| 105 | + { | |
| 106 | + precache_model(vmodel) | |
| 107 | + copy(g_szView[csw], charsmax(g_szView[]), vmodel) | |
| 108 | + } | |
| 109 | + | |
| 110 | + if (count >= 3 && pmodel[0] && file_exists(pmodel)) | |
| 111 | + { | |
| 112 | + precache_model(pmodel) | |
| 113 | + copy(g_szWorld[csw], charsmax(g_szWorld[]), pmodel) | |
| 114 | + } | |
| 115 | + | |
| 116 | + loaded++ | |
| 117 | + } | |
| 118 | + | |
| 119 | + log_amx("[CSB Weapon Models] loaded %d weapon model entries.", loaded) | |
| 120 | +} | |
| 121 | + | |
| 122 | +nameToCsw(const name[]) | |
| 123 | +{ | |
| 124 | + for (new i = 0; i < sizeof(g_szNames); i++) | |
| 125 | + { | |
| 126 | + if (equali(name, g_szNames[i])) | |
| 127 | + return g_iNameCsw[i] | |
| 128 | + } | |
| 129 | + | |
| 130 | + return -1 | |
| 131 | +} | |
| 132 | + | |
| 133 | +public client_putinserver(id) | |
| 134 | +{ | |
| 135 | + g_bDefault[id] = false | |
| 136 | +} | |
| 137 | + | |
| 138 | +public cmdToggle(id) | |
| 139 | +{ | |
| 140 | + g_bDefault[id] = !g_bDefault[id] | |
| 141 | + | |
| 142 | + client_print(id, print_chat, "[CSB] Custom weapon models are now %s for you.", | |
| 143 | + g_bDefault[id] ? "OFF (default models)" : "ON") | |
| 144 | + | |
| 145 | + return PLUGIN_HANDLED | |
| 146 | +} | |
| 147 | + | |
| 148 | +public fwCurWeapon(id) | |
| 149 | +{ | |
| 150 | + if (!get_pcvar_num(g_pEnabled) || g_bDefault[id] || !is_user_alive(id)) | |
| 151 | + return | |
| 152 | + | |
| 153 | + new csw = read_data(2) | |
| 154 | + | |
| 155 | + if (csw < 1 || csw > MAX_WEAPONS) | |
| 156 | + return | |
| 157 | + | |
| 158 | + if (g_szView[csw][0]) | |
| 159 | + set_pev(id, pev_viewmodel2, engfunc(EngFunc_AllocString, g_szView[csw])) | |
| 160 | + | |
| 161 | + if (g_szWorld[csw][0]) | |
| 162 | + set_pev(id, pev_weaponmodel2, engfunc(EngFunc_AllocString, g_szWorld[csw])) | |
| 163 | +} |
csb.json
A
| @@ -0,0 +1,37 @@ | ||
| 1 | +{ | |
| 2 | + "name": "CSB Weapon Models", | |
| 3 | + "category": "weapons", | |
| 4 | + "tags": "models, skins, v_model", | |
| 5 | + "image": "", | |
| 6 | + "original_author": "Emp` (Weapon Model Replacement)", | |
| 7 | + "original_url": "", | |
| 8 | + "license": "GPL-3.0", | |
| 9 | + "title": "CSB Weapon Models", | |
| 10 | + "short_desc": "Replaces view and world weapon models from a simple ini file, applied on CurWeapon, with a per-player toggle back to default models.", | |
| 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", | |
| 20 | + "install_notes": "1. Ensure the fakemeta module is enabled in modules.ini\n2. Create addons/amxmodx/configs/csb_weapon_models.ini (see the description)\n3. Upload your .mdl files and add them to fastdl\n4. Put csb_weapon_models.amxx in plugins/, add to plugins.ini, change map", | |
| 21 | + "known_conflicts": "Any other view-model replacement plugin - run only one.", | |
| 22 | + "cvars": [ | |
| 23 | + { | |
| 24 | + "name": "csb_wmodels_enabled", | |
| 25 | + "default": "1", | |
| 26 | + "description": "Enable or disable custom weapon models globally." | |
| 27 | + } | |
| 28 | + ], | |
| 29 | + "commands": [ | |
| 30 | + { | |
| 31 | + "name": "say /wmodels", | |
| 32 | + "access": "", | |
| 33 | + "description": "Toggle custom weapon models for yourself." | |
| 34 | + } | |
| 35 | + ], | |
| 36 | + "main": "addons/amxmodx/scripting/csb_weapon_models.sma" | |
| 37 | +} | |
| 0 | 38 |









