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
}...
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.
TFS 1.3Rules 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
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
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
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
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.
tile:getBottomCreature()