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

[Help] DoTeleportThing(getCreatureSummons(cid))

Omen

New Member
Joined
Sep 11, 2008
Messages
70
Reaction score
0
Does this work? how can I make it work at a certain range?

I DO NOT WANT TO USE THE CONFIG.LUA METHOD

Thanks :D
 
hmm...
I see two ways:

1. Use circular addEvent, that start, when you summon creature (then look for code)
2. Use globalevents onThink() and use similar code

You need this functions:
isPlayer --- is online?, for addEvent
getCreatureSummons(cid) --- return false or table (table can be empty!)
getDistanceBetween(playerPos, summonPos)
doTeleportThing(cid, newpos[, pushmove = true])
 
getDistanceBetween(playerPos, summonPos)

this exists? that just about solves everything..

ok I found it in the readme >_> but im not too good with addevent, could you help me get started?
 
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"/>


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
 
Last edited:
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

Don't forget function
 
Code:
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
 
This looks perfect O_O im gonna try it, if it works ill rep ofc not that you seem to need more :D

Edit: How do I make this check for z ups and downs too?
 
Back
Top