Ir para conteúdo

Featured Replies

Postado

TOOLS = {}
TOOLS.ROPE = function(cid, item, fromPosition, itemEx, toPosition)
    if(toPosition.x == CONTAINER_POSITION) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
        return true
    end

    toPosition.stackpos = STACKPOS_GROUND
    error(false)
    local ground = getThingFromPos(toPosition)
    error(true)
    if(isInArray(SPOTS, ground.itemid)) then
        doTeleportThing(cid, {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z - 1}, false)
        return true
    elseif(isInArray(ROPABLE, itemEx.itemid)) then
        local canOnlyRopePlayers = getBooleanFromString(getConfigValue('canOnlyRopePlayers'))
        local hole = getThingFromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z + 1, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE})
        if(canOnlyRopePlayers) then
            if(isPlayer(hole.uid) and (not isPlayerGhost(hole.uid) or getPlayerGhostAccess(cid) >= getPlayerGhostAccess(hole.uid))) then
                doTeleportThing(hole.uid, {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z}, false)
            else
                doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
            end
        else
            if(hole.itemid > 0) then
                doTeleportThing(hole.uid, {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z}, false)
            else
                doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
            end
        end

        return true
    end

    return false
end

TOOLS.PICK = function(cid, item, fromPosition, itemEx, toPosition)
    error(false)
    local ground = getThingFromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z + 1, stackpos = STACKPOS_GROUND})
    error(true)
    if(isInArray(SPOTS, ground.itemid) and isInArray({354, 355}, itemEx.itemid)) then
        doTransformItem(itemEx.uid, 392)
        doDecayItem(itemEx.uid)

        doSendMagicEffect(toPosition, CONST_ME_POFF)
        return true
    end

    if(itemEx.itemid == 7200) then
        doTransformItem(itemEx.uid, 7236)
        doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
        return true
    end

    return false
end

TOOLS.MACHETE = function(cid, item, fromPosition, itemEx, toPosition, destroy)
    if(isInArray(JUNGLE_GRASS, itemEx.itemid)) then
        doTransformItem(itemEx.uid, itemEx.itemid - 1)
        doDecayItem(itemEx.uid)
        return true
    end

    if(isInArray(SPIDER_WEB, itemEx.itemid)) then
        if math.random(3) == 1 then
            doTransformItem(itemEx.uid, (itemEx.itemid + 6))
            doDecayItem(itemEx.uid)
        end
        doSendMagicEffect(toPosition, CONST_ME_POFF)
        return true
    end

    if(isInArray(BAMBOO_FENCE, itemEx.itemid)) then
        if math.random(3) == 1 then
            if(itemEx.itemid == BAMBOO_FENCE[1]) then
                doTransformItem(itemEx.uid, (itemEx.itemid + 161))
            elseif(itemEx.itemid == BAMBOO_FENCE[2]) then
                doTransformItem(itemEx.uid, (itemEx.itemid + 159))
            end
            doDecayItem(itemEx.uid)
        end
        doSendMagicEffect(toPosition, CONST_ME_POFF)
        return true
    end

    if(isInArray(WILD_GROWTH, itemEx.itemid)) then
        doSendMagicEffect(toPosition, CONST_ME_POFF)
        doRemoveItem(itemEx.uid)
        return true
    end

    return destroy and destroyItem(cid, itemEx, toPosition) or false
end

TOOLS.SHOVEL = function(cid, item, fromPosition, itemEx, toPosition)
    if(isInArray(HOLES, itemEx.itemid)) then
 
        local newId = itemEx.itemid + 1
 
        if(itemEx.itemid == 8579) then
            newId = 8585
        end
 
        doTransformItem(itemEx.uid, newId)
        doDecayItem(itemEx.uid)
    elseif(isInArray(SAND, itemEx.itemid)) then
 
        local rand = math.random(1, 100)
        local ground = getThingFromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z + 1, stackpos = STACKPOS_GROUND})    
        if(isInArray(SPOTS, ground.itemid) and rand <= 20) then
            doTransformItem(itemEx.uid, 489)
            doDecayItem(itemEx.uid)
        elseif(rand >= 1 and rand <= 5) then
            doCreateItem(2159, 1, toPosition)
        elseif(rand > 85) then
            doCreateMonster("Scarab", toPosition, false)
        end
 
 
        doSendMagicEffect(toPosition, CONST_ME_POFF)
 
    end
 
 
    return true
end

TOOLS.SCYTHE = function(cid, item, fromPosition, itemEx, toPosition, destroy)
    if(itemEx.itemid == 2739) then
        doTransformItem(itemEx.uid, 2737)
        doCreateItem(2694, 1, toPosition)

        doDecayItem(itemEx.uid)
        return true
    end

    return destroy and destroyItem(cid, itemEx, toPosition) or false
end

TOOLS.KNIFE = function(cid, item, fromPosition, itemEx, toPosition)
    if(itemEx.itemid ~= PUMPKIN) then
        return false
    end

    doTransformItem(itemEx.uid, PUMPKIN_HEAD)
    return true
end

local config = {
    functions = {
        [10511] = { -- sneaky stabber of eliteness
            TOOLS.ROPE,
            TOOLS.SHOVEL,
            TOOLS.PICK,
            TOOLS.MACHETE,
            TOOLS.KNIFE
        },
        [10513] = { -- squeezing gear of girlpower
            TOOLS.ROPE,
            TOOLS.SHOVEL,
            TOOLS.PICK,
            TOOLS.MACHETE,
            TOOLS.SCYTHE
        },
        [10515] = { -- whacking driller of fate
            TOOLS.ROPE,
            TOOLS.SHOVEL,
            TOOLS.PICK,
            TOOLS.MACHETE,
            TOOLS.KNIFE
        }
    },
    jamChance = 10
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local funcs = config.functions[item.itemid]
    if(funcs == nil) then
        return false
    end

    local result = false
    for _, func in ipairs(funcs) do
        if(func(cid, item, fromPosition, itemEx, toPosition)) then
            result = true
            break
        end
    end

    if(not result) then
        return false
    end

    if(math.random(1, 100) <= config.jamChance) then
        doTransformItem(item.uid, item.itemid + 1)
        doDecayItem(item.uid)
    end

    return true
end
  • Respostas 10
  • Visualizações 2.1k
  • Created
  • Última resposta

Top Posters In This Topic

Postado
  • Autor
TOOLS = {}
TOOLS.ROPE = function(cid, item, fromPosition, itemEx, toPosition)
    if(toPosition.x == CONTAINER_POSITION) then
        doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
        return true
    end

    toPosition.stackpos = STACKPOS_GROUND
    error(false)
    local ground = getThingFromPos(toPosition)
    error(true)
    if(isInArray(SPOTS, ground.itemid)) then
        doTeleportThing(cid, {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z - 1}, false)
        return true
    elseif(isInArray(ROPABLE, itemEx.itemid)) then
        local canOnlyRopePlayers = getBooleanFromString(getConfigValue('canOnlyRopePlayers'))
        local hole = getThingFromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z + 1, stackpos = STACKPOS_TOP_MOVEABLE_ITEM_OR_CREATURE})
        if(canOnlyRopePlayers) then
            if(isPlayer(hole.uid) and (not isPlayerGhost(hole.uid) or getPlayerGhostAccess(cid) >= getPlayerGhostAccess(hole.uid))) then
                doTeleportThing(hole.uid, {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z}, false)
            else
                doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
            end
        else
            if(hole.itemid > 0) then
                doTeleportThing(hole.uid, {x = toPosition.x, y = toPosition.y + 1, z = toPosition.z}, false)
            else
                doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
            end
        end

        return true
    end

    return false
end

TOOLS.PICK = function(cid, item, fromPosition, itemEx, toPosition)
    error(false)
    local ground = getThingFromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z + 1, stackpos = STACKPOS_GROUND})
    error(true)
    if(isInArray(SPOTS, ground.itemid) and isInArray({354, 355}, itemEx.itemid)) then
        doTransformItem(itemEx.uid, 392)
        doDecayItem(itemEx.uid)

        doSendMagicEffect(toPosition, CONST_ME_POFF)
        return true
    end

    if(itemEx.itemid == 7200) then
        doTransformItem(itemEx.uid, 7236)
        doSendMagicEffect(toPosition, CONST_ME_BLOCKHIT)
        return true
    end

    return false
end

TOOLS.MACHETE = function(cid, item, fromPosition, itemEx, toPosition, destroy)
    if(isInArray(JUNGLE_GRASS, itemEx.itemid)) then
        doTransformItem(itemEx.uid, itemEx.itemid - 1)
        doDecayItem(itemEx.uid)
        return true
    end

    if(isInArray(SPIDER_WEB, itemEx.itemid)) then
        if math.random(3) == 1 then
            doTransformItem(itemEx.uid, (itemEx.itemid + 6))
            doDecayItem(itemEx.uid)
        end
        doSendMagicEffect(toPosition, CONST_ME_POFF)
        return true
    end

    if(isInArray(BAMBOO_FENCE, itemEx.itemid)) then
        if math.random(3) == 1 then
            if(itemEx.itemid == BAMBOO_FENCE[1]) then
                doTransformItem(itemEx.uid, (itemEx.itemid + 161))
            elseif(itemEx.itemid == BAMBOO_FENCE[2]) then
                doTransformItem(itemEx.uid, (itemEx.itemid + 159))
            end
            doDecayItem(itemEx.uid)
        end
        doSendMagicEffect(toPosition, CONST_ME_POFF)
        return true
    end

    if(isInArray(WILD_GROWTH, itemEx.itemid)) then
        doSendMagicEffect(toPosition, CONST_ME_POFF)
        doRemoveItem(itemEx.uid)
        return true
    end

    return destroy and destroyItem(cid, itemEx, toPosition) or false
end

TOOLS.SHOVEL = function(cid, item, fromPosition, itemEx, toPosition)
    if(isInArray(HOLES, itemEx.itemid)) then
 
        local newId = itemEx.itemid + 1
 
        if(itemEx.itemid == 8579) then
            newId = 8585
        end
 
        doTransformItem(itemEx.uid, newId)
        doDecayItem(itemEx.uid)
    elseif(isInArray(SAND, itemEx.itemid)) then
 
        local rand = math.random(1, 100)
        local ground = getThingFromPos({x = toPosition.x, y = toPosition.y, z = toPosition.z + 1, stackpos = STACKPOS_GROUND})    
        if(isInArray(SPOTS, ground.itemid) and rand <= 20) then
            doTransformItem(itemEx.uid, 489)
            doDecayItem(itemEx.uid)
        elseif(rand >= 1 and rand <= 5) then
            doCreateItem(2159, 1, toPosition)
        elseif(rand > 85) then
            doCreateMonster("Scarab", toPosition, false)
        end
 
 
        doSendMagicEffect(toPosition, CONST_ME_POFF)
 
    end
 
 
    return true
end

TOOLS.SCYTHE = function(cid, item, fromPosition, itemEx, toPosition, destroy)
    if(itemEx.itemid == 2739) then
        doTransformItem(itemEx.uid, 2737)
        doCreateItem(2694, 1, toPosition)

        doDecayItem(itemEx.uid)
        return true
    end

    return destroy and destroyItem(cid, itemEx, toPosition) or false
end

TOOLS.KNIFE = function(cid, item, fromPosition, itemEx, toPosition)
    if(itemEx.itemid ~= PUMPKIN) then
        return false
    end

    doTransformItem(itemEx.uid, PUMPKIN_HEAD)
    return true
end

local config = {
    functions = {
        [10511] = { -- sneaky stabber of eliteness
            TOOLS.ROPE,
            TOOLS.SHOVEL,
            TOOLS.PICK,
            TOOLS.MACHETE,
            TOOLS.KNIFE
        },
        [10513] = { -- squeezing gear of girlpower
            TOOLS.ROPE,
            TOOLS.SHOVEL,
            TOOLS.PICK,
            TOOLS.MACHETE,
            TOOLS.SCYTHE
        },
        [10515] = { -- whacking driller of fate
            TOOLS.ROPE,
            TOOLS.SHOVEL,
            TOOLS.PICK,
            TOOLS.MACHETE,
            TOOLS.KNIFE
        }
    },
    jamChance = 10
}

function onUse(cid, item, fromPosition, itemEx, toPosition)
    local funcs = config.functions[item.itemid]
    if(funcs == nil) then
        return false
    end

    local result = false
    for _, func in ipairs(funcs) do
        if(func(cid, item, fromPosition, itemEx, toPosition)) then
            result = true
            break
        end
    end

    if(not result) then
        return false
    end

    if(math.random(1, 100) <= config.jamChance) then
        doTransformItem(item.uid, item.itemid + 1)
        doDecayItem(item.uid)
    end

    return true
end

 

 

agora da o seguinte erro .   Mais só da esse erro quando usa o item para corta ou abrir buracos ! 

 

[Errir- Action interface]

Data/actions/scripts/tools/squeeze.luua:onUse

description: 

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

Postado

O tópico foi movido para a área correta, preste mais atenção da próxima vez!

Leia as regras do fórum: http://tibiaking.com/forum/topic/1281-regras-gerais/?p=7680

Este tópico foi movido:

De: "OTServSuporte OTServSuporte de OTServ Geral"

Para: "OTServSuporte OTServSuporte de Scripts"

Atenciosamente,

Bruno Minervino

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.7k

Informação Importante

Confirmação de Termo