Forum

> > CS2D > Scripts > Buy menu Script isn't working- HARD
Forums overviewCS2D overview Scripts overviewLog in to reply

English Buy menu Script isn't working- HARD

12 replies
To the start Previous 1 Next To the start

old Buy menu Script isn't working- HARD

C0nan
User Off Offline

Quote
> Yes! I read whole console ANd after many errors, console was clean but still i had problem with script

Hello all! 2 days later i downloadet that script: http://www.unrealsoftware.de/files_show.php?file=7692 and I edited it by myself. BUT! There is my fault, it's not working! This is my code:
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
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
--Buy Script

addhook("serveraction","buyweapons")
function buyweapons(id,act)
if act==1 then
menu(id,"Buy,Handgun,Shotgun,Sub Machine Gun,Rifle,Machine Gun,Others,Primary Ammo|150$,Secondary Ammo|150$,Equipment")
	end
end

addhook("menu","buymenu")
function buymenu(id,title,buton)
if title=="Buy" then
if buton==1 then
menu(id,"Handgun,Glock|600$,P228|750$,Deagle|900$,Elite|1100$")
elseif buton==2 then
menu(id,"Shotgun,M3|2000$,XM1014|3400$")
elseif buton==3 then
menu(id,"Sub Machine Gun,TMP|1350$,MP5|1600$,UMP45|1800$,P90|2500$")
elseif buton==4 then
menu(id,"Rifle,Famas|2500$,AK47|2900$,Aug|3800$,Scout|4050$,AWP|6200$,G3SG1|6500$")
elseif buton==5 then
menu(id,"Machine Gun,M249|6900$")
elseif buton==6 then
menu(id,"Others,Flamethrower|16000$,RPG Launcher|8000$,Machete|4000$,Chainsaw|4200$,Mine|550$,Laser Mine|550$")
elseif buton==7 then
	if player(id,"money")>=150 then
		parse("equip "..id.." 61")
		msg2(id,"©000255000You bought Primary Ammo!@C")
		parse("setmoney "..id.." "..(player(id,"money")-150))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

end
elseif buton==8 then
	if player(id,"money")>=150 then
		parse("equip "..id.." 62")
		msg2(id,"©000255000You bought Secondary Ammo!@C")
		parse("setmoney "..id.." "..(player(id,"money")-150))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

end
elseif buton==9 then
menu(id,"Equipment,Tactical Shield|10000$,Throwable,Armors,Medicines")
end
end
if title=="Handgun" then
if buton==1 then
	if player(id,"money")>=600 then
		parse("equip "..id.." 2")
		msg2(id,"©000255000You bought Glock!@C")
		parse("setmoney "..id.." "..(player(id,"money")-600))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

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

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

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

end
end
end
if title=="Shotgun" then
if buton==1 then
	if player(id,"money")>=2000 then
		parse("equip "..id.." 10")
		msg2(id,"©000255000You bought M3!@C")
		parse("setmoney "..id.." "..(player(id,"money")-2000))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

end
elseif buton==2 then
	if player(id,"money")>=3400 then
		parse("equip "..id.." 11")
		msg2(id,"©000255000You bought XM1014!@C")
		parse("setmoney "..id.." "..(player(id,"money")-3400))
--100--
	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")>=1350 then
		parse("equip "..id.." 21")
		msg2(id,"©000255000You bought TMP!@C")
		parse("setmoney "..id.." "..(player(id,"money")-1350))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

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

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

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

end
end
end
if title=="Rifle" then
if buton==1 then
	if player(id,"money")>=2500 then
		parse("equip "..id.." 39")
		msg2(id,"©000255000You bought Famas!@C")
		parse("setmoney "..id.." "..(player(id,"money")-2500))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

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

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

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

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

end
elseif buton==6 then
	if player(id,"money")>=6500 then
		parse("equip "..id.." 36")
		msg2(id,"©000255000You bought G3SG1!@C")
		parse("setmoney "..id.." "..(player(id,"money")-6500))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

end
--200--
end
end
if title=="Machine Gun" then
if buton==1 then
	if player(id,"money")>=6900 then
		parse("equip "..id.." 40")
		msg2(id,"©000255000You bought M249!@C")
		parse("setmoney "..id.." "..(player(id,"money")-6900))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

end
end
end
if title=="Others" then
if buton==1 then
	if player(id,"money")>=15000 then
		parse("equip "..id.." 46")
		msg2(id,"©000255000You bought Flamethrower!@C")
		parse("setmoney "..id.." "..(player(id,"money")-15000))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

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

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

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

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

end
elseif buton==6 then
	if player(id,"money")>=550 then
		parse("equip "..id.." 87")
		msg2(id,"©000255000You bought Laser Mine!@C")
		parse("setmoney "..id.." "..(player(id,"money")-550))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

end
end
end
if title=="Equipment" then
if buton==1 then
	if player(id,"money")>=10000 then
		parse("equip "..id.." 41")
		msg2(id,"©000255000You bought Tactical Shield!@C")
		parse("setmoney "..id.." "..(player(id,"money")-10000))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

end
elseif buton==2 then
menu(id,"Throwable,He|600$,Molotov Cocktail|900$,Air Strike|2000$")
elseif buton==3 then
menu(id,"Armors,Kevlar|1000$,Light Armor|3000$,Armor|6000$")
elseif buton==4 then
menu(id,"Medicines,Medikit|1500$,Bandage|600$")
end
end
end
if title=="Throwable" then
if buton==1 then
	if player(id,"money")>=600 then
		parse("equip "..id.." 51")
		msg2(id,"©000255000You bought HE!@C")
		parse("setmoney "..id.." "..(player(id,"money")-600))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

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

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

end
end
end
if title=="Armors" then
if buton==1 then
	if player(id,"money")>=1000 then
		parse("equip "..id.." 57")
		msg2(id,"©000255000You bought Kevlar!@C")
		parse("setmoney "..id.." "..(player(id,"money")-1000))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

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

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

end
end
end
if title=="Medicines" then
if buton==1 then
	if player(id,"money")>=1500 then
		parse("equip "..id.." 64")
		msg2(id,"©000255000You bought Medikit!@C")
		parse("setmoney "..id.." "..(player(id,"money")-1500))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

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

end
end
end
Sorry i know it's too big but Everything is good until I open Equipment menu! I can buy Tactical Shield but nothing else! I want to reperair Armors, Throwable, Medicines.

Oh and Anonther thing: How to make this menu on trigger use??? because it's only on F2 and i want to change it. Thanks for help!
edited 1×, last 14.02.13 07:26:39 pm

old Re: Buy menu Script isn't working- HARD

C0nan
User Off Offline

Quote
egh hahaha I'm not good scripter idk what you are talking about, and i can't make better script can you give me some tips?
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
--Buy Script - IN MAPS FOLDER!!!

addhook("serveraction","buyweapons")
function buyweapons(id,act)
if act==1 then
menu(id,"Buy,Handgun,Shotgun,Sub Machine Gun,Rifle,Special Weapons,Primary Ammo|150$,Secondary Ammo|150$,Throwable,Protection,Medicine")
	end
end

addhook("menu","buymenu")
function buymenu(id,title,buton)
if title=="Buy" then
if buton==1 then
menu(id,"Handgun,Glock|600$,P228|750$,Deagle|900$,Elite|1100$")
elseif buton==2 then
menu(id,"Shotgun,M3|2000$,XM1014|3400$")
elseif buton==3 then
menu(id,"Sub Machine Gun,TMP|1350$,MP5|1600$,UMP45|1800$,P90|2500$")
elseif buton==4 then
menu(id,"Rifle,Famas|2500$,AK47|2900$,Aug|3800$,Scout|4050$,AWP|6200$,G3SG1|6500$")
elseif buton==5 then
menu(id,"Special Weapons,M249|6900$,Flamethrower|15000$,RPG Launcher|8000$,Machete|4000$,Chainsaw|4200$,Mine|550$,Laser Mine|550$")
elseif buton==6 then
	if player(id,"money")>=150 then
		parse("equip "..id.." 61")
		msg2(id,"©000255000You bought Primary Ammo!@C")
		parse("setmoney "..id.." "..(player(id,"money")-150))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

end
elseif buton==7 then
	if player(id,"money")>=150 then
		parse("equip "..id.." 62")
		msg2(id,"©000255000You bought Secondary Ammo!@C")
		parse("setmoney "..id.." "..(player(id,"money")-150))
	else
		msg2(id,"©255000000You have insufficient funds!@C")

end
elseif buton==8 then
menu(id,"Throwable,HE|600$,Molotov Cocktail|900$,Air Strike|2000$")
elseif buton==9 then
menu(id,"Protection,Kevlar|1000$,Light Armor|4000$,Armor|6000$,Tactical Shield|10000$")
elseif buton==10 then
menu(id,"Medicine,Medikit|1500$,Bandage|600$")
end
end
CODE is working! This is only little piece of it but can you help me to make it on trigger? edit this piece by yourself and i will end it.
edited 1×, last 15.02.13 01:08:31 am

old Re: Buy menu Script isn't working- HARD

EngiN33R
Moderator Off Offline

Quote
This script is very long, but you probably know that yourself. You could adapt file cs2d [EngiN33R] UniMenu to suit your needs and to shorten the code dramatically - I could try doing that later, but wouldn't cs2d cmd mp_buymenu do the job in this case? Even though it has its limitations it might do a better job of simulating a buy menu.

Also, what trigger?

old Re: Buy menu Script isn't working- HARD

C0nan
User Off Offline

Quote
ok I paste it and edited, and it looks like:
1
2
3
4
5
6
addhook("usebutton","AA_usebutton")
function AA_usebutton(id,x,y)
if entity(49, 10, "shop") ==_script_buy then
menu(id,"Buy,Handgun,Shotgun,Sub Machine Gun,Rifle,Special Weapons,Primary Ammo|150$,Secondary Ammo|150$,Throwable,Protection,Medicine")
	end
end
But it isn't working I check console but there where no errors

I tried also this:
1
2
3
4
5
6
7
8
9
10
addhook("usebutton","AA_usebutton")
addhook("usebutton","buyweapons")
function AA_usebutton(id,x,y)
function buyweapons(act)
if entity(49, 10, "shop") ==_script_buy then
elseif act==1 then
menu(id,"Buy,Handgun,Shotgun,Sub Machine Gun,Rifle,Special Weapons,Primary Ammo|150$,Secondary Ammo|150$,Throwable,Protection,Medicine")
end
end
end
It works but when i go somewhere on map and suddenly i press E near other entity trigger use it opens MENU but only once:( Sry for my English

old Re: Buy menu Script isn't working- HARD

Cure Pikachu
User Off Offline

Quote
• entity(49,10,"shop"): You are making it such that if the criteria for the entity at specifically (49,10) in tiles is fulfilled then the menu will pop up no matter which button you use. Just use the function's parameter x and y.
• entity(49,10,"shop"): Underlined parameter is invalid anyway. entity(x,y,"name") is fine as it is.
• _script_buy is a placeholder. Replace it with the name of the Trigger_Use entity.

E.g. If the name of the entity is simply buy then it would be like this:
1
2
3
4
5
6
addhook("usebutton","AA_usebutton")
function AA_usebutton(id,x,y)
	if entity(x,y,"name") == "buy" then
		menu(id,"Buy,Handgun,Shotgun,Sub Machine Gun,Rifle,Special Weapons,Primary Ammo|150$,Secondary Ammo|150$,Throwable,Protection,Medicine")
	end
end
Also, user omg & user Alistaire are right: Learn the basics (of mapping and scripting) first.
edited 1×, last 16.02.13 02:01:32 pm

old Re: Buy menu Script isn't working- HARD

C0nan
User Off Offline

Quote
Thx i tried it but i forgot to add " near entity name (eg. "buy") I know mapping very good but i'm learning scripts by practice.
EDIT: OMG! it's still not working!
EDIT 2: Maybe it's bugs fault?
EDIT 3: WORKS!!!
1
2
3
4
5
6
addhook("usebutton","AA_usebutton")
function AA_usebutton(id,x,y)
     if x == 47 and y == 10 then
          menu(id,"Buy,Handgun,Shotgun,Sub Machine Gun,Rifle,Special Weapons,Primary Ammo|150$,Secondary Ammo|150$,Throwable,Protection,Medicine")
	end
end
edited 3×, last 21.02.13 04:34:59 pm
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview