botar pra cobrar item pra puxar alavanca

880123
Por 880123
em Scripts

880123

avatar
Campones
Campones

INFOS

Grupo: CamponesRegistrado: 03/05/21Posts: 33Gênero: Masculino

botar pra cobrar item ao puxar a alavanca
item: 2157 / quantidade 80

 

Citar

local config = {
    daily = "yes", -- allow only one enter per day? (like in global Tibia)
    level = 500,
    storage = 30015,
    entry =
    {
        {x = 319, y = 669, z = 7},
        {x = 319, y = 668, z = 7},
        {x = 319, y = 667, z = 7},
        {x = 319, y = 666, z = 7}
    },
    destination =
    {
        {x = 276, y = 653, z = 7},
        {x = 276, y = 653, z = 7},
        {x = 276, y = 653, z = 7},
        {x = 276, y = 653, z = 7}
    }
}

config.daily = getBooleanFromString(config.daily)
function onUse(cid, item, fromPosition, itemEx, toPosition)
    if(item.itemid == 1946) then
        if(config.daily) then
            doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
        else
            doTransformItem(item.uid, item.itemid - 1)
        end

        return true
    end

    if(item.itemid ~= 1945) then
        return true
    end

    local players = {}
    for _, position in ipairs(config.entry) do
        local pid = getTopCreature(position).uid
        if(pid == 0 or not isPlayer(pid) or getCreatureStorage(pid, config.storage) > 0 or getPlayerLevel(pid) < config.level) then
            doPlayerSendDefaultCancel(cid, RETURNVALUE_NOTPOSSIBLE)
            return true
        end

        table.insert(players, pid)
    end

    for i, pid in ipairs(players) do
        doSendMagicEffect(config.entry[i], CONST_ME_POFF)
        doTeleportThing(pid, config.destination[i], false)
        doSendMagicEffect(config.destination[i], CONST_ME_ENERGYAREA)
    end

    doTransformItem(item.uid, item.itemid + 1)
    return true
end