Forum

> > CS2D > Scripts > Menu Disappears
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch Menu Disappears

8 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Menu Disappears

Dovahkin
User Off Offline

Zitieren
Hello! How can I make a script that whenever I press something the choice disappears. Example :
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
1
menu(id,"Container,,Take garbage")

alt Re: Menu Disappears

Livia
User Off Offline

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

alt Re: Menu Disappears

EngiN33R
Moderator Off Offline

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

alt Re: Menu Disappears

Dovahkin
User Off Offline

Zitieren
Oh my. This is fantastic. Thank you.

EDIT!

Whenever I press the button it gives me an error.

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

Still the same code that you used @user EngiN33R:
3× editiert, zuletzt 04.10.13 17:31:27

alt Re: Menu Disappears

pbeloto
User Off Offline

Zitieren
user Dovahkin hat geschrieben
Oh my. This is fantastic. Thank you.

EDIT!

Whenever I press the button it gives me an error.

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

Still the same code that you used @user EngiN33R:


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

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:

alt Sorry for being late :)

Avo
User Off Offline

Zitieren
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 >

alt Re: Menu Disappears

Dovahkin
User Off Offline

Zitieren
@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?
1× editiert, zuletzt 21.10.13 00:19:59
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht