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

doRelocate returns nil value

kimokimo

Kimo
Joined
Jan 25, 2011
Messages
821
Solutions
6
Reaction score
156
GitHub
karimadnan
Code:
function onStepOut(cid, item, position, fromPosition)
    local tile = Tile(position)
    if tile:getCreatureCount() > 0 then
        return true
    end

    local newPosition = {x = position.x + 1, y = position.y, z = position.z}
    local query = Tile(newPosition):queryAdd(cid)
    if query ~= RETURNVALUE_NOERROR or query == RETURNVALUE_NOTENOUGHROOM then
        newPosition.x = newPosition.x - 1
        newPosition.y = newPosition.y + 1
        query = Tile(newPosition):queryAdd(cid)
    end
    if query == RETURNVALUE_NOERROR and query ~= RETURNVALUE_NOTENOUGHROOM then
        doRelocate(position, newPosition)
    end

    local i, tileItem, tileCount = 1, true, tile:getThingCount()
    while tileItem and i < tileCount do
        tileItem = tile:getThing(i)
        if tileItem and tileItem:getUniqueId() ~= item.uid and tileItem:getType():isMovable() then
            tileItem:remove()
        else
            i = i + 1
        end
    end

    Item(item.uid):transform(item.itemid - 1)
    return true
end

Lua Script Error: [MoveEvents Interface]
data/movements/scripts/closingdoor.lua:eek:nStepOut
data/movements/scripts/closingdoor.lua:8: attempt to call global 'doRelocate' (a nil value)
stack traceback:
[C]: in function 'doRelocate'
data/movements/scripts/closingdoor.lua:8: in function <data/movements/scripts/closingdoor.lua:1>
 
I tried to use it but throws a nill value error.

I don't know if variables should works as:

Code:
destino = {x = p.x, y = p.y-1, z = p.z}

Or

Code:
destino = {p.x,p.y-1,p.z}

A friend told me that it changed.

Also using as self:doRelocate(destino) but it isn't working.
 
This is the code

Code:
function Creature:onTargetCombat(target)
    if not self then
        return true
    end

    if self:isPlayer() and target:isPlayer() then
        if self:getStorageValue(_Lib_Battle_Info.TeamOne.storage) >= 1 and target:getStorageValue(_Lib_Battle_Info.TeamOne.storage) >= 1 or self:getStorageValue(_Lib_Battle_Info.TeamTwo.storage) >= 1 and target:getStorageValue(_Lib_Battle_Info.TeamTwo.storage) >= 1 then
            return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
        end
    end

    if target:isPlayer() then
        if self:isMonster() then
            local protectionStorage = target:getStorageValue(Storage.combatProtectionStorage)
           
            local p = self:getPosition()
            local destino = self:getPosition()
           
            if self:getDirection() == NORTH then
                --destino = SOUTH
                destino = {x = p.x, y = p.y-1, z = p.z}
            elseif self:getDirection() == EAST then
                --destino = WEST
                destino = {x = p.x+1, y = p.y, z = p.z}
            elseif self:getDirection() == WEST then
                --destino = EAST
                destino = {x = p.x-1, y = p.y, z = p.z}
            else
                --destino = NORTH
                destino = {x = p.x, y = p.y+1, z = p.z}
            end
           
                       
            if target:getIp() == 0 then -- If player is disconnected, monster shall ignore to attack the player   
           
                if protectionStorage <= 0 then
                    doteleportThing(self, destino)
                    --self:doRelocate(p, destino)
                    addEvent(removeCombatProtection, 30 * 1000, target.uid)
                    target:setStorageValue(Storage.combatProtectionStorage, 1)   
                elseif protectionStorage == 1 then
                    self:searchTarget()
                   
                    return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
                end

                return true
            end

            if protectionStorage >= os.time() then
                return RETURNVALUE_YOUMAYNOTATTACKTHISPLAYER
            end
        end
    end

    return true
end
 
Back
Top