Ir para conteúdo

Featured Replies

Postado

Obrigado ,Snowsz era oque eu precisava.

 

EDIT:

Cara não pensei que a aula 1 seria tao produtiva por ser uma Introdução.
Fica o REP pela indicação sem igual!

Editado por klipstyle (veja o histórico de edições)

www.pokemiw.com
24 Horas Online - 1º 2º 3º 4º 5º 6º 7º gerações 100%
 

  • Respostas 15
  • Visualizações 749
  • Created
  • Última resposta

Top Posters In This Topic

Most Popular Posts

  • vou tentar ajudar primeiro com a quantia aleatória, até porque sou meio amador na área.

  • http://www.tibiaking.com/forum/forum/220-aulas-de-scripting/

  • local cfg = {     soul = 0,     time = 3600,     level = 1 } local t = {     [{11419}] = {fruit = 2675, NFTree = 4008, fName = "Orange"},     [{5094}] = {fruit = 2676, NFTree = 5092, fName = "Banana"}

Postado
  • Autor
local cfg = {
    soul = 0,
    time = 3600,
    level = 1
}
local t = {
    [{11419}] = {fruit = 2675, NFTree = 4008, fName = "Orange"},
    [{5094}] = {fruit = 2676, NFTree = 5092, fName = "Banana"},
    [{5096}] = {fruit = 2678, NFTree = 2726, fName = "Coconut"},
    [{5157}] = {fruit = 5097, NFTree = 5156, fName = "Mango"}
}
function onUse(cid, item, frompos, item2, topos)
    local S = getPlayerSoul(cid)
    local L = getPlayerLevel(cid)
    for i, k in pairs(t) do
        if (isInArray(i, item.itemid) == true) and (S >= cfg.soul) and (L >= cfg.level) then
            addEvent(function()
                local i = getTileItemById(k.NFTree, topos).uid
                if i > 0 then
                    doTransformItem(i, item.itemid)
                end
            end, cfg.time * 1000)
            doTransformItem(item.uid, k.NFTree)
            doPlayerAddItem(cid, k.fruit, math.random(1, 10))
            doPlayerAddSoul(cid, -cfg.soul)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got some "..k.fName..".")
        elseif (S < cfg.soul) then
            doPlayerSendCancel(cid, "You do not have soul to harvest the plant.")
        elseif (L < cfg.level) then
            doPLayerSendCancel(cid, "You are not in the requiered level to harvest.")
        end
    end
    return true
end

 

[29/05/2015 22:14:09] [Error - Action Interface]
[29/05/2015 22:14:09] In a timer event called from:
[29/05/2015 22:14:09] data/actions/scripts/harvest plants.lua:onUse
[29/05/2015 22:14:09] Description:
[29/05/2015 22:14:09] attempt to index a number value
[29/05/2015 22:14:09] stack traceback:
[29/05/2015 22:14:09]     [C]: in function 'getTileItemById'
[29/05/2015 22:14:09]     data/actions/scripts/harvest plants.lua:18: in function <data/actions/scripts/harvest plants.lua:17>
Postado
  • Solução
local cfg = {
    soul = 0,
    time = 3600,
    level = 1
}
local t = {
    [{11419}] = {fruit = 2675, NFTree = 4008, fName = "Orange"},
    [{5094}] = {fruit = 2676, NFTree = 5092, fName = "Banana"},
    [{5096}] = {fruit = 2678, NFTree = 2726, fName = "Coconut"},
    [{5157}] = {fruit = 5097, NFTree = 5156, fName = "Mango"}
}
function onUse(cid, item, frompos, item2, topos)
    local S = getPlayerSoul(cid)
    local L = getPlayerLevel(cid)
    for i, k in pairs(t) do
        if (isInArray(i, item.itemid) == true) and (S >= cfg.soul) and (L >= cfg.level) then
            local info = {fromId = k.NFTree, toId = item.itemid, pos = topos}
            addEvent(function()
                local i = getTileItemById(info.pos, info.fromId).uid
                if i > 0 then
                    doTransformItem(i, info.toId)
                end
            end, cfg.time * 1000)
            doTransformItem(item.uid, k.NFTree)
            doPlayerAddItem(cid, k.fruit, math.random(1, 10))
            doPlayerAddSoul(cid, -cfg.soul)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got some "..k.fName..".")
        elseif (S < cfg.soul) then
            doPlayerSendCancel(cid, "You do not have soul to harvest the plant.")
        elseif (L < cfg.level) then
            doPLayerSendCancel(cid, "You are not in the requiered level to harvest.")
        end
    end
    return true
end

Editado por zipter98 (veja o histórico de edições)

não respondo pms solicitando suporte em programação/scripting

Postado
  • Autor
local cfg = {
    soul = 0,
    time = 3600,
    level = 1
}
local t = {
    [{11419}] = {fruit = 2675, NFTree = 4008, fName = "Orange"},
    [{5094}] = {fruit = 2676, NFTree = 5092, fName = "Banana"},
    [{5096}] = {fruit = 2678, NFTree = 2726, fName = "Coconut"},
    [{5157}] = {fruit = 5097, NFTree = 5156, fName = "Mango"}
}
function onUse(cid, item, frompos, item2, topos)
    local S = getPlayerSoul(cid)
    local L = getPlayerLevel(cid)
    for i, k in pairs(t) do
        if (isInArray(i, item.itemid) == true) and (S >= cfg.soul) and (L >= cfg.level) then
            local info = {fromId = k.NFTree, toId = item.itemid, pos = topos}
            addEvent(function()
                local i = getTileItemById(info.fromId, info.pos).uid
                if i > 0 then
                    doTransformItem(i, info.toId)
                end
            end, cfg.time * 1000)
            doTransformItem(item.uid, k.NFTree)
            doPlayerAddItem(cid, k.fruit, math.random(1, 10))
            doPlayerAddSoul(cid, -cfg.soul)
            doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You got some "..k.fName..".")
        elseif (S < cfg.soul) then
            doPlayerSendCancel(cid, "You do not have soul to harvest the plant.")
        elseif (L < cfg.level) then
            doPLayerSendCancel(cid, "You are not in the requiered level to harvest.")
        end
    end
    return true
end

 

 

[29/05/2015 23:17:38] [Error - Action Interface]
[29/05/2015 23:17:38] In a timer event called from:
[29/05/2015 23:17:38] data/actions/scripts/harvest plants.lua:onUse
[29/05/2015 23:17:38] Description:
[29/05/2015 23:17:38] attempt to index a number value
[29/05/2015 23:17:38] stack traceback:
[29/05/2015 23:17:38]     [C]: in function 'getTileItemById'
[29/05/2015 23:17:38]     data/actions/scripts/harvest plants.lua:19: in function <data/actions/scripts/harvest plants.lua:18>

Participe da conversa

Você pode postar agora e se cadastrar mais tarde. Se você tem uma conta, faça o login para postar com sua conta.

Visitante
Responder

Quem Está Navegando 0

  • Nenhum usuário registrado visualizando esta página.

Estatísticas dos Fóruns

  • Tópicos 96.9k
  • Posts 519.6k

Informação Importante

Confirmação de Termo