• 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!

TFS 1.X+ posSand shovel tfs 1.5

bpm91

Intermediate OT User
Joined
May 23, 2019
Messages
881
Solutions
7
Reaction score
122
Location
Brazil
YouTube
caruniawikibr
Does anyone know why the script works but this error appears in tfs?

Lua:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    local tile = Tile(toPosition)
    if not tile then
        return false
    end
  
    if table.contains({468, 481, 483}, target.itemid) then
        target:transform(target.itemid + 1)
        target:decay()
    elseif target.itemid == 231 then
        local randomValue = math.random(1, 100)
        if target.actionid == 100 and randomValue <= 25 then
            target:transform(489)
            target:decay()
        elseif randomValue <= 3 and player:getPosition():isInRange(posSand.fromPos, posSand.toPos) then
            Game.createItem(2159, 1, toPosition)
        elseif randomValue > 98 and player:getPosition():isInRange(posSand.fromPos, posSand.toPos) then
            Game.createMonster("Scarab", toPosition)

        end
        toPosition:sendMagicEffect(CONST_ME_POFF)
    elseif target.itemid == 5581 then
        toPosition:sendMagicEffect(CONST_ME_POFF)
    else
        return false
    end

    return true
end


Screenshot_2.png
 
posSand is not defined. Thats all,
Lua:
        elseif randomValue <= 3 and player:getPosition():isInRange(posSand.fromPos, posSand.toPos) then
            Game.createItem(2159, 1, toPosition)
        elseif randomValue > 98 and player:getPosition():isInRange(posSand.fromPos, posSand.toPos) then
            Game.createMonster("Scarab", toPosition)
this part wont work since posSand return nil.
 
Has @Dakos said, to fix the posSand error, you will need to define posSand somewhere in your code. The posSand variable is used in the onUse function to check if the player is in range of a specific area.
 
It's not about removing this check, I found similar script here:

You need to define posSand:
Lua:
local posSand = {
    fromPos = Position(33018, 32894, 7),
    toPos = Position(33306, 32530, 7)
}
 
Back
Top