Forum

> > CS2D > Scripts > Buy menu doesnt work
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Buy menu doesnt work

8 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Buy menu doesnt work

alex72super
User Off Offline

Zitieren
Hello i made a buy menu but its doenst work:

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
addhook("serveraction","lol")
function lol(id,act)
     if act == 1
          menu(id,"Buy Guns,Deagle,M3,M4A1,AWP") then
     end
end

addhook("serveraction","ki")
function ki(id,act)
	 if act == 2
		 menu(id,"Buy HP,Bandage,Medikit")
	 end
end

if title=="Deagle" then
if buton==1 then
     if player(id,"money")>=600 then
          parse("equip "..id.." 3")
          msg2(id,"©000000255You bought a Deagle!@C")
          parse("setmoney "..id.." "..(player(id,"money")-600))
     else
          msg2(id,"©255000000You Don't have enough money!@C")
		end
	end
end

Can anyone help?

alt Re: Buy menu doesnt work

brofistmsia
User Off Offline

Zitieren
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
addhook('serveraction','serveraction_buymenu')
function serveraction_buymenu(id,act)
	if act==1 then
		menu(id,'Buy guns,Weapon')
	end
end

addhook('menu','menu_buymenu')
function menu_buymenu(id,title,buton)
	if title=='Buy guns' then
		if buton==1 then
			menu(id,'Weapon,Deagle|$100,M3|$100,M4A1|$100,AWP|$100')
		end
	end
	if title=='Weapon' then
		if buton==1 then
			if player(id,'money')>=100 then
				parse('setmoney '..id..' '..player(id,'money')-100)
				parse('equip '..id..' 3')
				parse('setweapon '..id..' 3')
			else
				msg('©255000000Money is low@C')
			end
		elseif buton==2 then
			if player(id,'money')>=100 then
				parse('setmoney '..id..' '..player(id,'money')-100)
				parse('equip '..id..' 10')
				parse('setweapon '..id..' 10')
			else
				msg('©255000000Money is low@C')
			end
		elseif buton==3 then
			if player(id,'money')>=100 then
				parse('setmoney '..id..' '..player(id,'money')-100)
				parse('equip '..id..' 32')
				parse('setweapon '..id..' 32')
			else
				msg('©255000000Money is low@C')
			end
		elseif buton==4 then
			if player(id,'money')>=100 then
				parse('setmoney '..id..' '..player(id,'money')-100)
				parse('equip '..id..' 35')
				parse('setweapon '..id..' 35')
			else
				msg('©255000000Money is low@C')
			end
		end
	end
end

one example for guns, the others, i have no time to write it, press f2. i just learn this 1 month ago

Admin/Mod Kommentar

Edited your post to include code indentation. Do yourself and all of us a favour and tab your code. /EngiN33R

alt Re: Buy menu doesnt work

GrizzlyAtlas
User Off Offline

Zitieren
there is a couple of times when you state a condition after an if but you don't compliment it with a then, I am not very experienced, I have only programmed a little in java so far, so tell my if I´m wrong.
for example:
if act == 1 then
menu(id,"Buy Guns,Deagle,M3,M4A1,AWP")
else...

alt Re: Buy menu doesnt work

Rainoth
Moderator Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
addhook("serveraction","lol")
function lol(id,b)
     if b == 1 then
          menu(id,"Buy Guns,Deagle,M3,M4A1,AWP")
     elseif b == 2 then
		menu(id,"Buy HP,Bandage,Medikit")
	end
end

addhook("menu","potato")
function potato(id,t,b)
local cash = player(id,"money")
	if t=="Buy Guns" then
		if b==1 then
    			if cash>=600 then
          			parse("equip "..id.." 3")
          			msg2(id,"©000000255You bought a Deagle!@C")
          			parse("setmoney "..id.." "..(player(id,"money")-600))
     			else
          			msg2(id,"©255000000You Don't have enough money!@C")
         		 end
     		end
	end
end

Don't use multiple hooks of same type. Add "then" for every "if" always check the name of menu you're making, use elseif instead of making another hook.

Sorry for tabbing, can't do it properly in reply.
1× editiert, zuletzt 09.09.13 14:58:45

alt Re: Buy menu doesnt work

alex72super
User Off Offline

Zitieren
Thank you all !

I am still learning lua and now im trying to do a zombie survival script thanks everyone

LUA ERROR: sys/lua/autorun/serveraction.lua:4: 'then' expected near 'menu'

Didnt work

EDIT2: Using user brofistmsia script it worked you'll be credited
2× editiert, zuletzt 09.09.13 14:55:05

alt Re: Buy menu doesnt work

alex72super
User Off Offline

Zitieren
user Dynamite07 hat geschrieben
Idea: would you like "cs2d cmd strip" so you cant have more than 1 pistol or 1 primary gun...


If you help me do it i would like that, im still learning lua and right now im making a script to use with the map(the map is done).
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht