Ir para conteúdo
  • 0

Erro Nos Npc's Quando Vou Abrir O Ot, Oq Fazer?


Prezyoso

Pergunta

12 respostass a esta questão

Posts Recomendados

  • 0

Me ajuda em 1 apenas q eu faço com os outros, rsrs.

 

Ta ae o do fighter:

 

 

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') then

 

selfSay('Hey Do you have 20 dino eye for me?')

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,6021) == 1 then

 

selfSay('Sorry You Cant Do this quest.')

elseif msgcontains(msg, 'yes') then

if doPlayerRemoveItem(cid,6543,20) == 0 then

selfSay('Sorry Dont have that items.')

 

else

if doPlayerAddItem(cid,2395,1) then

 

setPlayerStorageValue(cid,6021,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

 

 

 

Link para o comentário
Compartilhar em outros sites

  • 0

.

 

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') then
selfSay('Hey Do you have 20 dino eye for me?')
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,6021) == 1 then
selfSay('Sorry You Cant Do this quest.')
elseif msgcontains(msg, 'yes') then
if doPlayerRemoveItem(cid,6543,20) == 0 then
selfSay('Sorry Dont have that items.')
else
if doPlayerAddItem(cid,2395,1) then
setPlayerStorageValue(cid,6021,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()
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

 

veja agr

Link para o comentário
Compartilhar em outros sites

  • 0

Nao tem cara...

 

 

 

-- get the distance to a creature

function getDistanceToCreature(id)

if id == 0 or id == nil then

selfGotoIdle()

end

cx, cy, cz = creatureGetPosition(id)

if cx == nil then

return nil

end

sx, sy, sz = selfGetPosition()

return math.max(math.abs(sx-cx), math.abs(sy-cy))

end

 

-- do one step to reach position

function moveToPosition(x,y,z)

selfMoveTo(x, y, z)

end

 

-- do one step to reach creature

function moveToCreature(id)

if id == 0 or id == nil then

selfGotoIdle()

end

tx,ty,tz=creatureGetPosition(id)

if tx == nil then

selfGotoIdle()

else

moveToPosition(tx, ty, tz)

end

end

 

-- stop talking

function selfGotoIdle()

following = false

attacking = false

selfAttackCreature(0)

target = 0

end

 

-- getCount function by Jiddo

function getCount(msg)

b, e = string.find(msg, "%d+")

 

if b == nil or e == nil then

count = 1

else

count = tonumber(string.sub(msg, b, e))

end

 

if count > 2000 then

count = 2000

end

 

return count

end

 

-- buy an item

function buy(cid, itemid, count, cost)

cost = count*cost

amount = count

if doPlayerRemoveMoney(cid, cost) == 1 then

if getItemStackable(itemid) then

while count > 100 do

doPlayerAddItem(cid, itemid, 100)

count = count - 100

end

 

doPlayerAddItem(cid, itemid, count) -- add the last items, if there is left

else

while count > 0 do

doPlayerAddItem(cid, itemid, 1)

count = count - 1

end

end

 

if amount <= 1 then

selfSay('Here is your '.. getItemName(itemid) .. '!')

else

selfSay('Here are your '.. amount ..' '.. getItemName(itemid) .. 's!')

end

else

selfSay('Sorry, you do not have enough money.')

end

end

 

function buyFluidContainer(cid, itemid, count, cost, fluidtype)

cost = count*cost

amount = count

if doPlayerRemoveMoney(cid, cost) == 1 then

while count > 0 do

doPlayerAddItem(cid, itemid, fluidtype)

count = count - 1

end

 

if amount <= 1 then

selfSay('Here is your '.. getItemName(itemid) .. '!')

else

selfSay('Here are your '.. amount ..' '.. getItemName(itemid) .. 's!')

end

else

selfSay('Sorry, you do not have enough money.')

end

end

 

-- sell an item

function sell(cid, itemid, count, cost)

cost = count*cost

if doPlayerRemoveItem(cid, itemid, count) == 1 then

coins = math.floor(cost/10000)

crystals = coins

while coins > 100 do

doPlayerAddItem(cid, 2160, 100)

coins = coins - 100

end

 

doPlayerAddItem(cid, 2160, coins)

cost = cost - crystals*10000

 

coins = math.floor(cost/100)

if coins > 0 then

doPlayerAddItem(cid, 2152, coins)

cost = cost - coins*100

end

coins = cost

if cost > 0 and cost < 100 then

doPlayerAddItem(cid, 2148, coins)

cost = cost - coins

end

 

if cost > 0 then

selfSay('You couldn\'t retrieve '.. cost ..' gold pieces, please contact the admin.')

end

 

if count <= 1 then

selfSay('Thanks for this '.. getItemName(itemid) .. '!')

else

selfSay('Thanks for these '.. count..' '.. getItemName(itemid) .. 's!')

end

else

selfSay('Sorry, you do not have this item.')

end

end

 

-- pay for anything?

function pay(cid, cost)

if doPlayerRemoveMoney(cid, cost) == 1 then

return true

else

return false

end

end

 

-- Travel player

function travel(cid, x, y, z)

destpos = {x = x, y = y, z = z}

doTeleportThing(cid, destpos)

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

 

 

Link para o comentário
Compartilhar em outros sites

Visitante
Este tópico está impedido de receber novos posts.
×
×
  • Criar Novo...