Forum

> > CS2D > Scripts > Just something about menu
Forums overviewCS2D overview Scripts overviewLog in to reply

English Just something about menu

3 replies
To the start Previous 1 Next To the start

old Just something about menu

WiFi
User Off Offline

Quote
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

old Re: Just something about menu

Yunuu
User Off Offline

Quote
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

old Re: Just something about menu

GeoB99
Moderator Off Offline

Quote
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.

old Re: Just something about menu

script favor
User Off Offline

Quote
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.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview