@Spring Trap, ah saquei... Então nesse caso deixa o npc.lua como tava, então.. :v
*ou seja, remove essa checagem:
if s.z ~= c.z then return nil end
Ficando assim:
function getNpcDistanceToCreature(id) if id == 0 or id == nil then selfIdle() return nil end c = getCreaturePosition(id) if c == nil then return nil end s = getNpcPos() return math.max(math.abs(s.x-c.x), math.abs(s.y-c.y)) end




info
Grupo: Campones
Registrado: 01/05/15
Posts: 49
Reputação: +2
@Danihcv então nao e so ele ta dando em todos o erro de antes voltou. Quando vou pra outra posicao Z ele da o erro
local focus = 0
local talk_start = 0
local target = 0
local following = false
local attacking = false
function onThingMove(creature, thing, oldpos, oldstackpos)
end
function onCreatureAppear(creature)
end
function onCreatureDisappear(cid, pos)
if focus == cid then
selfSay('Good bye then.')
focus = 0
talk_start = 0
end
end
function onCreatureTurn(creature)
end
function msgcontains(txt, str)
return (string.find(txt, str) and not string.find(txt, '(%w+)' .. str) and not string.find(txt, str .. '(%w+)'))
end
function onCreatureSay(cid, type, msg)
msg = string.lower(msg)
if (msgcontains(msg, 'hi') and (focus == 0)) and getDistanceToCreature(cid) < 4 and getCreatureCondition(cid, CONDITION_INFIGHT) == false then
selfSay('Hey Can you give me 1 Bandit King Hood?.')
focus = cid
talk_start = os.clock()
elseif msgcontains(msg, 'hi') and (focus ~= cid) and getDistanceToCreature(cid) < 4 then
selfSay('Sorry, ' .. getCreatureName(cid) .. '! I talk to you in a minute.')
elseif focus == cid then
talk_start = os.clock()
if msgcontains(msg, 'yes') then
if getPlayerStorageValue(cid,6004) == 1 then
selfSay('Sorry You Cant Do this quest.')
elseif msgcontains(msg, 'yes') then
if doPlayerRemoveItem(cid,5879,1) == 0 then
selfSay('Sorry Dont have that items.')
else
if doPlayerAddItem(cid,5919,1) then
setPlayerStorageValue(cid,6004,1)
selfSay('Thanks take this')
focus = 0
talk_start = 0
end
end
end
elseif msgcontains(msg, 'bye') and getDistanceToCreature(cid) < 4 then
selfSay('Good bye, ' .. getCreatureName(cid) .. '!')
focus = 0
talk_start = 0
end
end
end
function onThink()
doNpcSetCreatureFocus(focus)
if (os.clock() - talk_start) > 45 then
if focus > 0 then
selfSay('Next Please...')
end
focus = 0
end
if focus ~= 0 then
if getDistanceToCreature(focus) > 5 then
selfSay('Good bye then.')
focus = 0
end
end
end