• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

Lua TFS 1.5 7.72 Pick tools 354, 355

SalvaART

TriasOT.online
Joined
May 1, 2017
Messages
208
Solutions
1
Reaction score
123
Location
USA
Hello someone can explain me how to block 354, 355 id grounds ? If i set action id: 100 on RME then pick shut work, not every hole... And second problem is in code in chance to give money, small diamonds - its possible to delete everything ?

Lua:
local groundIds = {354, 355}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if target.itemid == 11227 then -- shiny stone refining
        local chance = math.random(1, 100)
        if chance == 1 then
            player:addItem(ITEM_CRYSTAL_COIN) -- 1% chance of getting crystal coin
        elseif chance <= 6 then
            player:addItem(ITEM_GOLD_COIN) -- 5% chance of getting gold coin
        elseif chance <= 51 then
            player:addItem(ITEM_PLATINUM_COIN) -- 45% chance of getting platinum coin
        else
            player:addItem(2145) -- 49% chance of getting small diamond
        end
        target:getPosition():sendMagicEffect(CONST_ME_BLOCKHIT)
        target:remove(1)
        return true
    end

    local tile = Tile(toPosition)
    if not tile then
        return false
    end

    local ground = tile:getGround()
    if not ground then
        return false
    end

    if (ground.uid > 65535 or ground.actionid == 0) and not table.contains(groundIds, ground.itemid) then
        return false
    end

    ground:transform(392)
    ground:decay()

    toPosition.z = toPosition.z + 1
    tile:relocateTo(toPosition)
    return true
end

Thank you for any help.
 
Solution
E
Lua:
local groundIds = {354, 355} -- pick usable ground

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local tile = Tile(toPosition)
    if not tile then
        return false
    end

    local ground = tile:getGround()
    if not ground then
        return false
    end

    if table.contains(groundIds, ground.itemid) and ground.actionid == 100 then
        ground:transform(392)
        ground:decay()
        toPosition:sendMagicEffect(CONST_ME_POFF)

        toPosition.z = toPosition.z + 1
        tile:relocateTo(toPosition)
        return true
    end

    return false
end

change 100 to whichever actionID you have on your map
Revscripts
data/scripts
Lua:
local config = {
    groundIds = {354, 355},
    pick = 11227 -- shiny stone refining
}

local Pick = Action()

function Pick.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local tile = Tile(toPosition)
    if not tile then
        return false
    end

    local ground = tile:getGround()
    if not ground then
        return false
    end


    if table.contains(config.groundIds, ground.itemid) and item.itemid == config.pick then
        player:sendTextMessage(MESSAGE_INFO_DESCR, "You cannot open this ground.")
        return false
    end

    ground:transform(392)
    ground:decay()

    toPosition.z = toPosition.z + 1
    tile:relocateTo(toPosition)
    return true
end

Pick:id(config.pick)
Pick:register()

or

Lua:
local config = {
    blockedGroundIds = {354, 355},
    pick = 2553 -- shiny stone refining
 
}

function isGroundBlocked(groundID)
    for _, id in ipairs(config.blockedGroundIds) do
        if id == groundID then
            return true
        end
    end
    return false
end

local Pick = Action()

function Pick.onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local ground = Tile(toPosition):getGround()
    if ground then
        if isGroundBlocked(ground.itemid) then
            player:sendTextMessage(MESSAGE_INFO_DESCR, "This land cannot be opened or modified.")
            return false
        elseif ground.uid > 65535 or ground.actionid == 0 then
            return false
        else
            ground:transform(392)
            ground:decay()

            toPosition.z = toPosition.z + 1
            Tile(toPosition):relocateTo(toPosition)
            return true
        end
    end

    return false
end

Pick:id(config.pick)
Pick:register()
 
Last edited:
Lua:
local groundIds = {354, 355} -- pick usable ground

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local tile = Tile(toPosition)
    if not tile then
        return false
    end

    local ground = tile:getGround()
    if not ground then
        return false
    end

    if table.contains(groundIds, ground.itemid) and ground.actionid == 100 then
        ground:transform(392)
        ground:decay()
        toPosition:sendMagicEffect(CONST_ME_POFF)

        toPosition.z = toPosition.z + 1
        tile:relocateTo(toPosition)
        return true
    end

    return false
end

change 100 to whichever actionID you have on your map
 
Solution
Thank you guys, all works!

I don't want make a new topic, can you help me with my last problem?

@Evil Puncker
@Mateus Robeerto

Really big +

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item:getActionId() == 105 then
        fromPosition.z = fromPosition.z + 1
        player:teleportTo(fromPosition, false)
        return true
    end
end

change 105 to the desired action id and add this action id to every draw well that you want to work like this
 
Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if item:getActionId() == 105 then
        fromPosition.z = fromPosition.z + 1
        player:teleportTo(fromPosition, false)
        return true
    end
end

change 105 to the desired action id and add this action id to every draw well that you want to work like this
all works, thanks boss have a good day!
 
Back
Top