Forum

> > CS2D > Scripts > Changing ammo for any weapon?
Forums overviewCS2D overview Scripts overviewLog in to reply

English Changing ammo for any weapon?

5 replies
To the start Previous 1 Next To the start

old Changing ammo for any weapon?

Q-Q
User Off Offline

Quote
Is there any way with lua that you can change the ammo of a weapon? I know weapons are hard coded but there must be a way with lua to do this...
And also it would be helpfull if you take ammo that the gun increases with one single bullet.
Btw i need this for the pistol (glock)
Help would be nice

old Re: Changing ammo for any weapon?

EP
User Off Offline

Quote
this script simulates the additional ammo
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
wpn = 2
function Array(size,value) 
    local array = {}
    for i = 1, size do
        array[i]=value
    end
    return array
end

aammo = Array(32,0)

function hudtext2(id,tid,color,txt,x,y)
     local toprint = ("©"..color.." "..txt)
     parse('hudtxt2 '..id..' '..tid..' "'..toprint..'" '..x.." "..y)
end

function ahud(id)
	hudtext2(id,1,"255255000","Additional Ammo = "..aammo[id],450,368)
end
function uhud(id,A,B)
	hudtext2(id,1,"255255000","Additional Ammo = "..(aammo[id]+A+B),450,368)
end

addhook("walkover","a")
function a(id,iid,type,aa,am)
	if type == wpn then
		local A = aa
		local B = am
		uhud(id,A,B)
		aammo[id] = aammo[id]+A+B
		parse("removeitem "..iid)
		return 1
	end
end
		
addhook("spawn","c")
function c(id)
	aammo[id] = 0
	ahud(id)
end

addhook("attack","d")
function d(id)
	if player(id,"weapontype") == wpn then
		if aammo[id] > 0 then
			aammo[id] = aammo[id] - 1
			parse("setweapon "..id.." "..wpn)
			parse("equip "..id.." "..wpn)
			uhud(id,-1,0)
		end
	end
end
'-'
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview