Ir para conteúdo

Npc Que troca X item Por outro item


HurlockII

Posts Recomendados

Pessoal, alguém poderia deixar um script De um npc que troque X item por outro 
Gostaria de um npc que pegasse 130 Fragment of Mega Stone (20719)
Por 1 Mega stone (14252)

Se alguem puder me ajudar agradeço 

Link para o comentário
Compartilhar em outros sites

Aqui esta meu amigo, caso você queria que o player troque apenas uma vez com o npc só me falar:

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
if(msgcontains(msg, 'change')) then
selfSay('Yes, i am exchanging fragments of mega stone for a mega stone! Do you want to change?')
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if(doPlayerRemoveItem(cid, 20719, 130)) then
doPlayerAddItem(cid, 14252, 1)
selfSay('Here your mega stone, thank you for your fragments!')
else
selfSay('Sorry, but you do not have the 130 fragments you need to trade!')
end
end
return true
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

.xml do npc:

<?xml version="1.0" encoding="UTF-8"?>
<npc name="Julie" script="Julie.lua" walkinterval="0" floorchange="0">
<health now="100" max="100"/>
<look type="511" head="9" body="1" legs="1" feet="0" addons="0"/>
<parameters>
<parameter key="message_greet" value="Mega stones? I change!" />
</parameters>
</npc>

 

Editado por Rookie
Link para o comentário
Compartilhar em outros sites

  • 3 weeks later...
Em 25/11/2017 at 12:39, Rookie disse:

Aqui esta meu amigo, caso você queria que o player troque apenas uma vez com o npc só me falar:


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
if(msgcontains(msg, 'change')) then
selfSay('Yes, i am exchanging fragments of mega stone for a mega stone! Do you want to change?')
talkState[talkUser] = 1
elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
if(doPlayerRemoveItem(cid, 20719, 130)) then
doPlayerAddItem(cid, 14252, 1)
selfSay('Here your mega stone, thank you for your fragments!')
else
selfSay('Sorry, but you do not have the 130 fragments you need to trade!')
end
end
return true
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

 

.xml do npc:


<?xml version="1.0" encoding="UTF-8"?>
<npc name="Julie" script="Julie.lua" walkinterval="0" floorchange="0">
<health now="100" max="100"/>
<look type="511" head="9" body="1" legs="1" feet="0" addons="0"/>
<parameters>
<parameter key="message_greet" value="Mega stones? I change!" />
</parameters>
</npc>

 

Teria como por para receber XP ?

Link para o comentário
Compartilhar em outros sites

  • 2 weeks later...
Em 17/12/2017 at 00:41, mastof disse:

Teria como por para receber XP ?

Desculpe demorar para responder, configurei para receber 3000 de exp toda vez que o player trouxer os fragmentos, mas você pode configurar ao seu gosto apenas alterando o valor nesta linha: doPlayerAddExperience(cid, 3000):

 

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
	if(msgcontains(msg, 'change')) then
		selfSay('Yes, i am exchanging fragments of mega stone for a mega stone! Do you want to change?')
		talkState[talkUser] = 1
	elseif(msgcontains(msg, 'yes') and talkState[talkUser] == 1) then
		if(doPlayerRemoveItem(cid, 20719, 130)) then
			doPlayerAddItem(cid, 14252, 1)
			doPlayerAddExperience(cid, 3000) 
			selfSay('Here your mega stone, thank you for your fragments!')
		else
			selfSay('Sorry, but you do not have the 130 fragments you need to trade!')
			end
		end
		return true
	end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())
Link para o comentário
Compartilhar em outros sites

×
×
  • Criar Novo...