English Menu Disappears

8 replies
Goto Page
To the start Previous 1 Next To the start
03.10.13 06:35:18 pm
Up
Dovahkin
User
Offline Off
Hello! How can I make a script that whenever I press something the choice disappears. Example :
Code:
1
menu(id,"Container,Take coins,Take garbage")
But when I press the "Take Coins" How do I make it disappear on the choices? After I presses the "take coins" it must be like this
Code:
1
menu(id,"Container,,Take garbage")
IMG:http://i561.photobucket.com/albums/ss59/killerboy_04/76561198036665859.png
03.10.13 10:15:34 pm
Up
Livia
User
Offline Off
You can store the buttons in a table and remove/modify the values when user makes his selection. Then you'll generate a string for your new menu based on this table.
Software has no limits.
04.10.13 01:33:10 am
Up
Dovahkin
User
Offline Off
How do you actually store it? Can you lend me an example?
IMG:http://i561.photobucket.com/albums/ss59/killerboy_04/76561198036665859.png
04.10.13 10:46:13 am
Up
EngiN33R
Moderator
Offline Off
Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
menutbl = {"Take coins","Take garbage"}

addhook("serveraction","openmenu")
function openmenu(id,a)
     if (a == 1) then
          menu(id,"Container,"..table.concat(menutbl,","))
     end
end

addhook("menu","selectinmenu")
function selectinmenu(id,title,b)
     if (title == "Container") then
          menutbl[b] = ""
          menu(id,"Container,"..table.concat(menutbl,","))
     end
end


This is the general structure of how this could be done. When you press F2, you open the menu, and upon pressing each button, the button disappears and the updated menu reopens.
I code, therefore I exist. | Visit my blog for Lua tips and other interesting info
04.10.13 11:24:41 am
Up
Dovahkin
User
Offline Off
Oh my. This is fantastic. Thank you.

EDIT!

Whenever I press the button it gives me an error.

The error :
Code:
1
server.lua:13: table index is nil


Still the same code that you used @user EngiN33R:
edited 3×, last 04.10.13 05:31:27 pm
IMG:http://i561.photobucket.com/albums/ss59/killerboy_04/76561198036665859.png
04.10.13 05:55:23 pm
Up
pbeloto
User
Offline Off
user Dovahkin has written:
Oh my. This is fantastic. Thank you.

EDIT!

Whenever I press the button it gives me an error.

The error :
Code:
1
server.lua:13: table index is nil


Still the same code that you used @user EngiN33R:


Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
menu_action = {"Take coins","Take garbage"}

addhook("serveraction","_serveraction")
function _serveraction(id,action)
     if action == 1 then
          menu(id,"Container,"..table.concat(menu_action,","))
     end
end

addhook("menu","_menu")
function _menu(id,title,buton)
     if title == "Container" then
          menu_action[buton] = "(None)"
          menu(id,"Container,"..table.concat(menu_action,","))
    end
end


or

Code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
menu_action = {"Medic Armor","Laser"}

addhook("serveraction","_serveraction")
function _serveraction(id,action)
     if action == 1 then
          menu(id,"Container,"..table.concat(menu_action,","))
     end
end

addhook("menu","_menu")
function _menu(id,title,buton)
     if title == "Container" then
          if buton == 1 then
               parse ("equip "..id.." 82")
          elseif buton == 2 then
               parse ("equip "..id.." 45")
          end
          menu_action[buton] = "(None)"
          menu(id,"Container,"..table.concat(menu_action,","))
    end
end


Credits : user EngiN33R:
04.10.13 06:52:53 pm
Up
Dovahkin
User
Offline Off
Bravo. Thank you both.


Moderators : Please close the thread
IMG:http://i561.photobucket.com/albums/ss59/killerboy_04/76561198036665859.png
05.10.13 11:12:51 pm
Up
Avo
User
Offline Off
Sorry for reviving this (not so old, but whatever) thread, but I haven't seen it and I think I can help you if you're interested in more universal version of script you asked for. I'm providing it here:
Code >

Clicking a button doesn't remove it, but deactivates it.
Additional info >
06.10.13 06:33:31 am
Up
Dovahkin
User
Offline Off
@user Avo: Thank you. I will try it too.

Edit

Sorry for reviving this.

@user EngiN33R: How do you make only one button disappear? Not the other buttons?
edited 1×, last 21.10.13 12:19:59 am
IMG:http://i561.photobucket.com/albums/ss59/killerboy_04/76561198036665859.png
To the start Previous 1 Next To the start