Solved No SQM = Bug try summon

Discussion in 'Support' started by GOD Half, Jun 25, 2018.

Tags:
  1. GOD Half

    GOD Half Member

    Joined:
    May 9, 2010
    Messages:
    177
    Likes Received:
    12
    Best Answers:
    0
    Hi, someone help me set to not summon if don't have space next to the character?
     
    Last edited: Jun 25, 2018
  2. Best Answer:
    Post #4 by Nekiro, Jun 25, 2018
  3. Vulcan_

    Vulcan_ Support Team Support Team

    Joined:
    Feb 14, 2015
    Messages:
    4,038
    Likes Received:
    1,850
    Best Answers:
    316
    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
     
  4. GOD Half

    GOD Half Member

    Joined:
    May 9, 2010
    Messages:
    177
    Likes Received:
    12
    Best Answers:
    0
    TFS 1.3

    Script to summon:
    Code (Lua):
    1. local configId = {
    2.     [1] = {26382}
    3. }
    4.  
    5. function onThink(interval, lastExecution, thinkInterval)
    6.     for _, name in ipairs(getOnlinePlayers()) do
    7.     local pid = getPlayerByName(name)
    8.     local pos = getPlayerPosition(pid)
    9.         for _, i in pairs(configId) do
    10.             if type(i) == 'table' then
    11.                 if isInArray(i, getPlayerSlotItem(pid, CONST_SLOT_AMMO).itemid) and (getTilePzInfo(getCreaturePosition(pid)) == false) and (#getCreatureSummons(pid) == 0) then
    12.                 local NomePet = getItemName(i[1])
    13.                 local PetName = doSummonCreature(NomePet, getThingPos(pid))
    14.                     doConvinceCreature(pid, PetName)
    15.                     doSendMagicEffect(getThingPos(pid), 13)
    16.                 elseif isInArray(i, getPlayerSlotItem(pid, CONST_SLOT_AMMO).itemid) and (getTilePzInfo(getCreaturePosition(pid)) == true) and (#getCreatureSummons(pid) >= 1) then
    17.                 doPlayerSendCancel(pid, "This summon is not permitted in a protection zone.")
    18.                 local pet = getCreatureSummons(pid)
    19.                     for _, k in ipairs(pet) do
    20.                         doSendMagicEffect(getThingPos(k), 13)
    21.                         doRemoveCreature(k)
    22.                     return true
    23.                     end
    24.                 elseif (isInArray(i, getPlayerSlotItem(pid, CONST_SLOT_AMMO).itemid) == false) and (#getCreatureSummons(pid) >= 1) then
    25.                     local pet = getCreatureSummons(pid)
    26.                     for _, k in ipairs(pet) do
    27.                         doSendMagicEffect(getThingPos(k), 13)
    28.                         doRemoveCreature(k)
    29.                     return true
    30.                     end
    31.                 end
    32.             end
    33.         end
    34.     end
    35. return true
    36. end
    I'm trying something like:
    Code (Lua):
    1.                 local position = getClosestFreeTile(cid, getCreaturePosition(NomePet), true, false)
    2.                 if position.x == 0 then
    3.                     doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Destination not reachable.")
    4.                     return true
    5.                 end
    But getClosestFreeTile don't work idk why.
     
  5. Nekiro

    Nekiro worst coder Support Team

    Joined:
    Sep 7, 2015
    Messages:
    1,695
    Likes Received:
    522
    Best Answers:
    69
    Best Answer
    Code (Text):
    1. function getFreePosition(position)
    2.     local positions = {
    3.         -- 1, 2, 3
    4.         -- 4, 0, 5 -- 0 is player
    5.         -- 6, 7, 8
    6.         Position(position.x - 1, position.y - 1, position.z), -- 1
    7.         Position(position.x, position.y - 1, position.z), -- 2
    8.         Position(position.x + 1, position.y - 1, position.z), -- 3
    9.      
    10.         Position(position.x - 1, position.y, position.z), -- 4
    11.         -- Position(position.x, position.y, position.z), 0 -> player
    12.         Position(position.x + 1, position.y, position.z), -- 5
    13.      
    14.         Position(position.x - 1, position.y + 1, position.z) -- 6
    15.         Position(position.x, position.y + 1, position.z), -- 7
    16.         Position(position.x + 1, position.y + 1, position.z), -- 8
    17.     }
    18.  
    19.     for _, pos in pairs(positions) do
    20.         local tile = Tile(pos)
    21.         if tile and tile:getGround() and not tile:getHouse() and not tile:hasFlag(TILESTATE_PROTECTIONZONE) and not tile:hasFlag(TILESTATE_BLOCKSOLID) then
    22.             return pos
    23.         end
    24.     end
    25.     return nil
    26. end
    I didnt test that.
     
    GOD Half likes this.
  6. GOD Half

    GOD Half Member

    Joined:
    May 9, 2010
    Messages:
    177
    Likes Received:
    12
    Best Answers:
    0
    @Nekiro works very well:
    [​IMG]

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

    Code (Lua):
    1. tile:getBottomCreature()
    Thank's :rolleyes:
     
    Last edited: Jun 25, 2018

Share This Page

Loading...