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

Solved No SQM = Bug try summon

GOD Half

Member
Joined
May 9, 2010
Messages
179
Reaction score
15
Hi, someone help me set to not summon if don't have space next to the character?
 
Last edited:
Solution
Code:
function getFreePosition(position)
    local positions = {
        -- 1, 2, 3
        -- 4, 0, 5 -- 0 is player
        -- 6, 7, 8
        Position(position.x - 1, position.y - 1, position.z), -- 1
        Position(position.x, position.y - 1, position.z), -- 2
        Position(position.x + 1, position.y - 1, position.z), -- 3
      
        Position(position.x - 1, position.y, position.z), -- 4
        -- Position(position.x, position.y, position.z), 0 -> player
        Position(position.x + 1, position.y, position.z), -- 5
      
        Position(position.x - 1, position.y + 1, position.z) -- 6
        Position(position.x, position.y + 1, position.z), -- 7
        Position(position.x + 1, position.y + 1, position.z), -- 8
    }...
Rules for the Support board
5. Incomplete Problem Description:
- Post as much useful information as possible. If the problem is about something on your server, post the server version and client version. Also always post the errors you get and the scripts with the problems.

the video itself is not enough, post the exact server version you're using and the summon script you're using
 
Rules for the Support board


the video itself is not enough, post the exact server version you're using and the summon script you're using
TFS 1.3

Script to summon:
Lua:
local configId = {
    [1] = {26382}
}

function onThink(interval, lastExecution, thinkInterval)
    for _, name in ipairs(getOnlinePlayers()) do
    local pid = getPlayerByName(name)
    local pos = getPlayerPosition(pid)
        for _, i in pairs(configId) do
            if type(i) == 'table' then
                if isInArray(i, getPlayerSlotItem(pid, CONST_SLOT_AMMO).itemid) and (getTilePzInfo(getCreaturePosition(pid)) == false) and (#getCreatureSummons(pid) == 0) then
                local NomePet = getItemName(i[1])
                local PetName = doSummonCreature(NomePet, getThingPos(pid))
                    doConvinceCreature(pid, PetName)
                    doSendMagicEffect(getThingPos(pid), 13)
                elseif isInArray(i, getPlayerSlotItem(pid, CONST_SLOT_AMMO).itemid) and (getTilePzInfo(getCreaturePosition(pid)) == true) and (#getCreatureSummons(pid) >= 1) then
                doPlayerSendCancel(pid, "This summon is not permitted in a protection zone.")
                local pet = getCreatureSummons(pid)
                    for _, k in ipairs(pet) do
                        doSendMagicEffect(getThingPos(k), 13)
                        doRemoveCreature(k)
                    return true
                    end
                elseif (isInArray(i, getPlayerSlotItem(pid, CONST_SLOT_AMMO).itemid) == false) and (#getCreatureSummons(pid) >= 1) then
                    local pet = getCreatureSummons(pid)
                    for _, k in ipairs(pet) do
                        doSendMagicEffect(getThingPos(k), 13)
                        doRemoveCreature(k)
                    return true
                    end
                end
            end
        end
    end
return true
end

I'm trying something like:
Lua:
                local position = getClosestFreeTile(cid, getCreaturePosition(NomePet), true, false)
                if position.x == 0 then
                    doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Destination not reachable.")
                    return true
                end

But getClosestFreeTile don't work idk why.
 
Code:
function getFreePosition(position)
    local positions = {
        -- 1, 2, 3
        -- 4, 0, 5 -- 0 is player
        -- 6, 7, 8
        Position(position.x - 1, position.y - 1, position.z), -- 1
        Position(position.x, position.y - 1, position.z), -- 2
        Position(position.x + 1, position.y - 1, position.z), -- 3
      
        Position(position.x - 1, position.y, position.z), -- 4
        -- Position(position.x, position.y, position.z), 0 -> player
        Position(position.x + 1, position.y, position.z), -- 5
      
        Position(position.x - 1, position.y + 1, position.z) -- 6
        Position(position.x, position.y + 1, position.z), -- 7
        Position(position.x + 1, position.y + 1, position.z), -- 8
    }
 
    for _, pos in pairs(positions) do
        local tile = Tile(pos)
        if tile and tile:getGround() and not tile:getHouse() and not tile:hasFlag(TILESTATE_PROTECTIONZONE) and not tile:hasFlag(TILESTATE_BLOCKSOLID) then
            return pos
        end
    end
    return nil
end

I didnt test that.
 
Solution
Code:
function getFreePosition(position)
    local positions = {
        -- 1, 2, 3
        -- 4, 0, 5 -- 0 is player
        -- 6, 7, 8
        Position(position.x - 1, position.y - 1, position.z), -- 1
        Position(position.x, position.y - 1, position.z), -- 2
        Position(position.x + 1, position.y - 1, position.z), -- 3
  
        Position(position.x - 1, position.y, position.z), -- 4
        -- Position(position.x, position.y, position.z), 0 -> player
        Position(position.x + 1, position.y, position.z), -- 5
  
        Position(position.x - 1, position.y + 1, position.z) -- 6
        Position(position.x, position.y + 1, position.z), -- 7
        Position(position.x + 1, position.y + 1, position.z), -- 8
    }
 
    for _, pos in pairs(positions) do
        local tile = Tile(pos)
        if tile and tile:getGround() and not tile:getHouse() and not tile:hasFlag(TILESTATE_PROTECTIONZONE) and not tile:hasFlag(TILESTATE_BLOCKSOLID) then
            return pos
        end
    end
    return nil
end

I didnt test that.

@Nekiro works very well:
5D1HpT8kQ0q3aroGoPREKA.jpeg


But I needed to set something to don't make it happen the error below:
PaDWasScRxyoapRq1_i8lg.jpeg


Lua:
tile:getBottomCreature()

Thank's :rolleyes:
 
Last edited:
Back
Top