Ir para conteúdo
  • 0

EDIT NPC


carlinhoo0ww

Pergunta

alguem poderia me ajudar??

queria colocar esse npc para trocar 4 items em apenas 1.

eles sao: 8262, 8263, 8264, 8265 para trocar em um 8266.

 

 

local keywordHandler = KeywordHandler:new()local npcHandler = NpcHandler:new(keywordHandler)NpcSystem.parseParameters(npcHandler)function onCreatureAppear(cid)			npcHandler:onCreatureAppear(cid)			endfunction onCreatureDisappear(cid)		npcHandler:onCreatureDisappear(cid)			endfunction onCreatureSay(cid, type, msg)	npcHandler:onCreatureSay(cid, type, msg)	endfunction onThink()						npcHandler:onThink()	end-- Config --local configs = {	FirstItemId = 2455,	FirstItemCount = 5,	SecondItemId = 2321,	SecondItemCount = 1,	isQuest = "false",		questStorage = 17890,	msgMeet = 'Você deseja trocar '..FirstItemCount .. ' '.. getItemName(FirstItemId) ..' por '.. SecondItemCount ..' '.. getItemName(SecondItemId) ..'?',	msgQuestCompleted = "Você já fez essa quest.",	msgQuestNotItem = "Voce não tem o item necessario.",	}function npcTroca(cid, message, keywords, parameters, node)	if(not npcHandler:isFocused(cid)) then		return false	end	if (configs.isQuest == "true") then	if (getPlayerStorageValue(configs.questStorage) <= 0) then		if (getItemCount(cid, configs.FirstItemId) == configs.FirstItemCount) then			doRemoveItem(configs.FirstItemId, config.FirstItemCount)			doPlayerAddItem(cid, configs.SecondItemId, configs.SecondItemCount)		else			return	 doPlayerSendTextMessage(cid, 27, configs.msgQuestNotItem)		end	else		return doPlayerSendTextMessage(cid, 27, configs.msgQuestCompleted)	end   else	if (getItemCount(cid, configs.FirstItemId) == configs.FirstItemCount) then		doRemoveItem(configs.FirstItemId, config.FirstItemCount)		doPlayerAddItem(cid, configs.SecondItemId, configs.SecondItemCount)	else		return	 doPlayerSendTextMessage(cid, 27, configs.msgQuestNotItem)	end	   endenditemTrade = keywordHandler:addKeyword({'offer'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = configs.msgMeet})itemTrade:addChildKeyword({'yes'}, npcTroca, {})itemTrade:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then.', reset = true})npcHandler:addModule(FocusModule:new())
Link para o comentário
Compartilhar em outros sites

2 respostass a esta questão

Posts Recomendados

  • 0

@carlinhoo0ww, vê se resolve teu problema:

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
-- Config --
local configs = {

items = {
[8262] = {count = 1},
[8263] = {count = 1},
[8264] = {count = 1},
[8265] = {count = 1},
}
SecondItemId = 8266,
SecondItemCount = 1,

	isQuest = "false",	
	questStorage = 17890,
	msgMeet = 'Você deseja trocar '..items[8262].count ..' '..getItemName(8262)..', '..items[8263].count ..' '..getItemName(8263)..', '..items[8264].count ..' '..getItemName(8264)..', '..items[8265].count ..' '..getItemName(8265)..' por '..SecondItemCount..' '..getItemName(SecondItemId)..'?',
	msgQuestCompleted = "Você já fez essa quest.",
	msgQuestNotItem = "Voce não tem os itens necessarios.",
	}

function npcTroca(cid, message, keywords, parameters, node)
	if(not npcHandler:isFocused(cid)) then
		return false
	end
	c = 0
	for k, v in pairs(configs.items) do
		if getItemCount(cid, configs.items[k]) >= configs.items[k].count then
		c=c+1
		end
	end
	if (configs.isQuest == "true") then
		if (getPlayerStorageValue(configs.questStorage) <= 0) then
			if c == #configs.items then
				for k, v in pairs(configs.items) do
					doRemoveItem(configs.items[k], configs.items[k].count)
					doPlayerAddItem(cid, configs.SecondItemId, configs.SecondItemCount)
				end
			else
				return doPlayerSendTextMessage(cid, 27, configs.msgQuestNotItem)
			end
		else
			return doPlayerSendTextMessage(cid, 27, configs.msgQuestCompleted)
		end
	else
		if c == #configs.items then
			for k, v in pairs(configs.items) do
				doRemoveItem(configs.items[k], configs.items[k].count)
				doPlayerAddItem(cid, configs.SecondItemId, configs.SecondItemCount)
			end
		else
			return doPlayerSendTextMessage(cid, 27, configs.msgQuestNotItem)
		end
   end
end


itemTrade = keywordHandler:addKeyword({'offer'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = configs.msgMeet})
itemTrade:addChildKeyword({'yes'}, npcTroca, {})
itemTrade:addChildKeyword({'no'}, StdModule.say, {npcHandler = npcHandler, onlyFocus = true, text = 'Alright then.', reset = true})
npcHandler:addModule(FocusModule:new())nd

 

Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...