Forum

> > CS2D > Scripts > Lua script
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua script

6 replies
To the start Previous 1 Next To the start

old Lua script

Ekkoz
User Off Offline

Quote
I have a problem and I have no idea why it does not work, maybe something wrong ... can anyone tell me where is wrong?

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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
function initArray(m,v)
	local array = {}
	for i = 1, m do
		array[i]=0
	end
	return array
end

sol=initArray(32)
cry=initArray(32)
amm=initArray(32)

addhook("kill","dkill")
function dkill(k,v,w)
	sol[k]=sol[k]+1
	amm[k]=amm[k]+3
	if sol[k]==10 then
		cry[k]=cry[k]+1
		sol[k]=sol[k]-10
	end
	parse('hudtxt2 '..k..' 5 "\169200020020Crystal : '..cry[k]..'" 10 110 0')
	parse('hudtxt2 '..k..' 6 "\169255128000Soul : '..sol[k]..'" 10 130 0')
	parse('hudtxt2 '..k..' 7 "\169051153255Pack : '..amm[k]..'" 10 150 0')
end

addhook("second","dsec")
function dsec()
	for d=1,32 do
		parse('hudtxt2 '..d..' 5 "\169200020020Crystal : '..cry[d]..'" 10 110 0')
		parse('hudtxt2 '..d..' 6 "\169255128000Soul : '..sol[d]..'" 10 130 0')
		parse('hudtxt2 '..d..' 7 "\169051153255Pack : '..amm[d]..'" 10 150 0')
	end
end

addhook("spawn","dspawn")
function dspawn(id)
	parse('hudtxt2 '..id..' 5 "\169200020020Crystal : '..cry[id]..'" 10 110 0')
	parse('hudtxt2 '..id..' 6 "\169255128000Soul : '..sol[id]..'" 10 130 0')
	parse('hudtxt2 '..id..' 7 "\169051153255Pack : '..amm[id]..'" 10 150 0')
end

addhook("serveraction","dserv")
function dserv(id,a)
	if a==1 then
	menu(id,"Zombie Defend | Shop,Buy Weapon,Buy Armor")
    end
end

addhook("menu","zmenu")
function zmenu(id,t,b)
     if (t=="Zombie Defend | Shop") then
       if b==1 then
       menu(id,"Shop - Weapon | Cost,M4A1 | 5 Pack,Ak-47 | 5 Pack,M249 | 8 Pack,Flamethrower | 10 Crystal,Laser | 25 Crystal,Molotov Cocktail | 2 Pack")
       
       elseif b==2 then
       menu(id,"Shop - Armor | Cost,Small Armor | 10 Pack,Armor | 3 Crystal,Heavy Armor | 5 Crystal,Medic Armor | 10 Crystal,Super Armor | 30 Crystal")
       
       end
     end
end 

addhook("menu","wmenu")
function wmenu(id,t,b)
     if (t=="Shop - Weapon") then
       if b==1 and amm[id]>=5 then
		parse("equip "..id.." 32")
		amm[id]=amm[id]-5
	   
	   elseif b==2 and amm[id]>=5 then
		parse("equip "..id.." 30")
		amm[id]=amm[id]-5
	   
	   elseif b==3 and amm[id]>=8 then
		parse("equip "..id.." 40")
		amm[id]=amm[id]-8
	   
	   elseif b==4 and cry[id]>=10 then
		parse("equip "..id.." 46")
		cry[id]=cry[id]-10
	   
	   elseif b==5 and cry[id]>=25 then
		parse("equip "..id.." 45")
		cry[id]=cry[id]-25
	   
	   elseif b==6 and amm[id]>=2 then
		parse("equip "..id.." 73")
		amm[id]=amm[id]-2
       end		
     end
end
		
addhook("menu","amenu")
function amenu(id,t,b)	 
	 if (t=="Shop - Armor") then
	   if b==1 and amm[id]>=10 then
		parse("equip "..id.." 79")
		amm[id]=amm[id]-10
	   
	   elseif b==2 and cry[id]>=3 then
		parse("equip "..id.." 80")
		cry[id]=cry[id]-3
	   
	   elseif b==3 and cry[id]>=5 then
		parse("equip "..id.." 81")
		cry[id]=cry[id]-5
	   
	   elseif b==4 and cry[id]>=10 then
		parse("equip "..id.." 82")
		cry[id]=cry[id]-10
	   
	   elseif b==5 and cry[id]>=30 then
		parse("equip "..id.." 83")
		cry[id]=cry[id]-30
       end
     end
end

P.S : It's not entirely done by me, i just edited it and made it personalized .
Sorry for bad english ;3

old Re: Lua script

Mora
User Off Offline

Quote
Well, what console says?
What exactly is not working?

By the way dont use multiple hooks, use
elseif
for titles too

code >
edited 1×, last 30.07.17 12:21:05 pm

old Re: Lua script

Ekkoz
User Off Offline

Quote
When I want to buy something, it does not give me those items

old Re: Lua script

Mora
User Off Offline

Quote
Well, i added them in 1 hook and changed "title". Because it requires 100% exact name ^ read my previous post
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview