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

doCreatureFollowPlayer(cid, creature)

Joined
Apr 17, 2008
Messages
1,922
Solutions
1
Reaction score
188
Location
Venezuela
Hello, here i'm posting a function that i think is very ueful, creatures will follow you :)

Lua:
function doCreatureFollowPlayer(cid, creature)

	if isCreature(creature) == true then
		local cPos = getCreaturePosition(creature)
		local cidPos = getCreaturePosition(cid)
			if(cPos.y - cidPos.y) >= 2 then
				doMoveCreature(creature, NORTH)
			end
			if(cidPos.y - cPos.y) >= 2 then
				doMoveCreature(creature, SOUTH)
			end
			if(cPos.x - cidPos.x) >= 2 then
				doMoveCreature(creature, WEST)
			end
			if(cidPos.x - cPos.x) >= 2 then
				doMoveCreature(creature, EAST)
			end
		if(cidPos.z ~= cPos.z) then
			doTeleportThing(creature, cidPos)
		end
		addEvent(doCreatureFollowPlayer, 1, cid, creature)
	end
	return true
end

How to use? (Example)

Lua:
local monster = getThingFromPos(pos).uid
doCreatureFollowPlayer(cid, monster)
 
{x = cidPos.x, y = cidPos.y, z = cidPos.z}

ehh ??? why not just write cidPos
 
Back
Top