Forum

> > CS2D > Scripts > NPC Sell weapons
ForenübersichtCS2D-Übersicht Scripts-ÜbersichtEinloggen, um zu antworten

Englisch NPC Sell weapons

6 Antworten
Zum Anfang Vorherige 1 Nächste Zum Anfang

alt NPC Sell weapons

KabirDuy
User Off Offline

Zitieren
Sorry I asked the same one topic.
One certain place, for example (id, "tilex"). There will be one NPC, click on the table is one of the weapons for money.

Sorry for bad english.

alt Re: NPC Sell weapons

Alistaire
User Off Offline

Zitieren
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
npcs = {
	{type = 'food', x = 32, y = 16, cost = 100, heal = 5, name = 'a chillidog', npcname = 'Jack the Ripper'},
	{type = 'food', x = 30, y = 12, cost = 200, heal = 9, name = 'some lasagna', npcname = 'your mother'},
	{type = 'weapon', x = 40, y = 14, cost = 500, weapon = 32, name = 'an M4A1', npcname = 'some anonymous weapondealer'}
}

addhook('usebutton', 'usebuttonHook')

function usebuttonHook(id, x, y)
	for npc = 1, #npcs do
		if x == npcs[npc].x and y == npcs[npc].y then
			if player(id, 'money') >= npcs[npc].cost then
				if npcs[npc].type == 'food' then
					parse('sethealth '..id..' '..(player(id, 'health') + npcs[npc].heal))
				elseif npcs[npc].type == 'weapon' then
					parse('equip '..id..' '..npcs[npc].weapon)
				end
				parse('setmoney '..id..' '..(player(id, 'money') - npcs[npc].cost))
				msg2(id, "You bought '..npcs[npc].name..' from '..npcs[npc].npcname..'")
			end
		end
	end
end

<_<
1× editiert, zuletzt 20.03.13 09:11:28

alt Re: NPC Sell weapons

Alistaire
User Off Offline

Zitieren
user KabirDuy hat geschrieben
how to use? I use x and y but not work, why?


Add a line in the table for your shop, and add the X and Y tile position there..

{type = 'weapon', x = 72, y = 64, etc etc}

----

Oh and also, take my script again, there was a bug in it.

alt Re: NPC Sell weapons

KabirDuy
User Off Offline

Zitieren
Oh! I know! But instead of that, then I saw one table? Food and weapons are in the table and choose to buy.
Zum Anfang Vorherige 1 Nächste Zum Anfang
Einloggen, um zu antworten Scripts-ÜbersichtCS2D-ÜbersichtForenübersicht