Forum

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

Englisch Menu

13 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt Menu

Flame
BANNED Off Offline

Zitieren
addhook("serveraction","info")
function info(id,act)
if act==2 then
menu(id,"Information,Mapper,Scripter")
end
end

how to make when you press Mapper or Scripter it displays a message

alt Re: Menu

Yates
Reviewer Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
10
addhook("menu","stuff")
function stuff(id,button,title)
	if title=="Information" then
		if button==1 then
			msg2(id,"Your message here")
		elseif button==2 then
			msg2(id,"Your message here")
		end
	end
end
You forgot to add the menu. You only added the serveraction to open it.

alt Re: Menu

3RROR
User Off Offline

Zitieren
user Flame hat geschrieben
addhook("serveraction","info")
function info(id,act)
if act==2 then
menu(id,"Information,Mapper,Scripter")
end
end

how to make when you press Mapper or Scripter it displays a message


1
2
3
4
5
6
7
8
9
10
addhook("serveraction","info")
function info(id,act,men)
if act==2 then
menu(id,"Information,Mapper,Scripter")
if men == [[Mapper] then
parse(msg "Textwhatyouwant")
end
if men == [[Scripter] then -- Continue
end
end
I guess it's that way
4× editiert, zuletzt 17.09.11 20:51:18

alt Re: Menu

Yates
Reviewer Off Offline

Zitieren
@Tauma Tizer, I'm not sure if that will work. As the addhook should (I don't know this for sure) be menu.
AND PLEASE TAB YOUR CODE

I'm not sure the script will work at all. Why did you add an end in the middle of the code, and where is the message for button 2?

AND WHAT THE FUCK IS if men == [[mapper] then !?

alt Re: Menu

Yates
Reviewer Off Offline

Zitieren
I find your "Lua" very confusing. Seriously. I don't understand what you just wrote.

alt Re: Menu

Yates
Reviewer Off Offline

Zitieren
What? It should. Add it under your lua. Don't just use mine, then of course it wouldn't work.

Edit: Ah, wait. Change title and button around.
Here, paste this over the original function (The lua I posted);
1
function stuff(id,title,button)
I had a problem once with id and team, I changed them around and it worked. Maybe this is the case here aswell.
1× editiert, zuletzt 17.09.11 21:18:50

alt Re: Menu

Flacko
User Off Offline

Zitieren
You've got the parameters order wrong.
title is the second argument while button is the third.

edit: whoops, too late

alt Re: Menu

Yates
Reviewer Off Offline

Zitieren
user Flacko hat geschrieben
title is the second argument while button is the third.

Why, actually?

alt Re: Menu

Flacko
User Off Offline

Zitieren
user Yates hat geschrieben
user Flacko hat geschrieben
title is the second argument while button is the third.

Why, actually?


Because CS2D passes the values in that order.
The way you name the variables that hold these values doesn't really matter.
The only thing that really matters is that the second parameter of the hook is the menu title and the third one is the clicked button.

alt Re: Menu

Flame
BANNED Off Offline

Zitieren
So can anybody tell me the right script ?

alt Re: Menu

Yates
Reviewer Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
10
addhook("menu","stuff")
function stuff(id,title,button) -- Title and button have been switched.
	if title=="Information" then
		if button==1 then
			msg2(id,"Your message here")
		elseif button==2 then
			msg2(id,"Your message here")
		end
	end
end
Use this with your script.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht