<globalevent name="petsummon" interval="100" event="script" value="summonpet.lua"/>
onThink(cid, interval)
local summons = getCreatureSummons(cid)
if(table.maxn(summons) >= 1) then
if getDistanceBetween(cid, summons) >= 5 then
for _, pid in ipairs(summons) do
doTeleportThing(cid, pid, true)
end
return false
end
return false
end
end
Thanks alot guys, im gonna try to put this all together and ill post it
LUA:<globalevent name="petsummon" interval="100" event="script" value="summonpet.lua"/> function onThink(cid, interval) local summons = getCreatureSummons(cid) if(table.maxn(summons) >= 1) then if getDistanceBetween(cid, summons) >= 5 then for _, pid in ipairs(summons) do doTeleportThing(cid, pid, true) end return false end return false end end
Hows this look
function onThink(interval, lastExecution)
for _, cid in ipairs(getPlayersOnline()) do
for _, pid in ipairs(getCreatureSummons(cid)) do
local summonPos, playerPos = getThingPos(pid), getThingPos(cid)
local thisPlayer, thisSummon = {x = summonPos.x + 5, y = summonsPos.y, z = summonPos.z}, {x = playerPos.x - 5, y = playerPos.y, z = playerPos.z}
if getDistanceBetween(thisPlayer, thisSummon) >= 5 then
doTeleportThing(pid, playerPos, true)
end
end
end
return true
end