Forum

> > CS2D > Scripts > Fix my script!
Forums overviewCS2D overview Scripts overviewLog in to reply

English Fix my script!

8 replies
To the start Previous 1 Next To the start

old Fix my script!

KabirDuy
User Off Offline

Quote
It does not work as soon as I add:
1
2
elseif x == 59 and y == 57 then
 menu (id, "Grocery 1, Donuts | 250 $, Sandwich | $ 500, Candy | $ 350, Cow's Milk | $ 700")
Does 2 elseif a conflict? help me edit!

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
addhook("use","usebuttonworkaround")
function usebuttonworkaround(id)
     local x,y=player(id,"tilex"),player(id,"tiley")
     if x==18 and y==38 then
    menu(id,"Handgun Shop,USP|500$,Glock|400$,Deagle|650$,P228|600$,Elite|1000$,Five Seven|750$")
     elseif x==33 and y==38 then
 menu(id,"Sub Machine Gun,TMP|1250$,MP5|1500$,P90|2350$,UMP45|1700$,MAC10|1400$,Primary Ammo|350$")
     elseif x==59 and y==57 then
 menu(id,"Grocery 1,Donuts|250$,Sandwich|500$,Candy|350$,Cow's milk|700$")
end
end
	 
addhook("menu","buymenu")
function buymenu(id,title,buton)
if title=="Handgun Shop" then
if buton==1 then
	if player(id,"money")>=500 then
		parse("equip "..id.." 1")
		parse("setweapon "..id.." 1")
		msg2(id,"©000255000You successfully bought USP!@C")
		parse("setmoney "..id.." "..(player(id,"money")-500))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

end
elseif buton==2 then
	if player(id,"money")>=400 then
		parse("equip "..id.." 2")
		parse("setweapon "..id.." 2")
		msg2(id,"©000255000You successfully bought Glock!@C")
		parse("setmoney "..id.." "..(player(id,"money")-400))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

end
elseif buton==3 then
	if player(id,"money")>=650 then
		parse("equip "..id.." 3")
		parse("setweapon "..id.." 3")
		msg2(id,"©000255000You successfully bought Deagle!@C")
		parse("setmoney "..id.." "..(player(id,"money")-650))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

end
elseif buton==4 then
	if player(id,"money")>=600 then
		parse("equip "..id.." 4")
		parse("setweapon "..id.." 4")
		msg2(id,"©000255000You successfully bought P228!@C")
		parse("setmoney "..id.." "..(player(id,"money")-600))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

end
elseif buton==5 then
	if player(id,"money")>=1000 then
		parse("equip "..id.." 5")
		parse("setweapon "..id.." 5")
		msg2(id,"©000255000You successfully bought Elite!@C")
		parse("setmoney "..id.." "..(player(id,"money")-1000))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

end
elseif buton==6 then
	if player(id,"money")>=750 then
		parse("equip "..id.." 6")
		parse("setweapon "..id.." 6")
		msg2(id,"©000255000You successfully bought Five Seven!@C")
		parse("setmoney "..id.." "..(player(id,"money")-750))
	else
		msg2(id,"©255000000You have insufficient funds!@C")
end
end
end
if title=="Sub Machine Gun" then
if buton==1 then
	if player(id,"money")>=1250 then
		parse("equip "..id.." 21")
		parse("setweapon "..id.." 21")
		msg2(id,"©000255000You successfully bought TMP!@C")
		parse("setmoney "..id.." "..(player(id,"money")-1250))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

end
elseif buton==2 then
	if player(id,"money")>=1500 then
		parse("equip "..id.." 20")
		parse("setweapon "..id.." 20")
		msg2(id,"©000255000You successfully bought MP5!@C")
		parse("setmoney "..id.." "..(player(id,"money")-1500))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

end
elseif buton==3 then
	if player(id,"money")>=2350 then
		parse("equip "..id.." 22")
		parse("setweapon "..id.." 22")
		msg2(id,"©000255000You successfully bought P90!@C")
		parse("setmoney "..id.." "..(player(id,"money")-2350))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

end
elseif buton==4 then
	if player(id,"money")>=1700 then
		parse("equip "..id.." 24")
		parse("setweapon "..id.." 24")
		msg2(id,"©000255000You successfully bought UMP45!@C")
		parse("setmoney "..id.." "..(player(id,"money")-1700))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

end
elseif buton==5 then
	if player(id,"money")>=1400 then
		parse("equip "..id.." 23")
		parse("setweapon "..id.." 23")
		msg2(id,"©000255000You successfully bought MAC10!@C")
		parse("setmoney "..id.." "..(player(id,"money")-1400))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

end
elseif buton==6 then
	if player(id,"money")>=350 then
		parse("equip "..id.." 61")
		parse("setweapon "..id.." 61")
		msg2(id,"©000255000You successfully bought Primary Ammo Seven!@C")
		parse("setmoney "..id.." "..(player(id,"money")-350))
	else
		msg2(id,"©255000000You have insufficient funds!@C")
end
end
end

if title=="Grocery 1" then
if buton==1 then
	if player(id,"money")>=250 then
		parse("sethealth "..id.." 13")
		msg2(id,"©000255000You successfully bought Donuts!@C")
		parse("setmoney "..id.." "..(player(id,"money")-250))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

end
if buton==2 then
	if player(id,"money")>=500 then
		parse("sethealth "..id.." 30")
		msg2(id,"©000255000You successfully bought Sandwich!@C")
		parse("setmoney "..id.." "..(player(id,"money")-500))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

end
if buton==3 then
	if player(id,"money")>=350 then
		parse("sethealth "..id.." 20")
		msg2(id,"©000255000You successfully bought Candy!@C")
		parse("setmoney "..id.." "..(player(id,"money")-350))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

end
if buton==4 then
	if player(id,"money")>=700 then
		parse("sethealth "..id.." 55")
		msg2(id,"©000255000You successfully bought Cow's Milk!@C")
		parse("setmoney "..id.." "..(player(id,"money")-700))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

end
end
end
end
edited 3×, last 23.03.13 11:56:17 am

old Re: Fix my script!

Rainoth
Moderator Off Offline

Quote
More >

old Re: Fix my script!

DC
Admin Off Offline

Quote
Proper indention would have saved your day user KabirDuy. You would instantly see which end belongs to which if / elseif / function. That's why you should indent all your code properly.

old Re: Fix my script!

KabirDuy
User Off Offline

Quote
user Rainoth has written
More >

Please tell you how to fix it? I need to know to add a few menu.

old Re: Fix my script!

Rainoth
Moderator Off Offline

Quote
user KabirDuy has written
user Rainoth has written
More >

Please tell you how to fix it? I need to know to add a few menu.


DC Is correct. I was quite irritated when I saw your code, but since I obviously didn't have time (and I don't now) I just left it as it is and fixed. You can fix your IF codes simply. If you are too lazy to TAB your code then just count all IFs FORs and give the same amount of ends as well as end for function. The mistake you had was that you made a menu with ~6 IFs and none of them had ends so I just changed ~5 of them into "elseif" to avoid pointless counting. Look in console for error. If it says "eof" it's most likely that you have too many ends and if it says "end" expected to close bla bla bla near bla bla then you are missing an end. And again I'll repeat. If you tab your code, it will become a LOT more easier to understand everything not only for others but for yourself too...

old Re: Fix my script!

Avo
User Off Offline

Quote
1
parse("sethealth "..id.." 13")
Does not heal player, but sets his/her hp to 13.
Use this:
1
parse("sethealth "..id.." "..(player(id,"health")+13))
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview