Ir para conteúdo

Posts Recomendados

Alguem tem pra me arrumar esse npc q vende addons separado...mais sem ser em troca de itens.

Queria um q tenha q comprar separado por ropinha por ropinha soh q em troca de dinheiro ;D..

 

Plx pLx

Obrigado

Link para o comentário
https://xtibia.com/forum/topic/116768-npc-que-vende-addons-para-850-plx/
Compartilhar em outros sites

Cara dependendo de quais addons vc prescisa... se for todos vc continua com esse exemplo (citizen addon 1)

 

local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)


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

npcHandler:setMessage(MESSAGE_GREET, "Greetings |PLAYERNAME|. Will you help me? If you do, I'll sell citizen first addon! Just say {addon} or {help} if you don't know what to do.")

function playerBuyAddonNPC(cid, message, keywords, parameters, node)
if(not npcHandler:isFocused(cid)) then
	return false
end
if (parameters.confirm ~= true) and (parameters.decline ~= true) then
	if(getPlayerPremiumDays(cid) == 0) and (parameters.premium == true) then
		npcHandler:say('Sorry, but this addon is only for premium players!', cid)
		npcHandler:resetNpc()
		return true
	end
	if (getPlayerStorageValue(cid, parameters.storageID) ~= -1) then
		npcHandler:say('You already have this addon!', cid)
		npcHandler:resetNpc()
		return true
	end
	local itemsTable = parameters.items
	local items_list = ''
	if table.maxn(itemsTable) > 0 then
		for i = 1, table.maxn(itemsTable) do
			local item = itemsTable[i]
			items_list = items_list .. item[2] .. ' ' .. getItemNameById(item[1])
			if i ~= table.maxn(itemsTable) then
				items_list = items_list .. ', '
			end
		end
	end
	local text = ''
	if (parameters.cost > 0) and table.maxn(parameters.items) then
		text = items_list .. ' and ' .. parameters.cost .. ' gp'
	elseif (parameters.cost > 0) then
		text = parameters.cost .. ' gp'
	elseif table.maxn(parameters.items) then
		text = items_list
	end
	npcHandler:say('Did you bring me ' .. text .. ' for ' .. keywords[1] .. '?', cid)
	return true
elseif (parameters.confirm == true) then
	local addonNode = node:getParent()
	local addoninfo = addonNode:getParameters()
	local items_number = 0
	if table.maxn(addoninfo.items) > 0 then
		for i = 1, table.maxn(addoninfo.items) do
			local item = addoninfo.items[i]
			if (getPlayerItemCount(cid,item[1]) >= item[2]) then
				items_number = items_number + 1
			end
		end
	end
	if(getPlayerMoney(cid) >= addoninfo.cost) and (items_number == table.maxn(addoninfo.items)) then
		doPlayerRemoveMoney(cid, addoninfo.cost)
		if table.maxn(addoninfo.items) > 0 then
			for i = 1, table.maxn(addoninfo.items) do
				local item = addoninfo.items[i]
				doPlayerRemoveItem(cid,item[1],item[2])
			end
		end
		doPlayerAddOutfit(cid, addoninfo.outfit_male, addoninfo.addon)
		doPlayerAddOutfit(cid, addoninfo.outfit_female, addoninfo.addon)
		setPlayerStorageValue(cid,addoninfo.storageID,1)
		npcHandler:say('Here you are.', cid)
	else
		npcHandler:say('You do not have needed items or cash!', cid)
	end
	npcHandler:resetNpc()
	return true
elseif (parameters.decline == true) then
	npcHandler:say('Not interested? Maybe other addon?', cid)
	npcHandler:resetNpc()
	return true
end
return false
end

local noNode = KeywordNode:new({'no'}, playerBuyAddonNPC, {decline = true})
local yesNode = KeywordNode:new({'yes'}, playerBuyAddonNPC, {confirm = true})

-- citizen by delton(done)
local outfit_node = keywordHandler:addKeyword({'citizen cloth'}, playerBuyAddonNPC, {premium = true, cost = 10000,  outfit_female = 136, outfit_male = 128, addon = 1, storageID = 10001})
outfit_node:addChildKeywordNode(yesNode)
outfit_node:addChildKeywordNode(noNode)

keywordHandler:addKeyword({'addons'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'I sell citizen first addon.'})
keywordHandler:addKeyword({'help'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'To buy the first citizen addon say \'citizen cloth\'.'})

npcHandler:addModule(FocusModule:new())

 

Baseado num dos NPC's do meu Thyrania =)

 

Delton~~

Link para o comentário
https://xtibia.com/forum/topic/116768-npc-que-vende-addons-para-850-plx/#findComment-766124
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
  • Quem Está Navegando   0 membros estão online

    • Nenhum usuário registrado visualizando esta página.
×
×
  • Criar Novo...