calma ae tenta assim:
nome do seu npc.xml
<?xml version="1.0" encoding="UTF-8"?>
<npc name="Nome do seu npc" script="nome do seu script.lua" walkinterval="2000" floorchange="0">
<health now="100" max="100"/>
<look type="133" head="114" body="119" legs="132" feet="114"/>
</npc>
nome do seu script.lua
dofile("data/npc/lib/npc-func.lua")
local focuses = {} -- do not change
function onCreatureSay(cid, type, msg)
local falas = {
[1] = { -- druid
hi = 'Hello, mage of the skies. blablabla {yes} ?',
yes = 'ok mage! kkkkk',
no = 'ok then mage',
bye = 'Good bye '.. getCreatureName(cid) ..'.'
},
[2] = { -- sorc
hi = 'Hello my forest enchanter blablabla {yes} ?',
yes = 'ok forest enchanter! kkkkk',
no = 'ok then forest gamp',
bye = 'Good bye '.. getCreatureName(cid) ..'.'
},
[3] = { -- paladin
hi = 'Hey! Super shooter blablabla {yes} ?',
yes = 'ok Super shooter! kkkkk',
no = 'ok then super shooter',
bye = 'Good bye '.. getCreatureName(cid) ..'.'
},
[4] = { -- knight
hi = 'Aye, guardian blablabla {yes} ?',
yes = 'ok guardian! kkkkk',
no = 'ok then gaydian',
bye = 'Good bye '.. getCreatureName(cid) ..'.'
}
}
local cid_Say = msg:lower()
if ((cid_Say == "hi") and not (isFocused(cid, focuses))) then
if not falas[getPlayerVocation(cid)] then
selfSay('desculpe,não falo com você!', cid)
removeFocus(cid, focuses)
else
selfSay(falas[getPlayerVocation(cid)].hi, cid)
addFocus(cid, focuses)
selfFocus(cid)
talk_step = 1
end
elseif ((cid_Say == "yes") and (talk_step == 1)) then
selfSay(falas[getPlayerVocation(cid)].yes, cid)
talk_step = 2
elseif ((cid_Say == "no") and (isInArray({1,2}, talk_step))) then
selfSay(falas[getPlayerVocation(cid)].no, cid)
removeFocus(cid, focuses)
elseif (cid_Say == "bye") then
selfSay(falas[getPlayerVocation(cid)].bye, cid)
removeFocus(cid, focuses)
end
end
function onThink()
for _, focus in pairs(focuses) do
if not isCreature(focus) then
removeFocus(focus, focuses)
talk_step = 0
else
local distance = getDistanceTo(focus) or 5
if distance > 4 then
selfSay("Hmpf!", focus)
removeFocus(focus, focuses)
talk_step = 0
end
end
end
setFocus(focuses)
end
crie um arquivo chamado "npc-func.lua" em "data/npc/lib" e poe isso
local focuses = {}
function isFocused(cid, t)
for i, v in pairs(t) do
if(v == cid) then
return true
end
end
return false
end
function addFocus(cid, t)
if(not isFocused(cid, t)) then
table.insert(t, cid)
end
end
function setFocus(t)
for i, v in pairs(t) do
if(isPlayer(v)) then
doNpcSetCreatureFocus(v)
return
end
end
doNpcSetCreatureFocus(0)
end
function removeFocus(cid, t)
for i, v in pairs(t) do
if(v == cid) then
table.remove(t, i)
setFocus(focuses)
break
end
end
end
function onCreatureDisappear(cid)
if isFocused(cid, focuses) then
removeFocus(cid, focuses)
if isPlayer(cid) then
closeShopWindow(cid)
end
end
end
lembrando q tirei essa base de script do LsM
tenta ae