What's new

NPC Sprzeda? loota - nowy spos?b (?)

Status
Not open for further replies.

Oskar

Forum friend
Joined
Jan 24, 2009
Messages
2,256
Reaction score
331
PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid)        	npcHandler:onCreatureAppear(cid)        	end
function onCreatureDisappear(cid)     	npcHandler:onCreatureDisappear(cid) 	    end
function onCreatureSay(cid, type, msg)  npcHandler:onCreatureSay(cid, type, msg) 	end
function onThink()                    	npcHandler:onThink()                 		end

local function doNPCTalkALot(cid, npc, delay, messages)
	for i = 1,#messages do
		addEvent(function()
						if isPlayer(cid) then
							doCreatureSay(npc, messages[i], TALKTYPE_PRIVATE_NP, false, cid)
						end end,
						delay * i,
						cid, messages, i)
	end
end
local slowa_klucze = {'amulets','amulet','necklace','armors','armor','shields','shield','swords','sword','boots','shoes','legs','leg'}

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local msgss = ''

local items = {
				{s={'amulets','amulet','necklace'}, id=11208, buy=0, sell=50, name='antlers'},
				{s={'amulets','amulet','necklace'}, id=10549, buy=0, sell=100, name='bloody pincers'},
				{s={'amulets','amulet','necklace'}, id=11183, buy=0, sell=35, name='crab pincers'},
				{s={'armors','armor'}, id=6095, buy=0, sell=500, name='pirate shirt'},
				{s={'armors','armor'}, id=3968, buy=0, sell=1000, name='leopard armor'},
				{s={'armors','armor'}, id=8873, buy=0, sell=3000, name='hibiscus dress'},
				{s={'armors','armor'}, id=7463, buy=0, sell=6000, name='mammoth fur cape'},
				{s={'armors','armor'}, id=7897, buy=0, sell=11000, name='glacier robe'},
				{s={'armors','armor'}, id=7898, buy=0, sell=11000, name='lightning robe'},
				{s={'armors','armor'}, id=7899, buy=0, sell=11000, name='magma coat'},
				{s={'armors','armor'}, id=7884, buy=0, sell=11000, name='terra mantle'},
				{s={'armors','armor'}, id=8891, buy=0, sell=15000, name='paladin armor'},
				{s={'armors','armor'}, id=8877, buy=0, sell=16000, name='lavos armor'},
				{s={'armors','armor'}, id=8880, buy=0, sell=16000, name='swamplair armor'},
				{s={'armors','armor'}, id=8878, buy=0, sell=16000, name='crystalline armor'},
				{s={'armors','armor'}, id=8889, buy=0, sell=18000, name='skullcracker armor'},
				{s={'armors','armor'}, id=2466, buy=0, sell=20000, name='golden armor'},
				{s={'armors','armor'}, id=2503, buy=0, sell=30000, name='dwarven armor'},
				{s={'armors','armor'}, id=2492, buy=0, sell=40000, name='dragon scale mail'},
				{s={'armors','armor'}, id=2472, buy=0, sell=90000, name='magic plate armor'},
				{s={'shields','shield'}, id=2541, buy=0, sell=80, name='bone shield'},
				{s={'shields','shield'}, id=6131, buy=0, sell=150, name='tortoise shield'},
				{s={'shields','shield'}, id=2521, buy=0, sell=400, name='dark shield'},
				{s={'shields','shield'}, id=7460, buy=0, sell=1500, name='norse shield'},
				{s={'shields','shield'}, id=2540, buy=0, sell=2000, name='scarab shield'},
				{s={'shields','shield'}, id=2535, buy=0, sell=5000, name='castle shield'},
				{s={'shields','shield'}, id=2536, buy=0, sell=9000, name='medusa shield'},
				{s={'shields','shield'}, id=2520, buy=0, sell=30000, name='demon shield'},
				{s={'shields','shield'}, id=2542, buy=0, sell=35000, name='tempest shield'},
				{s={'shields','shield'}, id=2514, buy=0, sell=50000, name='mastermind shield'},
				{s={'swords','sword'}, id=2442, buy=0, sell=90, name='heavy machete'},
				{s={'swords','sword'}, id=2402, buy=0, sell=500, name='silver dagger'},
				{s={'swords','sword'}, id=7449, buy=0, sell=600, name='crystal sword'},
				{s={'swords','sword'}, id=7408, buy=0, sell=1500, name='wyvern fang'},
				{s={'swords','sword'}, id=2438, buy=0, sell=8000, name='epee'},
				{s={'swords','sword'}, id=7386, buy=0, sell=12000, name='mercenary sword'},
				{s={'swords','sword'}, id=7402, buy=0, sell=15000, name='dragon slayer '},
				{s={'swords','sword'}, id=2451, buy=0, sell=15000, name='djinn blade'},
				{s={'swords','sword'}, id=7404, buy=0, sell=20000, name='assassin dagger'},
				{s={'swords','sword'}, id=2446, buy=0, sell=23000, name='pharaoh sword'},
				{s={'swords','sword'}, id=7383, buy=0, sell=25000, name='relic sword'},
				{s={'swords','sword'}, id=7384, buy=0, sell=30000, name='mystic blade '},
				{s={'swords','sword'}, id=7418, buy=0, sell=35000, name='nightmare blade'},
				{s={'swords','sword'}, id=7382, buy=0, sell=36000, name='demonrage sword'},
				{s={'swords','sword'}, id=7403, buy=0, sell=40000, name='berserker'},
				{s={'boots','shoes'}, id=9931, buy=0, sell=500, name='coconut shoes'},
				{s={'boots','shoes'}, id=3982, buy=0, sell=1000, name='crocodile boots'},
				{s={'boots','shoes'}, id=7457, buy=0, sell=2000, name='fur boots'},
				{s={'boots','shoes'}, id=7892, buy=0, sell=2500, name='glacier shoes'},
				{s={'boots','shoes'}, id=7893, buy=0, sell=2500, name='lightning boots'},
				{s={'boots','shoes'}, id=7891, buy=0, sell=2500, name='magma boots'},
				{s={'boots','shoes'}, id=7886, buy=0, sell=2500, name='terra boots'},
				{s={'boots','shoes'}, id=5462, buy=0, sell=3000, name='pirate boots'},
				{s={'boots','shoes'}, id=2645, buy=0, sell=30000, name='steel boots'},
				{s={'legs','leg'}, id=5918, buy=0, sell=200, name='pirate knee breeches'},
				{s={'legs','leg'}, id=9928, buy=0, sell=500, name='leaf legs'},
				{s={'legs','leg'}, id=7464, buy=0, sell=850, name='mammoth fur shorts'},
				{s={'legs','leg'}, id=7896, buy=0, sell=11000, name='glacier kilt'},
				{s={'legs','leg'}, id=7895, buy=0, sell=11000, name='lightning legs'},
				{s={'legs','leg'}, id=7894, buy=0, sell=11000, name='magma legs'},
				{s={'legs','leg'}, id=7885, buy=0, sell=11000, name='terra legs'},
				{s={'legs','leg'}, id=2470, buy=0, sell=30000, name='golden legs'}
				}

if isInArray({'trade','offer'}, msg:lower()) then
	talkState[talkUser] = 1
	return doNPCTalkALot(cid, getNpcCid(), 200, {'Of course, old friend. You can also browse only {armor}, {legs}, {shields}, {helmets}, {boots}, {weapons}, {enchanted weapons}, {jewelry} or miscellaneous stuff.'})
elseif msgcontains(msg, 'weapons')then
	return doNPCTalkALot(cid, getNpcCid(), 200, {'You can browse with: {swords}, {clubs}, {axes} or {distance}.'})
elseif talkState[talkUser] == 1 and isInArray(slowa_klucze, msg:lower()) then
	local trade_tbl = {}
	for i = #items, 1, -1 do
		local v = items[i]
		if isInArray(v.s, msg:lower()) then
			trade_tbl[v.id] = {item_id = v.id, buyPrice = v.buy, sellPrice = v.sell, subType = 0, realName = v.name}
		else
			table.remove(items, i)
		end
	end
	local onBuy = function(cid, item, subType, amount)
		if trade_tbl[item].buyPrice ~= 0 then
			doPlayerRemoveMoney(cid, amount * trade_tbl[item].buyPrice)
			for i = 1, amount do
				doPlayerAddItem(cid, trade_tbl[item].item_id, amount)
			end
			return doNPCTalkALot(cid, getNpcCid(), 200, {'You bought '..amount..' '..trade_tbl[item].realName..' for '..trade_tbl[item].buyPrice * amount..' gold coins.'})
		end
	end
	local onSell = function(cid, item, subType, amount)
		if trade_tbl[item].sellPrice ~= 0 then
			doPlayerAddMoney(cid, trade_tbl[item].sellPrice * amount)
			doPlayerRemoveItem(cid, trade_tbl[item].item_id, amount)
			doNPCTalkALot(cid, getNpcCid(), 200, {'You sold '..amount..' '..trade_tbl[item].realName..' for '..trade_tbl[item].sellPrice * amount..' gold coins.'})
		end
	end
	openShopWindow(cid, items, onBuy, onSell)
	return doNPCTalkALot(cid, getNpcCid(), 200, {msg:lower()..'!'})	
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Wiele nie musz? wyja?nia?, ale wyja?ni?.
PHP:
{s={'armors','armor'}, id=6095, buy=0, sell=500, name='pirate shirt'},
W tabelce 's' wpisujemy s?owa 'klucze', kt?re trzeba wypowiedzie? by do okienka handlu zosta? dodany przedmiot.
'id' to id przedmiotu. Reszta wiadomo.
PHP:
local slowa_klucze = {'amulets','amulet','necklace','armors','armor','shields','shield','swords','sword','boots','shoes','legs','leg'}
To s?owa klucze, kt?rych skrypt nie b?dzie ignorowa?.
Mo?e komu? si? przyda. Zrobi?em go komu? na zlecenie, a ja takiego badziewia nie potrzebuj?.




Lepsza wersja skryptu:
Do data/lib/000-constant.lua wklejamy:
PHP:
ITS = {
				['test'] = {
							{id=2466, buy=0, sell=20000, name='golden armor'},
							{id=2503, buy=0, sell=30000, name='dwarven armor'},
							{id=2492, buy=0, sell=40000, name='dragon scale mail'},
							{id=2472, buy=0, sell=90000, name='magic plate armor'},
							{id=2541, buy=0, sell=80, name='bone shield'},
							{id=6131, buy=0, sell=150, name='tortoise shield'},
							{id=2521, buy=0, sell=400, name='dark shield'},
							{id=7460, buy=0, sell=1500, name='norse shield'}},
				['alesar'] = {
							{id=7899, buy=0, sell=11000, name='magma coat'},
							{id=7884, buy=0, sell=11000, name='terra mantle'},
							{id=8891, buy=0, sell=15000, name='paladin armor'},
							{id=8877, buy=0, sell=16000, name='lavos armor'},
							{id=8880, buy=0, sell=16000, name='swamplair armor'},
							{id=8878, buy=0, sell=16000, name='crystalline armor'},
							{id=8889, buy=0, sell=18000, name='skullcracker armor'},
							{id=2540, buy=0, sell=2000, name='scarab shield'},
							{id=2535, buy=0, sell=5000, name='castle shield'},
							{id=2536, buy=0, sell=9000, name='medusa shield'},
							{id=2520, buy=0, sell=30000, name='demon shield'}},
				['nah\'bob'] = {
							{id=2442, buy=0, sell=90, name='heavy machete'},
							{id=2402, buy=0, sell=500, name='silver dagger'},
							{id=7449, buy=0, sell=600, name='crystal sword'},
							{id=7408, buy=0, sell=1500, name='wyvern fang'},
							{id=2438, buy=0, sell=8000, name='epee'},
							{id=7386, buy=0, sell=12000, name='mercenary sword'},
							{id=7402, buy=0, sell=15000, name='dragon slayer '},
							{id=2451, buy=0, sell=15000, name='djinn blade'},
							{id=7404, buy=0, sell=20000, name='assassin dagger'},
							{id=2446, buy=0, sell=23000, name='pharaoh sword'},
							{id=7383, buy=0, sell=25000, name='relic sword'},
							{id=7384, buy=0, sell=30000, name='mystic blade '},
							{id=7418, buy=0, sell=35000, name='nightmare blade'},
							{id=7382, buy=0, sell=36000, name='demonrage sword'},
							{id=7403, buy=0, sell=40000, name='berserker'},
							{id=9931, buy=0, sell=500, name='coconut shoes'},
							{id=3982, buy=0, sell=1000, name='crocodile boots'}},
				['sam'] = {
							{id=11208, buy=0, sell=50, name='antlers'},
							{id=10549, buy=0, sell=100, name='bloody pincers'},
							{id=11183, buy=0, sell=35, name='crab pincers'},
							{id=6095, buy=0, sell=500, name='pirate shirt'},
							{id=3968, buy=0, sell=1000, name='leopard armor'},
							{id=8873, buy=0, sell=3000, name='hibiscus dress'},
							{id=7463, buy=0, sell=6000, name='mammoth fur cape'},
							{id=7897, buy=0, sell=11000, name='glacier robe'},
							{id=7898, buy=0, sell=11000, name='lightning robe'},
							{id=2542, buy=0, sell=35000, name='tempest shield'},
							{id=2514, buy=0, sell=50000, name='mastermind shield'},
							{id=7457, buy=0, sell=2000, name='fur boots'},
							{id=7892, buy=0, sell=2500, name='glacier shoes'},
							{id=7893, buy=0, sell=2500, name='lightning boots'},
							{id=7891, buy=0, sell=2500, name='magma boots'},
							{id=7886, buy=0, sell=2500, name='terra boots'},
							{id=5462, buy=0, sell=3000, name='pirate boots'},
							{id=2645, buy=0, sell=30000, name='steel boots'},
							{id=5918, buy=0, sell=200, name='pirate knee breeches'},
							{id=9928, buy=0, sell=500, name='leaf legs'},
							{id=7464, buy=0, sell=850, name='mammoth fur shorts'},
							{id=7896, buy=0, sell=11000, name='glacier kilt'},
							{id=7895, buy=0, sell=11000, name='lightning legs'},
							{id=7894, buy=0, sell=11000, name='magma legs'},
							{id=7885, buy=0, sell=11000, name='terra legs'},
							{id=2470, buy=0, sell=30000, name='golden legs'}}
				}
Teraz idziemy do data/npc/lib/npc.lua i doklejamy:
PHP:
function doNPCTalkALot(cid, npc, delay, messages)
	for i = 1,#messages do
		addEvent(function()
						if isPlayer(cid) then
							doCreatureSay(npc, messages[i], TALKTYPE_PRIVATE_NP, false, cid)
						end end,
						delay * i,
						cid, messages, i)
	end
end

function onBuys(cid, item, subType, amount)
if trade_tbl[item].buyPrice ~= 0 then
	doPlayerRemoveMoney(cid, amount * trade_tbl[item].buyPrice)
	for i = 1, amount do
		doPlayerAddItem(cid, trade_tbl[item].item_id, amount)
	end
	return doNPCTalkALot(cid, getNpcCid(), 200, {'You bought '..amount..' '..trade_tbl[item].realName..' for '..trade_tbl[item].buyPrice * amount..' gold coins.'})
	end
end
function onSells(cid, item, subType, amount)
if trade_tbl[item].sellPrice ~= 0 then
	doPlayerAddMoney(cid, trade_tbl[item].sellPrice * amount)
	doPlayerRemoveItem(cid, trade_tbl[item].item_id, amount)
	return doNPCTalkALot(cid, getNpcCid(), 200, {'You sold '..amount..' '..trade_tbl[item].realName..' for '..trade_tbl[item].sellPrice * amount..' gold coins.'})
end
end


A w pliku NPC robimy:
PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid)        	npcHandler:onCreatureAppear(cid)        	end
function onCreatureDisappear(cid)     	npcHandler:onCreatureDisappear(cid) 	    end
function onCreatureSay(cid, type, msg)  npcHandler:onCreatureSay(cid, type, msg) 	end
function onThink()                    	npcHandler:onThink()                 		end

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if isInArray({'trade','offer'}, msg:lower()) then
	for _, v in ipairs(#ITS) do
        trade_tbl[v.id] = {item_id = v.id, buyPrice = v.buy, sellPrice = v.sell, subType = 0, realName = v.name}
	end
	openShopWindow(cid, ITS[getCreatureName(getNpcCid()):lower()], onBuys, onSells)
	return doNPCTalkALot(cid, getNpcCid(), 200, {'Oto moje towary!'})	
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())


To system wszystkich NPCt?w w jednym pliku. Jedyne co musicie zmieni? to nazwy NPCt?w, reszt? w skrypcie zostawcie w spokoju.
 

Atyhlon

Advanced User
Joined
Oct 27, 2010
Messages
201
Reaction score
15
Odp: Sprzeda? loota - nowy spos?b (?)

Mo?e si? przyda? na OTS RPG ? Hmmm. Mo?e u?yj?, ale nie jestem pewien - nie wiem po co komu? by?o co? takiego skoro jest opcja trade xD
 

Dubler

Lua Factory =)
Joined
Apr 8, 2009
Messages
1,874
Reaction score
112
Odp: Sprzeda? loota - nowy spos?b (?)

dobry pomysl, polaczenie wszystkich npc w jedno posegregowane, gratuluje pomys?u.

@offtop
Btw. szukam kogo? kto mi wyt?umaczy konstrukcje npc bo nie czaje pom?g? by?? :D
 

Oskar

Forum friend
Joined
Jan 24, 2009
Messages
2,256
Reaction score
331
Odp: Sprzeda? loota - nowy spos?b (?)

Lepsza wersja skryptu:
Do data/lib/000-constant.lua wklejamy:
PHP:
ITS = {
				['test'] = {
							{id=2466, buy=0, sell=20000, name='golden armor'},
							{id=2503, buy=0, sell=30000, name='dwarven armor'},
							{id=2492, buy=0, sell=40000, name='dragon scale mail'},
							{id=2472, buy=0, sell=90000, name='magic plate armor'},
							{id=2541, buy=0, sell=80, name='bone shield'},
							{id=6131, buy=0, sell=150, name='tortoise shield'},
							{id=2521, buy=0, sell=400, name='dark shield'},
							{id=7460, buy=0, sell=1500, name='norse shield'}},
				['alesar'] = {
							{id=7899, buy=0, sell=11000, name='magma coat'},
							{id=7884, buy=0, sell=11000, name='terra mantle'},
							{id=8891, buy=0, sell=15000, name='paladin armor'},
							{id=8877, buy=0, sell=16000, name='lavos armor'},
							{id=8880, buy=0, sell=16000, name='swamplair armor'},
							{id=8878, buy=0, sell=16000, name='crystalline armor'},
							{id=8889, buy=0, sell=18000, name='skullcracker armor'},
							{id=2540, buy=0, sell=2000, name='scarab shield'},
							{id=2535, buy=0, sell=5000, name='castle shield'},
							{id=2536, buy=0, sell=9000, name='medusa shield'},
							{id=2520, buy=0, sell=30000, name='demon shield'}},
				['nah\'bob'] = {
							{id=2442, buy=0, sell=90, name='heavy machete'},
							{id=2402, buy=0, sell=500, name='silver dagger'},
							{id=7449, buy=0, sell=600, name='crystal sword'},
							{id=7408, buy=0, sell=1500, name='wyvern fang'},
							{id=2438, buy=0, sell=8000, name='epee'},
							{id=7386, buy=0, sell=12000, name='mercenary sword'},
							{id=7402, buy=0, sell=15000, name='dragon slayer '},
							{id=2451, buy=0, sell=15000, name='djinn blade'},
							{id=7404, buy=0, sell=20000, name='assassin dagger'},
							{id=2446, buy=0, sell=23000, name='pharaoh sword'},
							{id=7383, buy=0, sell=25000, name='relic sword'},
							{id=7384, buy=0, sell=30000, name='mystic blade '},
							{id=7418, buy=0, sell=35000, name='nightmare blade'},
							{id=7382, buy=0, sell=36000, name='demonrage sword'},
							{id=7403, buy=0, sell=40000, name='berserker'},
							{id=9931, buy=0, sell=500, name='coconut shoes'},
							{id=3982, buy=0, sell=1000, name='crocodile boots'}},
				['sam'] = {
							{id=11208, buy=0, sell=50, name='antlers'},
							{id=10549, buy=0, sell=100, name='bloody pincers'},
							{id=11183, buy=0, sell=35, name='crab pincers'},
							{id=6095, buy=0, sell=500, name='pirate shirt'},
							{id=3968, buy=0, sell=1000, name='leopard armor'},
							{id=8873, buy=0, sell=3000, name='hibiscus dress'},
							{id=7463, buy=0, sell=6000, name='mammoth fur cape'},
							{id=7897, buy=0, sell=11000, name='glacier robe'},
							{id=7898, buy=0, sell=11000, name='lightning robe'},
							{id=2542, buy=0, sell=35000, name='tempest shield'},
							{id=2514, buy=0, sell=50000, name='mastermind shield'},
							{id=7457, buy=0, sell=2000, name='fur boots'},
							{id=7892, buy=0, sell=2500, name='glacier shoes'},
							{id=7893, buy=0, sell=2500, name='lightning boots'},
							{id=7891, buy=0, sell=2500, name='magma boots'},
							{id=7886, buy=0, sell=2500, name='terra boots'},
							{id=5462, buy=0, sell=3000, name='pirate boots'},
							{id=2645, buy=0, sell=30000, name='steel boots'},
							{id=5918, buy=0, sell=200, name='pirate knee breeches'},
							{id=9928, buy=0, sell=500, name='leaf legs'},
							{id=7464, buy=0, sell=850, name='mammoth fur shorts'},
							{id=7896, buy=0, sell=11000, name='glacier kilt'},
							{id=7895, buy=0, sell=11000, name='lightning legs'},
							{id=7894, buy=0, sell=11000, name='magma legs'},
							{id=7885, buy=0, sell=11000, name='terra legs'},
							{id=2470, buy=0, sell=30000, name='golden legs'}}
				}
Teraz idziemy do data/npc/lib/npc.lua i doklejamy:
PHP:
function doNPCTalkALot(cid, npc, delay, messages)
	for i = 1,#messages do
		addEvent(function()
						if isPlayer(cid) then
							doCreatureSay(npc, messages[i], TALKTYPE_PRIVATE_NP, false, cid)
						end end,
						delay * i,
						cid, messages, i)
	end
end

function onBuys(cid, item, subType, amount)
if trade_tbl[item].buyPrice ~= 0 then
	doPlayerRemoveMoney(cid, amount * trade_tbl[item].buyPrice)
	for i = 1, amount do
		doPlayerAddItem(cid, trade_tbl[item].item_id, amount)
	end
	return doNPCTalkALot(cid, getNpcCid(), 200, {'You bought '..amount..' '..trade_tbl[item].realName..' for '..trade_tbl[item].buyPrice * amount..' gold coins.'})
	end
end
function onSells(cid, item, subType, amount)
if trade_tbl[item].sellPrice ~= 0 then
	doPlayerAddMoney(cid, trade_tbl[item].sellPrice * amount)
	doPlayerRemoveItem(cid, trade_tbl[item].item_id, amount)
	return doNPCTalkALot(cid, getNpcCid(), 200, {'You sold '..amount..' '..trade_tbl[item].realName..' for '..trade_tbl[item].sellPrice * amount..' gold coins.'})
end
end


A w pliku NPC robimy:
PHP:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
local talkState = {}
function onCreatureAppear(cid)        	npcHandler:onCreatureAppear(cid)        	end
function onCreatureDisappear(cid)     	npcHandler:onCreatureDisappear(cid) 	    end
function onCreatureSay(cid, type, msg)  npcHandler:onCreatureSay(cid, type, msg) 	end
function onThink()                    	npcHandler:onThink()                 		end

function creatureSayCallback(cid, type, msg)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
if isInArray({'trade','offer'}, msg:lower()) then
	for _, v in ipairs(#ITS) do
        trade_tbl[v.id] = {item_id = v.id, buyPrice = v.buy, sellPrice = v.sell, subType = 0, realName = v.name}
	end
	openShopWindow(cid, ITS[getCreatureName(getNpcCid()):lower()], onBuys, onSells)
	return doNPCTalkALot(cid, getNpcCid(), 200, {'Oto moje towary!'})	
end
return true
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())


To system wszystkich NPCt?w w jednym pliku. Jedyne co musicie zmieni? to nazwy NPCt?w, reszt? w skrypcie zostawcie w spokoju.
 
Last edited:

NewGift

Active User
Joined
Nov 14, 2010
Messages
120
Reaction score
6
Odp: Sprzeda? loota - nowy spos?b (?)

Nie dziala
522f2acb710ae657gen.png
 

Oskar

Forum friend
Joined
Jan 24, 2009
Messages
2,256
Reaction score
331
Odp: Sprzeda? loota - nowy spos?b (?)

Brak tabeli ITS w libach. Dodaj j?, a wszystko powinno dzia?a?.


#down
Zmieni?e? chocia? nazwy w libach? Bo widz? 'test', 'alesar' itd
Zmie? na swojego 'Sam' i powinno dzia?a?.
 
Last edited:

NewGift

Active User
Joined
Nov 14, 2010
Messages
120
Reaction score
6
Odp: Sprzeda? loota - nowy spos?b (?)

We wszystkich libach czy w tym jednym? Je?eli w tym jednym o nie dzia?a, bo mam tak o:

81a236d04f673325gen.png


I wywala taki b??d po napisaniu trade lub offer

0c050007e82ef661.png
 

Rybak

Advanced User
Joined
Nov 3, 2008
Messages
218
Reaction score
11
Odp: Sprzeda? loota - nowy spos?b (?)

Skrypt bardzo fajny, ale bym si? doczepi? tylko do "legs, leg" ;d bo jednak wyst?puje tylko liczba mnoga nogawic, bo leg to ju? noga :p
 
Status
Not open for further replies.
Top