Ir para conteúdo
  • 0

NPC Morpheu troca itens


weverton1559

Pergunta

5 respostass a esta questão

Posts Recomendados

  • 0

data\npc\nomedonpc.xml

<npc name="NOMEDONPC" script="data/npc/scripts/nomedoarquivo.lua" walkinterval="2000" floorchange="0">
   <health now="100" max="100"/>
   <look type="134" head="78" body="88" legs="0" feet="88" addons="3"/>
    <parameters>
		    <parameter key="message_greet" value="Yes." />
		    <parameter key="message_farewell" value="Tchau." />
		    <parameter key="message_walkaway" value="Tchau." />
    </parameters>
</npc>

data\npc\scripts\nomedoarquivo.lua

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
npcHandler:setMessage(MESSAGE_GREET, "eu troco item pra vc? me diz (yes)")   -- muda a frase   só yes q não muda
function creatureSayCallback(cid, type, msg)
if(not npcHandler:isFocused(cid)) then
return false
end
local h = 2160 -- ID do item que vai troca
local j = 2200 -- ID que vai ganhar
local talkUser = NPCHANDLER_CONVbehavior == CONVERSATION_DEFAULT and 0 or cid
if(msgcontains(msg, 'yes')) then
if doPlayerRemoveItem(cid,h,100) then
doPlayerAddItem(cid,j,10)
selfSay('Obrigado por troca cmg.',cid)   -- muda a frase
talkState[talkUser] = 1
else
selfSay('vc não tem item que eu quero..',cid)   -- muda a frase
talkState[talkUser] = 1
end
return TRUE
end
end
npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)
npcHandler:addModule(FocusModule:new())

Link para o comentário
Compartilhar em outros sites

  • 0

data/npc/scripts crie um arquivo chamado Morpheu.xml

 

coloque isso dentro:

 

 

 

<?xml version="1.0" encoding="UTF-8"?>

<npc name="Morpheu" script="data/npc/scripts/morheu.lua" walkinterval="0" floorchange="0">

<health now="100" max="100"/>

<look type="160" head="192" body="29" legs="40" feet="27" addons="0"/>

<parameters>

<parameter key="module_shop" value="1" />

<parameter key="module_keywords" value="1" />

<parameter key="keywords" value="exchange;" />

<parameter key="keyword_reply1" value="I can exchange {giant spider silk} for a Spool Of Yarn, are you interested? "/>

<parameter key="shop_buyable" value="blessed wooden stake,5942,1000;obsidian knife,5908,5000;" />

<parameter key="message_greet" value="Oh, Welcome |PLAYERNAME|, say {exchange} !" />

<parameter key="message_sendtrade" value="Here is my offer, also ask me for {exchange} if you want to get some special items!" />

<parameter key="message_farewall" value="Good bye!"/>

<parameter key="message_walkaway" value="Good bye then!"/>

</parameters>

</npc>

 

 

dps em scripts crie um script chamado morpheu.lua coloque isso dentro:

 

 

 

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

 

item = 'You do not have the required items.'

done = 'Here you are.'

 

function creatureSayCallback(cid, type, msg)

if(not npcHandler:isFocused(cid)) then

return false

end

 

if msgcontains(msg, 'giant spider silk') then

if getPlayerItemCount(cid,5879) >= 1 then

selfSay('Did you bring me the Giant spider Silk?', cid)

talk_state = 1

else

selfSay('I need a {giant spider silk}, to give you the Spool of Yarn. Come back when you have them.', cid)

talk_state = 0

end

 

elseif msgcontains(msg, 'yes') and talk_state == 1 then

talk_state = 0

if getPlayerItemCount(cid,5879) >= 1 then

if doPlayerRemoveItem(cid,5879, 10) == TRUE then

selfSay(done, cid)

doPlayerAddItem(cid, 5886, 1)

end

else

selfSay(item, cid)

end

 

elseif msgcontains(msg, 'dfdfdfh') then

if getPlayerItemCount(cid,5911) >= 1 then

selfSay('Did you bring me the red piece of cloth?', cid)

talk_state = 2

else

selfSay('I need a {red piece of cloth}, to give you the Dragon Throne. Come back when you have it.', cid)

talk_state = 0

end

elseif msgcontains(msg, 'yes') and talk_state == 2 then

talk_state = 0

if getPlayerItemCount(cid,5911) >= 1 then

if doPlayerRemoveItem(cid,5911,1) == TRUE then

selfSay(done, cid)

doPlayerAddItem(cid,11199,1)

end

else

selfSay(item, cid)

end

 

elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then

selfSay('So Leave, LEAVE ME NOW!')

talk_state = 0

end

-- Place all your code in here. Remember that hi, bye and all that stuff is already handled by the npcsystem, so you do not have to take care of that yourself.

return true

end

 

npcHandler:setCallback(CALLBACK_MESSAGE_DEFAULT, creatureSayCallback)

npcHandler:addModule(FocusModule:new())

 

 

Basta falar com ele e sabera o que dizer...

 

Lembrando que ja fiz tudo que tinha que fazer, o npc ja ta trocando certinho os itens...

Link para o comentário
Compartilhar em outros sites

  • 0

@notle2012 - a script dar erro. mesmo assim obrigado.

 

@SkyLigh - o titulo estar correto, o nome do npc e esse não fui eu que criei tem em vários outros tópicos falando

 

mesmo nome mais a script que eu achei estar bugada.

 

@GuizitoG - na sua scripter ele troca por RED PIECES.

 

@nathan96 mim ajudou via pm por isso meu +rep vai pra ele. muito obrigado a todos que tentaram.

 

DUVIDA SANADA .

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

×
×
  • Criar Novo...