Forum

> > CS2D > Scripts > Spawn NPC
Forums overviewCS2D overview Scripts overviewLog in to reply

English Spawn NPC

12 replies
To the start Previous 1 Next To the start

old Spawn NPC

Cereal Guy
User Off Offline

Quote
∗I need to know how to make a npc on the map and when a player get near him and press e an weapon list to appear and to be bought from there

old Re: Spawn NPC

Yates
Reviewer Off Offline

Quote
Add an NPC sprite on your map and use the Lua hook cs2d lua cmd use to open a menu.

old Re: Spawn NPC

Cereal Guy
User Off Offline

Quote
I added the npc sprite but I still don't know how to make the script I am not so good scripter by the way I play on your server and the map is so cool with these npc's !

old Re: Spawn NPC

loldlold123
User Off Offline

Quote
1
2
3
4
5
6
addhook("usebutton","hhbutton")
function hhbutton(id)
if player(id,"tilex")==x and player(id,"tiley")==y then
menu(id,"MY NPC,LOL,LOL1,LOL2")
end
end

old Re: Spawn NPC

Cereal Guy
User Off Offline

Quote
Headhunter where I put the tile coordonates? I made something like this.....

addhook("usebutton","hhbutton")
if player(id,"tilex")==x58 and
player(id,"tilex")==y36 then
menu(id,"MY NPC,LOL,LOL1,LOL2")
end
end

old Re: Spawn NPC

Alistaire
User Off Offline

Quote
Really?

1
2
3
4
5
6
7
addhook("usebutton","hhbutton")

function hhbutton(id)
	if player(id,"tilex")==58 and player(id,"tilex")==36 then
		menu(id,"MY NPC,LOL,LOL1,LOL2")
	end
end

Or my way

1
2
3
4
5
6
7
addhook('usebutton', 'AA_button')

function AA_button(id)
	if player(id, 'tilex') == 58 and player(id, 'tiley') == 36 then
		menu(id, 'title, button1, button2')
	end
end

old Re: Spawn NPC

loldlold123
User Off Offline

Quote
ur way is shit i prefer LOL buttons

by the way,delete x and y and put your cordinates

old Re: Spawn NPC

Cereal Guy
User Off Offline

Quote
The hook is good and worked but when I go in the front of my npc and press e nothing appears now to be sure that I didn't made it wrong I moved the npc on another place and changed the tilex to 240 and the tiley to 38 but it still not working when I edit the map there says Tile Position 38|240 - Tile #12......I missed something??

old Re: Spawn NPC

Alistaire
User Off Offline

Quote
Tile Position x|y - frame

Not Tile Position y|x - frame

----

You should make the tilex 38 and tiley 240.

old Re: Spawn NPC

Alistaire
User Off Offline

Quote
Oh there's no trigger_use.

1
2
3
4
5
6
7
addhook('use', 'AA_use')

function AA_use(id)
	if player(id, 'tilex') == 58 and player(id, 'tiley') == 36 then
		menu(id, 'title, button1, button2')
	end
end

old Re: Spawn NPC

Cereal Guy
User Off Offline

Quote
Finnaly it works ! now how to add items on that menu? Do i have to replace button 1 and button 2 with the weapons id or names?
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview