Forum

> > CS2D > Scripts > NPC sell the food?
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch NPC sell the food?

5 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

verschoben NPC sell the food?

KabirDuy
User Off Offline

Zitieren
I want one NPC to sell food in one location. And buy food that will subtract $ and its recovery Hp each.

alt Re: NPC sell the food?

Alistaire
User Off Offline

Zitieren
1
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.

alt Re: NPC sell the food?

KabirDuy
User Off Offline

Zitieren
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

alt Re: NPC sell the food?

Rainoth
Moderator Off Offline

Zitieren
user KabirDuy hat geschrieben
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


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.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht