Forum

> > CS2D > Scripts > my snowball script error
Forums overviewCS2D overview Scripts overviewLog in to reply

English my snowball script error

2 replies
To the start Previous 1 Next To the start

old my snowball script error

MikuAuahDark
User Off Offline

Quote
hi all, i create new lua again, but it's error. console only says: Lua Error: Attempt to call a nil value, not showing line. i don't know where error. here my code script:
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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
-- 6 snowball type by Rian2_idih
function Array(i,v)
	local array = {}
	for i = 1, i do
		array[i]=v
	end
	return array
end

function totable(t,m)
	local cmd = {}
	if not match then match = "[^%s]+" end
	for word in string.gmatch(t,m) do
		table.insert(cmd, word)
	end
	return cmd
end

snowballprice = {500,1000,750,300,300,2000}

expsnow = Array(32,false)
normsnow = Array(32,true)
flashsnow = Array(32,false)
telesnow = Array(32,false)
shuriken = Array(32,false)
smokesnow = Array(32,false)
expleft = Array(32,0)
normleft = Array(32,5)
flashleft = Array(32,0)
smokeleft = Array(32,0)
teleleft = Array(32,0)
shurikenleft = Array(32,0)

addhook("serveraction","_sva")
function _sva(id,sva)
	if sva==1 then
		if player(id,"health")>0 then
			menu(id,"Buy snowball,Normal Snowball|500 $,Explode Snowball|1000 $,Shuriken|750 $,Flash Snowball|300 $,Smoke Snowball|300 $,Teleport Snowball|2000 $")
		else
			msg2(id,"©255000000You are dead, can't buy snowball LOL")
		end
	elseif sva==2 then
		if player(id,"health")>0 then
			menu(id,"Snowballs,Normal Snowball ("..normleft[id].."),Explode Snowball ("..expleft[id].."),Shuriken ("..shurikenleft[id].."),Flash Snowball ("..flashleft[id].."),Smoke Snowball ("..smokeleft[id].."),Teleport Snowball ("..teleleft[id]..")")
		else
			msg2(id,"©255000000You are dead")
		end
	end
end

addhook("attack","_attack")
function _attack(id)
	if player(id,"weapontype")==75 then
	if normsnow[id]==true or expsnow[id]==true or shuriken[id]==true or flashsnow[id]==true or smokesnow[id]==true or telesnow[id]==true then
		if player(id,"weapontype")==75 then
			parse("equip "..id.." 75")
		end
	end
	if normsnow[id]==true then
		normleft[id]=normleft[id]-1
	elseif expsnow[id]==true then
		expleft[id]=expleft[id]-1
	elseif shuriken[id]==true then
		shurikenleft[id]=shurikenleft[id]-1
	elseif flashsnow[id]==true then
		flashleft[id]=flashleft[id]-1
	elseif smokesnow[id]==true then
		smokeleft[id]=smokeleft[id]-1
	elseif telesnow[id]==true then
		teleleft[id]=teleleft[id]-1
	end
	if normsnow[id]==true and normleft[id]==0 then
		normsnow[id]=false
		parse("strip "..id.." 75")
	elseif expsnow[id]==true and expleft[id]==0 then
		expsnow[id]=false
		parse("strip "..id.." 75")
	elseif shuriken[id]==true and shurikenleft[id]==0 then
		shuriken[id]=false
		parse("strip "..id.." 75")
	elseif flashsnow[id]==true and flashleft[id]==0 then
		flashsnow[id]=false
		parse("strip "..id.." 75")
	elseif smokesnow[id]==true and smokeleft[id]==0 then
		smokesnow[id]=false
		parse("strip "..id.." 75")
	elseif telesnow[id]==true and teleleft[id]==0 then
		telesnow[id]=false
		parse("strip "..id.." 75")
	end
end
end

addhook("projectile","_projectile")
function _projectile(id,w,x,y)
	if w==75 then
	if expsnow[id]==true then
		parse("explosion "..x.." "..y.." 32 999999 "..id)
	elseif flashsnow[id]==true then
		parse("flashposition "..x.." "..y.." 500")
	elseif smokesnow[id]==true then
		parse("effect \"smoke\" "..x.." "..y.." 256 64")
	elseif telesnow[id]==true then
		parse("effect \"smoke\" "..player(id,"x").." "..player(id,"y").." 256 64")
		parse("effect \"smoke\" "..x.." "..y.." 256 64")
		parse("setpos "..id.." "..x.." "..y)
	end
end
end

addhook("menu","_menu")
function _menu(id,title,sel)
	local UserMoney = player(id,"money")
	if title == "Buy snowball" then
		if sel==1 then
			if UserMoney>=snowballprice[1] then
				parse("setmoney "..id.." "..UserMoney-snowballprice[1])
				normleft[id]=normleft[id]+1
			else
				msg2(id,"©255000000Not Enough Money@C")
			end
		elseif sel==2 then
			if UserMoney>=snowballprice[2] then
				parse("setmoney "..id.." "..UserMoney-snowballprice[2])
				expleft[id]=expleft[id]+1
			else
				msg2(id,"©255000000Not Enough Money@C")
			end
		elseif sel==3 then
			if UserMoney>=snowballprice[3] then
				parse("setmoney "..id.." "..UserMoney-snowballprice[1])
				shurikenleft[id]=shurikenleft[id]+1
			else
				msg2(id,"©255000000Not Enough Money@C")
			end
		elseif sel==4 then
			if UserMoney>=snowballprice[4] then
				parse("setmoney "..id.." "..UserMoney-snowballprice[4])
				flashleft[id]=flashleft[id]+1
			else
				msg2(id,"©255000000Not Enough Money@C")
			end
		elseif sel==5 then
			if UserMoney>=snowballprice[5] then
				parse("setmoney "..id.." "..UserMoney-snowballprice[5])
				smokeleft[id]=smokeleft[id]+1
			else
				msg2(id,"©255000000Not Enough Money@C")
			end
		elseif sel==6 then
			if UserMoney>=snowballprice[6] then
				parse("setmoney "..id.." "..UserMoney-snowballprice[6])
				teleleft[id]=teleleft[id]+1
			else
				msg2(id,"©255000000Not Enough Money@C")
			end
		end
	end
	if title == "Snowballs" then
		if sel==1 then
			if normsnow[id]==false then
				if normleft[id]>0 then
					normsnow[id]=true
					expsnow[id]=false
					shuriken[id]=false
					flashsnow[id]=false
					smokesnow[id]=false
					telesnow[id]=false
					parse("equip "..id.." 75")
				else
					msg2(id,"©255000000You don't have Normal Snowball")
				end
			else
				normsnow[id]=false
				parse("strip "..id.." 75")
			end
		elseif sel==2 then
			if expsnow[id]==false then
				if expleft[id]>0 then
					normsnow[id]=false
					expsnow[id]=true
					shuriken[id]=false
					flashsnow[id]=false
					smokesnow[id]=false
					telesnow[id]=false
					parse("equip "..id.." 75")
				else
					msg2(id,"©255000000You don't have Explosive Snowball")
				end
			else
				expsnow[id]=false
				parse("strip "..id.." 75")
			end
		elseif sel==3 then
			if shuriken[id]==false then
				if shurikenleft[id]>0 then
					normsnow[id]=false
					expsnow[id]=false
					shuriken[id]=true
					flashsnow[id]=false
					smokesnow[id]=false
					telesnow[id]=false
					parse("equip "..id.." 75")
				else
					msg2(id,"©255000000You don't have Shuriken Snowball")
				end
			else
				shuriken[id]=false
				parse("strip "..id.." 75")
			end
		elseif sel==4 then
			if flashsnow[id]==false then
				if flashleft[id]>0 then
					normsnow[id]=false
					expsnow[id]=false
					shuriken[id]=false
					flashsnow[id]=true
					smokesnow[id]=false
					telesnow[id]=false
					parse("equip "..id.." 75")
				else
					msg2(id,"©255000000You don't have Flash Snowball")
				end
			else
				flashsnow[id]=false
				parse("strip "..id.." 75")
			end
		elseif sel==5 then
			if smokesnow[id]==false then
				if smokeleft[id]>0 then
					normsnow[id]=false
					expsnow[id]=false
					shuriken[id]=false
					flashsnow[id]=false
					smokesnow[id]=true
					telesnow[id]=false
					parse("equip "..id.." 75")
				else
					msg2(id,"©255000000You don't have Smoke Snowball")
				end
			else
				smokesnow[id]=false
				parse("strip "..id.." 75")
			end
		elseif sel==6 then
			if telesnow[id]==false then
				if teleleft[id]>0 then
					normsnow[id]=false
					expsnow[id]=false
					shuriken[id]=false
					flashsnow[id]=false
					smokesnow[id]=false
					telesnow[id]=true
					parse("equip "..id.." 75")
				else
					msg2(id,"©255000000You don't have Teleport Snowball")
				end
			else
				smokesnow[id]=false
				parse("strip "..id.." 75")
			end
		end
	end
end

addhook("hit","_hit")
function hit(id,pl,weapon,x,y)
	if weapon==75 then
		if shuriken[pl]==true then
			parse("customkill "..pl.." 'Shuriken Snowball' "..id)
			return 1
		end
	end
	return 0
end

addhook("die","_die")
function _die(id,pl,weapon,x,y)
	if normsnow[id]==true or expsnow[id]==true or shuriken[id]==true or flashsnow[id]==true or smokesnow[id]==true or telesnow[id]==true then
		normsnow[id]=false
		expsnow[id]=false
		shuriken[id]=false
		flashsnow[id]=false
		smokesnow[id]=false
		telesnow[id]=false
	end
end
this script not complete, there no save system but i want this error fixed first
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview