Forum

> > CS2D > Scripts > equip items with Lua menu
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch equip items with Lua menu

12 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt equip items with Lua menu

Flame
BANNED Off Offline

Zitieren
addhook("serveraction","server")
function server(id,action)
if action == 1 then
menu(id,"SELECT YOU'RE PERK@b,Berserker,Firebug")
end
end

How to make that berserker gets a machete and firebug gets a flamethrower

Admin/Mod Kommentar

bad title "one question" fixed

alt Re: equip items with Lua menu

Tajifun
User Off Offline

Zitieren
This should do it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
addhook("serveraction","func1")
function func1(id,key)
	if key == 1 then
		menu(id,"Select your perk,Berserker,Firebug")
	end
end

addhook("menu","func2")
function func2(id,menu,sel)
	if menu == "Select your perk" then
		if sel == 1 then
			parse("equip "..id.." 69")
		end
		if sel == 2 then
			parse("equip "..id.." 46")
		end
	end
end

By the way, use [code ] and [/code ] next time..

alt Re: equip items with Lua menu

Yates
Reviewer Off Offline

Zitieren
user Tajifun hat geschrieben
This should do it.

1
parse("equip "..id.." 46")

I have tried that before, didn't work. Maybe it does for you but incase not, use this.
1
parse("equip "..id.." "..WeaponID)

alt Re: equip items with Lua menu

DC
Admin Off Offline

Zitieren
there is no difference between those 2 solutions (if WeaponID = 46) because the resulting strings are exactly the same.

alt Re: equip items with Lua menu

Mech R
COMMUNITY BANNED Off Offline

Zitieren
Greetings. As the script which registers some pages of the weapon on one button will look. And that it was possible to move on them by means of buttons "next page"and "prev page" ?

alt Re: equip items with Lua menu

Alistaire
User Off Offline

Zitieren
user Mech R hat geschrieben
Greetings. As the script which registers some pages of the weapon on one button will look. And that it was possible to move on them by means of buttons "next page"and "prev page" ?



In my code this menu would look like:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
function initArray(m)
     local array = {}
     for i = 1, m do
          array[i] = 0
     end
     return array
end
sample.classes.class = initArray(32)
function sample.classes.classmenu1(id)
	menu(id,"Select your perk,Berserker,Firebug,,,,,,(Back),Next")
end
function sample.classes.classmenu2(id)
	menu(id,"Select your perk #2,Militia,Policeman,,,,,,Back,(Next)")
end

addhook("menu","func2")
function func2(id,menu,sel)
     	if menu == "Select your perk" then
          	if sel == 1 then
               		parse("equip "..id.." 69")
          	elseif sel == 2 then
              		parse("equip "..id.." 46")
		elseif sel == 9
			function sample.classes.classmenu2(id)
	elseif menu == "Select your perk #2" then
		if sel == 1 then
			parse("equip "..id.." 28")
		elseif sel == 2 then
			parse("equip "..id.." 3")
		elseif sel == 8 then
			function sample.classes.classmenu1(id)
     	end

end

Or else like

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
addhook("serveraction","func1")
function func1(id,key)
     	if key == 1 then
          	menu(id,"Select your perk,Berserker,Firebug")
     	end
	if key == 2 then
		menu(id,"Select your perk #2,Militia,Policeman")
	end
end

addhook("menu","func2")
function func2(id,menu,sel)
     	if menu == "Select your perk" then
          		if sel == 1 then
               			parse("equip "..id.." 69")
          		elseif sel == 2 then
              			parse("equip "..id.." 46")
		end
end
	if menu == "Select your perk #2" then
		if sel == 1 then
			parse("equip "..id.." 28")		
		elseif sel == 2 then
			parse("equip "..id.." 3")
		end
     	end

The first code uses a function to call the menus, and the second uses the assigned buttons to call them.

I prefer the first one, since I know button-triggered scripts are a bit harder.

With the first script (Which actually is the standard classes script) you could make an endless stream of menus assigned to 1 button.
5× editiert, zuletzt 12.06.11 17:16:24

alt Re: equip items with Lua menu

Dovahkin
User Off Offline

Zitieren
why not when you spawn the menu pop up i think thats good ill try it.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
function Array(size,value)
	local array = {}
	for i = 1, size do
		array[i]=value
	end
	return array
end

menu = Array(32,0)
menut = Array(32,0)
lol = Array(32,0)
lolct = Array(32,0)

addhook("spawn","spawnme")
function spawnme(id)
	if team == 1 then
		menu(id,"Terrorist Menu,FireBug,Deep Stalker")
		if menu[id] == 1 then
		menu[id] = 0
	if team == 2 then
		menu(id,"Counter Menu,Berserker,???")
		if lol[id] == 1 then
		lol[id] = 0
		end
	end
end

addhook("menu","lol")
function lol(id,title,sel)
	if title == "Terrorist Menu" then
		if sel == 1 then
			parse("equip "..id.." 49")
			parse("equip "..id.." 80")
			parse("speedmod "..id.." -15")
			parse("sethealth "..id.." 50")
			msg2(id,"Your Class is Firebug")
		end
		if sel == 2 then
			parse("equip "..id.." 45")
			parse("sethealth "..id.." 5")
			parse("equip "..id.." 84")
			msg2(id,"Your Class is Deep Stalker")
		end
	end
	if title == "Counter Menu" then
		if sel == 1 then
			parse("equip "..id.." 69")
			parse("equip "..id.." 79")
			parse("strip "..id.." 50")
			parse("strip "..id.." 2")
			parse("speedmod "..id.." 35")
			msg2(id,"Your Class is Berserker")
		end
		if sel == 2 then
			parse("equip "..id.." 88")
			parse("setmoney "..id.." 0")
			parse("killplayer "..id)
			msg2(id,"HAHAHAH BYE BYE!")
		end
	end
end

addhook("spawn","spawnlol")
function spawnlol(id)
	menu[id] == 1
end

addhook("spawn","again")
function again(id)
	parse("setmoney "..id.." 16000")
end

Test?
1× editiert, zuletzt 14.06.11 06:42:15

alt Re: equip items with Lua menu

Alistaire
User Off Offline

Zitieren
user Dovahkin hat geschrieben
why not when you spawn the menu pop up i think thats good ill try it.

[code]addhook("spawn","learn")
function learn(id)
if team == 1 then
menu(id,"Terrorist Menu,Firebug,Deep Stalker")
if team == 2 then
menu(id,"Counter-terrorist,Berserker,The Legend")
end
end

addhook("menu","lol")
function lol(id,title,sel)
if title == "Terrorist Menu"
if sel == 1 then
parse("equip "..id.."


I used the same script, but when you chose something, the menu pops up again.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht