Forum

> > CS2D > Scripts > equip items with Lua menu
Forums overviewCS2D overview Scripts overviewLog in to reply

English equip items with Lua menu

12 replies
To the start Previous 1 Next To the start

old equip items with Lua menu

Flame
BANNED Off Offline

Quote
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 comment

bad title "one question" fixed

old Re: equip items with Lua menu

Tajifun
User Off Offline

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

old Re: equip items with Lua menu

Yates
Reviewer Off Offline

Quote
user Tajifun has written
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)

old Re: equip items with Lua menu

DC
Admin Off Offline

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

old Re: equip items with Lua menu

Mech R
COMMUNITY BANNED Off Offline

Quote
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" ?

old Re: equip items with Lua menu

Alistaire
User Off Offline

Quote
user Mech R has written
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.
edited 5×, last 12.06.11 05:16:24 pm

old Re: equip items with Lua menu

Mech R
COMMUNITY BANNED Off Offline

Quote
I did not want spammed, I am simple the beginner. Excuse me. Thanks for a presented script, 2Fast4You.

old Re: equip items with Lua menu

Dovahkin
User Off Offline

Quote
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?
edited 1×, last 14.06.11 06:42:15 am

old Re: equip items with Lua menu

Alistaire
User Off Offline

Quote
user Dovahkin has written
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.
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview