Solved No SQM = Bug try summon

GOD Half

Intermediate OT User
Joined
May 9, 2010
Messages
177
Reaction score
13
Hi, someone help me set to not summon if don't have space next to the character?
 
Last edited:

Stigma

Veteran OT User
Joined
Feb 14, 2015
Messages
4,395
Reaction score
1,974
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
 
OP
GOD Half

GOD Half

Intermediate OT User
Joined
May 9, 2010
Messages
177
Reaction score
13
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.
 

Nekiro

worst coder
Support Team
Joined
Sep 7, 2015
Messages
1,768
Reaction score
538
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.
 
OP
GOD Half

GOD Half

Intermediate OT User
Joined
May 9, 2010
Messages
177
Reaction score
13
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:


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


Lua:
tile:getBottomCreature()
Thank's :rolleyes:
 
Last edited:
Top