Forum

> > CS2D > Scripts > unexpected symbol near "i"
Forums overviewCS2D overview Scripts overviewLog in to reply

English unexpected symbol near "i"

9 replies
To the start Previous 1 Next To the start

old unexpected symbol near "i"

Dovahkin
User Off Offline

Quote
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
medic = 0
warrior = 0
class = 0
wall = 0

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

caps=initArray(32)

addhook("spawn","heyya")
function heyya(id)
	parse("sethealth "..id.." 1")
end

addhook("join","spawned")
function spawned(id)
	parse('hudtxt2 '..id..' 2 "©000128255Your class : " 13 220')
	parse('hudtxt2 '..id..' 3 "©255255255You have : '..caps[id]..' Caps" 13 240')
end

addhook("serveraction","action")
function action(id,a)
	if a==1 then
		if medic == 1 then
			menu(id,"Your@b,Healing Hand|Costs : 200$ and 5 caps - Drops 1 bandage")
		end
		if warrior == 1 then
			menu(id,"Your skills [Warrior]@b,Accepted Faith|Costs : 15 caps - Gives a armor boost for a short time")
		end
	end
end

addhook("usebutton","button")
function button(id,tx,ty)
	if (tx == 12 and ty == 5) then
		if class == 0 then
			menu(id,"Pick your class!@b,Medic|Does heal teammates too!,Warrior|A veteran and a war fighter,Banker|A useful person for skills that costs money")
		end
	end
end

addhook("menu","menud")
function menud(id,title,button)
	if (title=="Pick your class!") then
		if button==1 then
			if class == 0 then
				if medic == 0 then
					msg2(id,"©000255255You're now a Medic!@C")
					parse('hudtxt2 '..id..' 2 "©000128255Your class : ©000255000Medic" 13 220')
					msg2(id,"©255000255You have now access to the wall! Goodluck!")
					parse("sethealth "..id.." 100")
					caps[id] = caps[id]+50
					medic = 1
					class = 1
					update(id)
				end
			end
		end
		if button==2 then
			if class == 0 then
				if warrior == 0 then
					msg2(id,"©000255255You're now a Warrior!")
					parse('hudtxt2 '..id..' 2 "000128255Your class : ©000255000Warrior" 13 220')
					msg2(id,"©255000255You have now access to the wall! Goodluck!")
					parse("sethealth "..id.." 100")
					caps[id] = caps[id]+100
					warrior = 1
					class = 1
					update(id)
				end
			end
		end
	end
	if (title=="Your") then
		if button==1 then
			if caps[id] >= 5 then
				parse("spawnitem 65 "..player(id,"tilex").." "..player(id,"tiley").."")
				parse("setmoney "..id.." "..player(id,"money")-100)
				caps[id] = caps[id]-5
				msg2(id,"©128255000You used the Healing Hand!@C")
				update(id)
			else
				msg2(id,"©255128000Not enough money")
			end
		end
	end
	if (title=="Your skills [Warrior]") then
		if button==1 then
			if caps[id] >= 15 then
				parse("setarmor "..id.." 150")
				msg2(id,"©128255000You increased your armor for a short time!@C")
				caps[id] = caps[id]-15
				update(id)
				function speedx ()
				parse("setarmor "..id.." 0")
				msg2(id,"©128000000Your armor has worned off!@C")
			end
				timer(6000,"speedx")
			else
				msg2(id,"©255128000Not enough money!")
		end
	end
end

addhook("movetile","tile")
function tile(id,tx,ty)
	if (tx == 14 and ty == 3) then
		if class == 0 then
			msg2(id,"Please pick your class!@C")
		end
	end
	if (tx == 14 and ty == 3) then
		if class == 1 then
			msg2(id,"Welcome!@C")
			parse("trigger w1")
			parse("trigger d1")
		end
	end
end

addhook("die","ifdie")
function ifdie(id)
	if medic == 1 then
		if class == 1 then
			parse('hudtxt2 '..id..' 2 "©000128255Your class : ©000255000Medic" 13 220')
		end
	end
	if warrior == 1 then
		if class == 1 then
			parse('hudtxt2 '..id..' 2 "©©000128255Your class : ©000255000Warrior" 13 220')
		end
	end
end

function update(id)
hudx = 290
hudy = 440
parse('hudtxt2 '..id..' 3 "©255255255You have : '..caps[id]..' Caps" 13 240')
end
end

There are three errors I have been having. Before it worked. Now it dont. I need serious help guys!

> The error is :
unexpected symbol near "i"
It doesn't give me caps anymore
Attempt to call global 'update' (a nil value)

old Re: unexpected symbol near "i"

Dovahkin
User Off Offline

Quote
unexpected symbol near "i"
It doesn't give me caps anymore
Attempt to call global 'update' (a nil value)

Three known errors found.

old Re: unexpected symbol near "i"

Devil-Thanh
GAME BANNED Off Offline

Quote
I suggest you should check which function the error in. For example this is my way:

> first you delete a function you doubt it has an error.
> save and start. If the error still apears, ctrl+Z to back up your function and check another.
> repeat it with all functions may help you know where the error is(in which function).

If you try to post all of it here, it's annoyed much and people will be lazy to read and fnd an error.

old Re: unexpected symbol near "i"

DC
Admin Off Offline

Quote
Always copy and paste the exact error message please. It normally should contain something like a number which stands for the line were the error occurred. This makes it 100 times easier to find the problem in long scripts.

old Re: unexpected symbol near "i"

Avo
User Off Offline

Quote
Fixed code >


I suggest you to use more&code tags on US.de.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview