Forum

> > CS2D > Scripts > Just something about menu
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Just something about menu

3 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Just something about menu

WiFi
User Off Offline

Zitieren
Just a simple menu script,
It doesn't work,but i cannot find the reason at all.
Could you give me a hand.?
Sorry for my bad English.

Code:

addhook("usebutton","testbutton")
function testbutton(id,title,button)
if title =="Test" then
      if button == 1 then
parse("equip "..id.." 10")
parse("setweapon "..id.." 10")
          end
end
end     
function testbutton(id,x,y)
     if entity(x,y,"name") =="testbutton" then
      menu(id,"Test,xd")
end
end

alt Re: Just something about menu

Yunuu
User Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
addhook("menu","menu_hook")
function menu_hook(id,title,button) 
	if title =="Test" then
		if button == 1 then
			parse("equip "..id.." 10")
			parse("setweapon "..id.." 10")
		end
	end
end     

addhook("usebutton","testbutton")
function testbutton(id,x,y)
	if entity(x,y,"name") =="testbutton" then
		menu(id,"Test,xd")
	end
end

alt Re: Just something about menu

GeoB99
Moderator Off Offline

Zitieren
First of all, your code indentation is a complete clusterfuck and barely understandable. Please refer to this Lua Style guide about this. Also use the code tag to post your code instead of plain text.

Secondly, the first function has wrong arguments. cs2d lua hook usebutton's parameters are
id
,
x
and
y
whilst
testbutton()
passes
id
,
title
and
button
. I haven't tested user Yunuu's code but I believe it should work.

alt Re: Just something about menu

script favor
User Off Offline

Zitieren
First of all your forgot the local of the button that's why it doesn't give the items that you needed, also you need to locate the button by
1
x
1
y
in map.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht