Hello! This is a fairly simple script.
I'm aware that there are alternative scripts, but I'm certain that this one would stand out, as it is a lot faster and considerably more modern.
I took inspiration from the thread
Ho do i make an inf ammo? (W/o reloading).
That thread made me scratch my head a lot as I was seeing people struggle with a simple task.
As such, I decided to create this file.
This concept of no reload &/ infinite ammo was already thought of years ago, but this time I decided to make a superior version which takes both features and optimisation into account.
I took inspiration from the scripts on the archive aiming for the same goal.
I also took inspiration from the thread above.
And now, the features:

You can easily add &/ remove weapons and you can even enable the no reload function on all weapons

Will hide the ammo HUD

Will enable infinite ammo to counter strange cases where you'd run out of ammo, or pickup an empty weapon and be unable to reload.

I didn't include a reload hook to support the above, but that can easily be added manually, or requested. Though, it's really unnecessary

Easy to configure, read, understand and use

Highly efficient & compact

A single hook is used

Only one for loop is used, and it only runs at the beginning of the script (could be omitted, but remains for user simplicity)
Code w/o download 
Code:1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
------------------------------------------
-- Mami Tomoe's CS2D No Reload Script --
-- Signed on 28/01/2022 --
------------------------------------------
-- Configuration:
-- You can set this variable to `true` if
-- you wish for all weapons to have infinite ammo.
local infAmmo = { 1, 45, 3, 2 }
-- Recommended to be set at 33%, any higher will
-- cause more traffic and has no practical use.
-- Lower will support laggier players, but 33%
-- is the sweet spot.
local refillMultiplier = 0.33
-- Initialise workspace:
mt = mt or { }
mt.NoReload = mt.NoReload or { }
-- Local functions:
local function AmmoRefill(p, wpnType)
local ammoIn, _ = playerammo(p, wpnType)
local minAmmo = itemtype(wpnType, 'ammoin') * refillMultiplier
if ammoIn <= minAmmo then
parse('setammo ' .. p .. ' ' .. wpnType .. ' 999 999')
end
end
-- Hooks:
function mt.NoReload.attack_hook(p)
local wpnType = player(p, 'weapontype')
if infAmmo == true or infAmmo[wpnType] then
AmmoRefill(p, wpnType)
end
end
-- Module API:
local function init()
if infAmmo ~= true then
-- Quicker table access.
local t = { }
for i = 1, #infAmmo do
t[infAmmo[i]] = true
end
infAmmo = t
end
-- Enable infinite ammo.
parse('mp_infammo 1')
-- Hide ammo on HUD.
parse('mp_hud 119')
-- Sadly cannot hide ammo on dropped items.
-- parse('mp_hovertext 15')
-- Hooks.
addhook('attack', 'mt.NoReload.attack_hook')
end
init()
Developer note:
Yes, this can easily be made to run faster, but there's no need to over-optimise something that already works quickly enough.
If your server is struggling to run this script, then you should look for problems elsewhere, instead of assuming that I didn't optimise this enough.
edited 13×, last 29.01.22 10:21:37 pm