Forum

> > CS2D > Scripts > Lua Can't Proces
Forums overviewCS2D overview Scripts overviewLog in to reply

English Lua Can't Proces

2 replies
To the start Previous 1 Next To the start

old Lua Can't Proces

MilK
User Off Offline

Quote
Hi all
I have make a lua but can't use

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
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
function toTable(t,match)
    local cmd = {}
    if not match then
         match = "[^%s]+"
    else
         match = "[^"..match.."]+"
    end
    for word in string.gmatch(t, match) do
        table.insert(cmd, word)
    end
    return cmd
end

function initArray(m)
	local array = {}
	for i = 1, m do
		array[i] = 0
	end
return array
end

kills=initArray(32)
bindwpna=initArray(32)
bindwpnb=initArray(32)
bindarmor=initArray(32)
hp=initArray(32)
speed=initArray(32)
ccp=initArray(32)
ccs=initArray(32)
bindarmorc=initArray(32)
bindwpnac=initArray(32)
bindwpnbc=initArray(32)

addhook("minute","help")
function help()
	msg("©000255000Say coinmenu to open menu")
end

addhook("spawn","nonil")
function nonil(id)
	if kills[id]==nil then kills[id]=0 end
end

addhook("hit","ck")
function ck(id,source,wpn,dmg)
	if player(source,"bot") then
		if dmg>=player(id,"health") then
			parse('customkill '..source..' "Anti Gun" '..id)
			return 1
		end
	end
end

addhook("kill","score")
function score(id)
	kills[id]=kills[id]+2
	parse('hudtxt2 '..id..' 1 "©000255000 Coins: '..kills[id]..'" 10 410 0') 
end

addhook("spawn","viewscore")
function viewscore(id)
	parse('hudtxt2 '..id..' 1 "©000255000 Coins: '..kills[id]..'" 10 410 0') 
end

addhook("spawn","botsetup")
function botsetup(id)
	if player(id,"bot") then
		parse("equip "..id.." 30")
		parse("strip "..id.." 74")
		parse("setmaxhealth "..id.." 100")
		parse("speedmod "..id.." -5")
	end
end

addhook("build","no_site")
function no_site(id,type)
	if (type == 21) then
		return 0
	else
		return 1
	end
end

buildingmoney = {0,0,0,0,0,0,0,0}

addhook("build","no_sitenow")
function no_sitenow(id,type,x,y)
	if (type == 21) then
		return 0
	else
		parse("spawnobject "..type.." "..x.." "..y.." 90 1 "..player(id,"team").." "..id)
	end
end

addhook("build","money_loose")
function money_loose(id,type)
	if (type == 1) then
		parse("setmoney "..id.." "..player(id,"money")-buildingmoney[1])
	elseif (type == 2) then
		parse("setmoney "..id.." "..player(id,"money")-buildingmoney[2])
	elseif (type == 3) then
		parse("setmoney "..id.." "..player(id,"money")-buildingmoney[3])
	elseif (type == 4) then
		parse("setmoney "..id.." "..player(id,"money")-buildingmoney[4])
	elseif (type == 5) then
		parse("setmoney "..id.." "..player(id,"money")-buildingmoney[5])
	elseif (type == 6) then
		parse("setmoney "..id.." "..player(id,"money")-buildingmoney[6])
	elseif (type == 7) then
		parse("setmoney "..id.." "..player(id,"money")-buildingmoney[7])
	elseif (type == 8) then
		parse("setmoney "..id.." "..player(id,"money")-buildingmoney[7])
	elseif (type == 9) then
		parse("setmoney "..id.." "..player(id,"money")-buildingmoney[7])
	elseif (type == 13) then
		parse("setmoney "..id.." "..player(id,"money")-buildingmoney[8])
	elseif (type == 14) then
		parse("setmoney "..id.." "..player(id,"money")-buildingmoney[8])
	end
end

parse('mp_building_limit "Turret" 99999')
parse('mp_building_limit "Gate field" 99999')
parse('mp_building_health "dispenser" 99999')
parse('mp_building_health "turret" 99999')
parse('mp_building_health "supply" 99999')
parse('mp_building_health "gate field" 99999')
parse('mp_building_health "wall I" 99999')
parse('mp_building_health "wall II" 99999')
parse('mp_building_health "wall III" 99999')
parse('mp_building_health "barbed wire" 99999')
parse('mp_building_health "Barricade" 99999')
parse('mp_building_health "teleporter exit" 99999')
parse('mp_building_health "teleporter entrance" 99999')



addhook("say","buymenu")
function buymenu(id,text)
	if text=="coinmenu" then
		menu(id,"Menu,Spawn Armor,Set Speed")
	end
end

addhook("serveraction","openmenu")
function openmenu(id,t)
	if (t==1) then
		menu(id,"Which One,Kevlar,Kevlar+Helmet,Light Armor,Armor,Heavy Armor,Medic Armor,Super Armor")
	end
	if (t==2) then
		menu(id,"Which One,5 Speed Mod,10 Speed Mod,15 Speed Mod,20 Speed Mod,Admin Speed|40")
	end
end

addhook("menu","contrlalmenus")
function contrlalmenus(id,menuu,sel)
	if (menuu=="Which One") then
		if (sel==1) then
			if kills[id]<=15 then
				msg2(id,"©255000000You dont have coins to buy that armor!@C")
			elseif kills[id]>=15 then
				kills[id]=kills[id]-15
				parse('hudtxt2 '..id..' 1 "©000255000 Coins: '..kills[id]..'" 10 410 0') 
				msg2(id,"©000255000You have bought Kevlar!@C")
				parse("spawnitem "..id.." 57")
			end
		end
		if (sel==2) then
			if kills[id]<=30 then
				msg2(id,"©255000000You dont have coins to buy that armor!@C")
			elseif kills[id]>=30 then
				kills[id]=kills[id]-30
				parse('hudtxt2 '..id..' 1 "©000255000 Coins: '..kills[id]..'" 10 410 0') 
				msg2(id,"©000255000You have bought Kevlar + Helm!@C")
				parse("spawnitem "..id.." 58")
			end
		end
		if (sel==3) then
			if kills[id]<=100 then
				msg2(id,"©255000000You dont have coins to buy that armor!@C")
			elseif kills[id]>=100 then
				kills[id]=kills[id]-100
				parse('hudtxt2 '..id..' 1 "©000255000 Coins: '..kills[id]..'" 10 410 0') 
				msg2(id,"©000255000You have bought Light Armor!@C")
				parse("spawnitem "..id.." 79")
			end
		end
		if (sel==4) then
			if kills[id]<=150 then
				msg2(id,"©255000000You dont have coins to buy that armor!@C")
			elseif kills[id]>=150 then 
				kills[id]=kills[id]-150
				parse('hudtxt2 '..id..' 1 "©000255000 Coins: '..kills[id]..'" 10 410 0') 
				msg2(id,"©000255000You have bought Armor!@C")
				parse("spawnitem "..id.." 80")
			end
		end
		if (sel==5) then
			if kills[id]<=200 then
				msg2(id,"©255000000You dont have coins to buy that armor!@C")
			elseif kills[id]>=200 then
				kills[id]=kills[id]-200
				parse('hudtxt2 '..id..' 1 "©000255000 Coins: '..kills[id]..'" 10 410 0') 
				msg2(id,"©000255000You have bought Heavy Armor!@C")
				parse("spawnitem "..id.." 81")
			end
		end
		if (sel==6) then
			if kills[id]<=500 then
				msg2(id,"©255000000You dont have coins to buy that armor!@C")
			elseif kills[id]>=500 then
				kills[id]=kills[id]-500
				parse('hudtxt2 '..id..' 1 "©000255000 Coins: '..kills[id]..'" 10 410 0') 
				msg2(id,"©000255000You have bought Medic Armor!@C")
				parse("spawnitem "..id.." 82")
			end
		end
		if (sel==7) then
			if kills[id]<=1000 then
				msg2(id,"©255000000You dont have coins to buy that armor!@C")
			elseif kills[id]>=1000 then 
				kills[id]=kills[id]-1000
				parse('hudtxt2 '..id..' 1 "©000255000 Coins: '..kills[id]..'" 10 410 0') 
				msg2(id,"©000255000You have bought Super Armor!@C")
				parse("spawnitem "..id.." 83")
			end
		end
	end
	if (menuu=="Set Speed") then
		if (sel==1) then
			if speed[id]>4 then
				msg2 (id,"©255000000You cannot buy more speed updates!@C")
			elseif speed[id]<=10 then
				if kills[id]<=50 then
					msg2(id,"©255000000You dont have coins to buy that update!@C")
				elseif kills[id]>=50 then
					kills[id]=kills[id]-500
					parse('hudtxt2 '..id..' 1 "©000255000 Coins: '..kills[id]..'" 10 410 0') 
					msg2(id,"©000255000You have bought Speed update!(Speed incrased by 10!)@C")
					speed[id]=speed[id]+1
					if speed[id]<=1 then
						parse("speedmod "..id.." 5")
					elseif speed[id]<=2 and	speed[id]>=1 then
						parse("speedmod "..id.." 10")
					elseif speed[id]<=3 and	speed[id]>=2 then
						parse("speedmod "..id.." 15")
					elseif speed[id]<=4 and	speed[id]>=3 then
						parse("speedmod "..id.." 20")
					elseif speed[id]<=5 and	speed[id]>=4 then
						parse("speedmod "..id.." 40")
					end	
				end
			end
		end
	end

addhook("spawn","spawncontroll")
function spawncontroll(id)
	menu(id,"Weapon menu,Select primary weapon,Select secondary weapon")
	if speed[id]==1 then parse("speedmod "..id.." 5") end
	if speed[id]==2 then parse("speedmod "..id.." 10") end
	if speed[id]==3 then parse("speedmod "..id.." 15") end
	if speed[id]==4 then parse("speedmod "..id.." 20") end
	if speed[id]==5 then parse("speedmod "..id.." 40") end
	if bindarmor[id]==1 then parse("equip "..id.." 57") end
	if bindarmor[id]==2 then parse("equip "..id.." 58") end
	if bindarmor[id]==3 then parse("equip "..id.." 79") end
	if bindarmor[id]==4 then parse("equip "..id.." 80") end
	if bindarmor[id]==5 then parse("equip "..id.." 81") end
	if bindarmor[id]==6 then parse("equip "..id.." 82") end
	if bindarmor[id]==7 then parse("equip "..id.." 83") end
end
	
-------------------------------
addhook("leave","savefile")
function savefile(id)
	if player(id,"exists") and player(id,"usgn")>0 then
		f = assert(io.open("sys/lua/defsaves/"..player(id,"usgn")..".txt","w"))
		f:write(kills[id].." "..bindarmor[id].." "..speed[id]..")
		f:close()
	end
end

addhook("join","loadfile")
function loadfile(id)
	local prs
	if player(id,"usgn")>0 then
		f = io.open("sys/lua/coinsaves/"..player(id,"usgn")..".txt","r")
		if (f ~= nil) then
				msg2(id,"©000255000Your save file is found!@C")
				for line in f:lines() do
					prs=toTable(line)
					kills[id]=tonumber(prs[1])
					bindarmor[id]=tonumber(prs[2])
					speed[id]=tonumber(prs[3])
				break
				end
			f:close()
		else
		msg2(id,"©255000000Yours save file is not found, Sorry!!@C")
		end
	end
end

Thanks All cookie

old Re: Lua Can't Proces

DC
Admin Off Offline

Quote
and you can't use it why? what's your problem? what happens or doesn't happen? what's the error message? in which line does it occur? please be more specific, otherwise we can't help.

old Re: Lua Can't Proces

MilK
User Off Offline

Quote
I think It there
Spoiler >


Thankscookie
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview