Forum
CS2D Scripts NPC sell the food?NPC sell the food?
5 replies 1
If you want something, go and script it.
http://unrealsoftware.de/forum_posts.php?post=228906#jn
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
npcs = { 	{x = 32, y = 16, cost = 100, heal = 5, name = 'chillidog', npcname = 'Jack the Ripper'}, 	{x = 30, y = 12, cost = 200, heal = 9, name = 'lasagna', npcname = 'your mother'} } addhook('usebutton', 'usebuttonHook') function usebuttonHook(id, x, y) 	for npc = 1, #npcs do 		if x == npcs[npc].x and y == npc[npc].y then 			if player(id, 'money') >= npcs[npc].cost then 				parse('sethealth '..id..' '..(player(id, 'health') + npcs[npc].heal)) 				parse('setmoney '..id..' '..(player(id, 'money') - npcs[npc].cost)) 				msg2(id, "You bought a '..npcs[npc].name..' from '..npcs[npc].npcname..'") 			end 		end 	end end
Add a trigger_button on the place you want the npc to be, and add the tilex and tiley position, name etc. to the npcs[] table.
Sr for bad english
KabirDuy has written
I don't quite understand, can you tell me how i stand in any position (x, y). And using for trigger button.
Sr for bad english
Sr for bad english
Go to "editor" and place entity called "trigger_use" then look up it's cordinates and enter them in Alistaire's script where it says "x = and y =" at second line.
You can also change the name of food that you bought (like chillidog to donut and lasagna to omelette) you can also change cost, healing amount.
It's quite obvious when you look at his script.
1