Você fala com o npc:
-hi
->Voce quer que eu encha seu pote de health por 50 gps?
-encher
->Ai está seu pote cheio =]
Aqui vai um tutorial esplicando como fazê-lo ok?
PRIMEIRO
crie um documento de texto na área de trabalho, renomeando-o para Enche Health.xml e coloque isto dentro dele:
<?xml version="1.0"?>
<npc name="Enche Health" script="data/npc/scripts/encheh.lua" access="1" lookdir="2">
<mana now="800" max="800"/>
<health now="200" max="200"/>
<look type="133" head="78" body="88" legs="0" feet="88"/>
</npc>
pronto, primeiro passo cumprido!
SEGUNDO
Agora abra outro documento de texto renomeando para encheh.lua
e coloque isto dentro dele:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
-- OTServ event handling functions start
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
-- OTServ event handling functions end
function creatureSayCallback(cid, type, msg)
-- 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.
if(npcHandler.focus ~= cid) then
return false
end
if msgcontains(msg, 'health potion') or msgcontains(msg, 'encher') then
selfSay('Voce quer que eu encha seu pote de health por 50 gps?')
talk_state = 1
elseif msgcontains(msg, 'yes') and talk_state == 1 then
if getPlayerItemCount(cid,7636,1) >= 1 and getPlayerItemCount(cid,2148,50) >= 1 then
if doPlayerTakeItem(cid,7636,1) and doPlayerTakeItem(cid,2148,50) == 0 then
selfSay('Ai Esta Seu pote cheio =]')
doPlayerAddItem(cid,7618,1)
end
else
selfSay('Desculpe Voce Nao Tem os itens precisos.')
end
elseif msgcontains(msg, 'no') and (talk_state >= 1 and talk_state <= 5) then
selfSay('Ok Ate Mais.')
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())
Pronto! agora é só adicionar ele no seu map editor assim:
vá na pasta do map editor e abra o creatures.xml e adicione isto na lista!
<creature looktype="133" name="Enche Health" head="78" body="88" legs="0" feet="88" type="npc"/>
aew! agora é só colocar ele no seu mapa pelo map editor
Obs: esse npc substitui o pote vazio pelo pote cheio, pegando a sua grana, intão voce pode usar isso pra fazer outros itens serem substituidos!!
Creditos:Apenas Eu =]