Forum
Scripts
Ho do i make an inf ammo? (W/o reloading)
Ho do i make an inf ammo? (W/o reloading)
11 replies
1

1
parse("mp_infammo 1");
mp_infammoWithout 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
setammo
Bowlinghead: Parsing on every attack is rather expensive. You can hide ammo with
mp_hudSet 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
setammo ,
playerammo ,
playerThanks, @
SQ!
Bowlinghead: I would set it higher, because of lags, eg. <= 10
Gaios: That would make it more frequent though. Even Deagle would always call it. 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
setammo ,
playerammo ,
player ,
itemtypeLets make it ping dependent
Bowlinghead: Can i make so its only affect on certain weapon (like making a table for the weapon id/name and then make an "if" statment for the weapon table)
Komo the Cat: Yes, you can. 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
Enjoy
Mami Tomoe: Thanks! I don't have to write a code for my zombie mod that i'll make soon if i have some free time. Thanks again
1

Offline