Hello, here i'm posting a function that i think is very ueful, creatures will follow you
How to use? (Example)
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)