![](img/smiles/bigsmile.gif)
Forum
![>](img/i_next.png)
![>](img/icons/cs2d.png)
![>](img/i_next.png)
![>](img/i_next.png)
Ho do i make an inf ammo? (W/o reloading)
11 Antworten![Zum Anfang](img/i_first.png)
![Vorherige](img/i_prev.png)
![Nächste](img/i_next.png)
![Zum Anfang](img/i_last.png)
![](img/smiles/bigsmile.gif)
1
parse("mp_infammo 1");
![cs2d cmd](img/i_codehelp.png)
Without reloading:
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
--untested addhook("attack","atk") function atk(id) local itemType = player(id,"weapontype"); parse("setammo "..id.." "..itemType.." 999 999"); end
![cs2d cmd](img/i_codehelp.png)
![user](img/i_friend.png)
You can hide ammo with
![cs2d cmd](img/i_codehelp.png)
Set ammo only when it is less than 1
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
--untested addhook("attack","atk") function atk(id) local itemType = player(id,"weapontype"); if (playerammo(id,itemType) <= 1) then -- if ammo amount (ammoin) is less than 2 parse("setammo "..id.." "..itemType.." 999 999"); -- fill up ammo&ammoin end end
![cs2d cmd](img/i_codehelp.png)
![cs2d lua cmd](img/i_codehelp.png)
![cs2d lua cmd](img/i_codehelp.png)
Thanks, @
![user](img/i_friend.png)
![user](img/i_friend.png)
<= 10
![user](img/i_friend.png)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
--untested refillCap = 0.33 -- Reload ammo on 33% of its maximum capacity addhook("attack","atk") function atk(id) 	local itemType = player(id,"weapontype"); 	AmmoRefill(playerammo(id,itemType), itemType); end addhook("collect", "garbage") function garbage(id,iid,itype, ain) 	AmmoRefill(ain,itype) end function AmmoRefill(ammoIn, itemType) 	if (ammoIn <= itemtype(itemType,"ammoin") * refillCap) then 		parse("setammo "..id.." "..itemType.." 999 999"); -- fill up ammo&ammoin 	end 	return false; end
![cs2d cmd](img/i_codehelp.png)
![cs2d lua cmd](img/i_codehelp.png)
![cs2d lua cmd](img/i_codehelp.png)
![cs2d lua cmd](img/i_codehelp.png)
Lets make it ping dependent
![](img/smiles/ugly.gif)
![user](img/i_friend.png)
![user](img/i_friend.png)
For example, you create a table and a for-loop to iterate through the table.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
myGunzWithInfAmmo = { 45, 3, 2 }; addhook("attack","atk") function atk(id) local itemType = player(id,"weapontype"); for _,v in ipairs(myGunzWithInfAmmo) do if (v == itemType) { 		AmmoRefill(playerammo(id,itemType), itemType); 		 return; 	 end end end
Note the return in line 16: Once you found your weapon, you can stop searching.
Depending on the amount of weapons you need with infinite ammo, you maybe want to "invert" the table (=> make a table 'myGunzWithoutInfAmmo'), so you dont need to go over too much weapons
![file](img/i_file.png)
![cs2d](img/icons/cs2d.png)
Enjoy
![](img/smiles/bigsmile.gif)
![user](img/i_friend.png)
![](img/smiles/bigsmile.gif)
![Zum Anfang](img/i_first.png)
![Vorherige](img/i_prev.png)
![Nächste](img/i_next.png)
![Zum Anfang](img/i_last.png)