@kttallan, pelo que dá pra entender, nessa linha você está qrnd pegar o id de um item.
local tb = tables[item.itemid]
Sendo que você está usando um parâmetro (item) que não possui nenhum valor atribuído.
Faria sentido utilizar essa linha se o script fosse um action. Eis o porquê:
Citarfunction onUse(cid, item)
Como você pode ver, aqui se vc utilizar o parâmetro item em algum lugar do script (action), ele terá um valor que terá sido pego automaticamente no momento em que o script foi acionado.
Porém você está utilizando um onCreatureSay, e nesse tipo de evento, não é possível utilizar o parâmetro item.
Vc terá que arranjar alguma outra forma de capturar o id do item X que vc tá qrnd.
Não sei se me fiz entender, mas espero que sim... sahusahusahu
possível solução:
Já que na tabela tables vc tá usando só 1 elemento, acredito que usar isso não irá te trazer problemas:
for k, v in pairs(tables) do if getPlayerItemCount(cid, k) > 0 then ..etc etc.. end end




info
Grupo: Infante
Registrado: 06/03/13
Posts: 1.6k
Reputação: +319
Gênero: Masculino
Char no Tibia: Lord Sorte
Olá pessoal eu estava fazendo um sisteminha aqui para meu servidor porém eu tive um erro relacionado a tabela, gostaria da ajuda de vocês para conseguir concerta-lo se possivel uma explicação do motivo desse erro.
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
local talkState = {}
local focus = 0
local talk_start = 0
function onCreatureSay(cid, type, msg)
local msg = string.lower(msg)
local talkUser = NPCHANDLER_CONVBEHAVIOR == CONVERSATION_DEFAULT and 0 or cid
local tables = {
[12127] = {preco = 10, storage = 1212, storagese = 1213, tempo = 24 * 60 * 60, pokemon = "Arcanine"}
}
local tb = tables[item.itemid]
local temp = os.time() + tb.tempo
if not (getDistanceToCreature(cid) <= 3) then
return true
end
if msgcontains(string.lower(msg), 'hi') then
if focus ~= 0 and focus ~= cid then
selfSay(getCreatureName(cid) .. ' aguarde...')
return true
else
focus = cid
talk_start = os.clock()
end
end
if msgcontains(string.lower(msg), 'hi') then
selfSay('Oi! Voce deseja {checar}, {entregar} ou {retirar}?')
talkState[talkUser] = 1
elseif msgcontains(string.lower(msg), 'checar') and talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, tb.storage) < temp then
selfSay('Seu pokemon ja esta pronto.')
else
selfSay('Ainda falta [' .. getPlayerStorageValue(cid, tb.storage) < temp ..'], Para seu pokemon esta pronto')
talkState[talkUser] = 0
focus = 0
tchau = true
end
elseif msgcontains(string.lower(msg), 'entregar') and talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, tb.storagese) > 1 then
selfSay('Voce já tem um ovo comigo, espere terminar')
return true end
if getPlayerItemCount(cid, 2160) < tb.preco then
selfSay('Voce nao tem dinheiro necessesario para compeltar essa acao')
return true end
if getPlayerItemCount(cid, tb) < 1 then
selfSay('Voce nao tem nenhum ovo listado')
return true end
doPlayerRemoveItem(cid, tb, 1)
setPlayerStorageValue(cid, tb.storage, temp)
setPlayerStorageValue(cid, tb.storagese, 1)
selfSay('Seu ovo estara pronto em breve, toda vez que possivel cheque o ovo para acompanhar o progresso!')
talkState[talkUser] = 0
focus = 0
tchau = true
elseif msgcontains(string.lower(msg), 'retirar') and talkState[talkUser] == 1 then
if getPlayerStorageValue(cid, tb.storage) < temp then
setPlayerStorageValue(cid, tb.storagese, -1)
addPokeToPlayer(cid, tb.pokemon, 0)
selfSay('Uau, seu ovo foi chocado parabens agora voce tem um ' ..tb.pokemon..'.')
talkState[talkUser] = 0
focus = 0
tchau = true
return true
end
if tchau then
tchau = false
doCreatureSetLookDir(getThis(), lookNpcDir)
selfSay('Tchau.')
end
end
end
function onThink()
if focus ~= 0 then
if getDistanceToCreature(focus) > 3 then
tchau = true
focus = 0
end
if (os.clock() - talk_start) > 15 then
if focus > 0 then
tchau = true
focus = 0
end
end
doNpcSetCreatureFocus(focus)
end
if tchau then
tchau = false
selfSay('Tchau.')
end
end