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

removing items from area

Verrine

Member
Joined
Mar 2, 2016
Messages
117
Reaction score
7
Hi
I wrote in my old thread about that but it should be better to make another.
I need function that clean area I defined.
I have smth like this:
Code:
function doAreaClean(frompos, topos)
local Tile
local item = Tile(position):getItemById(itemid)

for x = frompos.x, topos.x do
    for y = frompos.y, topos.y do
        for z = frompos.z, topos.z do
    local p = {x=x,y=y,z=z}
     if isCleanAbleArea(p) then
     if item then

        item:remove()

        end
    end
        end
      end
   end
   end
but it does not work ;<
Can someone tell me whats wrong, how to fix that or just give me any advices ? Im not good at this jet but Im trying all the time. Im just bored to reset all the time server to check that function (got this in libs so I cant just reload them)
 
Code:
Lua Script Error: [TalkAction Interface]
data/talkactions/scripts/czysc.lua:onSay
data/talkactions/scripts/czysc.lua:14: attempt to call global 'item' (a nil value)
stack traceback:
        [C]: in function 'item'
        data/talkactions/scripts/czysc.lua:14: in function 'doAreaClean'
        data/talkactions/scripts/czysc.lua:4: in function <data/talkactions/scripts/czysc.lua:1>
 
Code:
local c = {
position = {from = {x=31994, y=32446, z=7}, to = {x=31989, y=32444, z=7}},
}
function onSay(cid, words, param)

    if words == "!cleanxx" then

        doAreaClean(c.position.from, c.position.to)

       
    else
    return false
    end
end

function doAreaClean(frompos, topos)

for x = frompos.x, topos.x do
    for y = frompos.y, topos.y do
        for z = frompos.z, topos.z do
            local p = {x=x,y=y,z=z}
            if isCleanAbleArea(p) then

            remove()

        end
    end
        end
      end
   end

with this code I have no errors :/
 
Code:
ua Script Error: [TalkAction Interface]
data/talkactions/scripts/czysc.lua:onSay
data/talkactions/scripts/czysc.lua:16: attempt to index field 'topos' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/talkactions/scripts/czysc.lua:16: in function <data/talkactions/scripts/czysc.lua:14>

changed to
PHP:
local p = {
    from = {x=31994, y=32446, z=7},
    to = {x=31989, y=32444, z=7}
}

function isCleanAbleArea(pos)
    pos.stackpos = 0
    local tile = getThingfromPos(pos, false)
    if tile ~= 0 and not hasProperty(tile.uid, CONST_PROP_BLOCKSOLID) and not isCreature(getTopCreature(pos).uid) then
        return true
    end
end

function onSay(cid, words, param)
    if words == "!cleanxx" then
    for x = p.from.x, p.to.x do
        for y = p.from.y, p.to.y do
            for z = p.from.z, p.to.z do
                local c = {x = x, y = y, z = z}
                if isCleanAbleArea(c) then
                    doCleanTile(c, false)
                end
            end
        end
    end
    end
    return true

end

and no errors and no cleaning
 
change topos -> to in that line
done, edited my post, no errors ;/ and does not cleaning area

omm now it evend does not want to execute

edit 2
nah it just does not clean anything ;/

Code:
    for x = p.from.x, p.to.x do
    cid:sendTextMessage(MESSAGE_STATUS_CONSOLE_BLUE, cid:getName() .. ' look' .. p.from.x .. ' and ' .. p.to.x)
        for y = p.from.y, p.to.y do

when I did this no message appeared, before for it was ok
seems that for does not work
 
Last edited:
Back
Top