Forum

> > CS2D > Scripts > NPC for 3
Forums overviewCS2D overview Scripts overviewLog in to reply

English NPC for 3

6 replies
To the start Previous 1 Next To the start

old NPC for 3

superpegamento
User Off Offline

Quote
i need
in this menu by pressing a button to create a npc are created three npc in position the User

--not 1 npc I need three

Sorry my english

EG:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
serverlist=={xxxxx}

addhook("serveraction" , "Teclado_f2")
function Teclado_f2(id,act)
for _,usgn in ipairs(serverlist) do
if player(id,'usgn') == usgn then
if act==1 then
menu(id,"Menu NPC,NPC x3")
end
end
end
end

addhook("menu" , "Server_Menu")
function Server_Menu(id,title,b)
if title=="Menu NPC" then
if b==1 then
menu(id,"NPC,Zombie,HeadCrab,Sodlier,Vortiguant,etc")
end
end
if title=="NPC" then
if b==1 then
--------as I can do?
elseif b==2 then...ETC,ETC,ETC

old Re: NPC for 3

Bowlinghead
User Off Offline

Quote
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
serverlist=={xxxxx}

addhook("serveraction" , "Teclado_f2")
function Teclado_f2(id,act)
for _,usgn in ipairs(serverlist) do
if player(id,'usgn') == usgn then
if act==1 then
menu(id,"Menu NPC,NPC x3")
end
end
end
end

addhook("menu" , "Server_Menu")
function Server_Menu(id,title,b)
if title=="Menu NPC" then
if b==1 then
menu(id,"NPC,Zombie,HeadCrab,Snark,Vortiguant,Soldier")
end
end
if title=="NPC" then
parse("spawnnpc "..b.." "..player(id,"x").." "..player(id,"y").." "..math.random(1,359))
parse("spawnnpc "..b.." "..player(id,"x").." "..player(id,"y").." "..math.random(1,359))
parse("spawnnpc "..b.." "..player(id,"x").." "..player(id,"y").." "..math.random(1,359))
end
end

I think this is a smart solution!

old Re: NPC for 3

D-D3ADxPro
User Off Offline

Quote
@user Rainoth: Yep. You are right. They have to spawn in tiles or else it wont work. Therefore, his code doesnt work.

This should work:

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
serverlist = {122641}

addhook("serveraction","Teclado_f2")
function Teclado_f2(id,act)
	for _,usgn in ipairs(serverlist) do
		if player(id,'usgn') == usgn then
			if act==1 then
			menu(id,"NPC Spawn Menu,Zombie,HeadCrab,Snark,Vortigaunt,Soldier")
			end
		end
	end
end

addhook("menu","npcmenu")
function npcmenu(id,title,b)
if title=="NPC Spawn Menu" then
	if b==1 then
	parse('spawnnpc 1 '..(player(id,"tilex")-0)..' '..player(id,"tiley"))
	parse('spawnnpc 1 '..(player(id,"tilex")-0)..' '..player(id,"tiley"))
	parse('spawnnpc 1 '..(player(id,"tilex")-0)..' '..player(id,"tiley"))
	menu(id,"NPC Spawn Menu,Zombie,HeadCrab,Snark,Vortigaunt,Soldier")
elseif b==2 then
	parse('spawnnpc 2 '..(player(id,"tilex")-0)..' '..player(id,"tiley"))
	parse('spawnnpc 2 '..(player(id,"tilex")-0)..' '..player(id,"tiley"))
	parse('spawnnpc 2 '..(player(id,"tilex")-0)..' '..player(id,"tiley"))
	menu(id,"NPC Spawn Menu,Zombie,HeadCrab,Snark,Vortigaunt,Soldier")
elseif b==3 then
	parse('spawnnpc 3 '..(player(id,"tilex")-0)..' '..player(id,"tiley"))
	parse('spawnnpc 3 '..(player(id,"tilex")-0)..' '..player(id,"tiley"))
	parse('spawnnpc 3 '..(player(id,"tilex")-0)..' '..player(id,"tiley"))
	menu(id,"NPC Spawn Menu,Zombie,HeadCrab,Snark,Vortigaunt,Soldier")
elseif b==4 then
	parse('spawnnpc 4 '..(player(id,"tilex")-0)..' '..player(id,"tiley"))
	parse('spawnnpc 4 '..(player(id,"tilex")-0)..' '..player(id,"tiley"))
	parse('spawnnpc 4 '..(player(id,"tilex")-0)..' '..player(id,"tiley"))
	menu(id,"NPC Spawn Menu,Zombie,HeadCrab,Snark,Vortigaunt,Soldier")
elseif b==5 then
	parse('spawnnpc 5 '..(player(id,"tilex")-0)..' '..player(id,"tiley"))
	parse('spawnnpc 5 '..(player(id,"tilex")-0)..' '..player(id,"tiley"))
	parse('spawnnpc 5 '..(player(id,"tilex")-0)..' '..player(id,"tiley"))
		menu(id,"NPC Spawn Menu,Zombie,HeadCrab,Snark,Vortigaunt,Soldier")
		end
	end
end

If you dont want it to spawn at the exact tile your own, find this line:
1
'..(player(id,"tilex")-0)..'
You can change the " - " to a " + ". And for the number, you can change it to 1 or whatever you like.

old Re: NPC for 3

Rainoth
Moderator Off Offline

Quote
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
serverlist=={xxxxx}

addhook("serveraction" , "Teclado_f2")
function Teclado_f2(id,act)
	for _,usgn in ipairs(serverlist) do
		if player(id,'usgn') == usgn then
			if act==1 then
				menu(id,"Menu NPC,NPC x3")
			end
		end
	end
end

addhook("menu" , "Server_Menu")
function Server_Menu(id,title,b)
	if title=="Menu NPC" then
		if b==1 then
			menu(id,"NPC,Zombie,HeadCrab,Snark,Vortiguant,Soldier")
		end
	elseif title=="NPC" then
		for i=1,3 do
			parse("spawnnpc "..b.." "..player(id,"tilex").." "..player(id,"tiley").." "..i*120)
			menu(id,"NPC,Zombie,HeadCrab,Snark,Vortiguant,Soldier")
		end
	end
end
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview