English Just something about menu

3 replies
Goto Page
To the start Previous 1 Next To the start
31.12.17 06:09:33 pm
Up
WiFi
User
Offline Off
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
31.12.17 06:25:51 pm
Up
Code:
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
31.12.17 07:18:43 pm
Up
Fraizeraust
Moderator
Offline Off
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 Yu's code but I believe it should work.
31.12.17 07:34:03 pm
Up
script favor
User
Offline Off
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
Code:
1
x
Code:
1
y
in map.
Visit my website : https://bounty-mafia.tk , Discord : https://discord.gg/ntNd6TX, IMG:http://i60.tinypic.com/5kixc8.gif
To the start Previous 1 Next To the start