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

Lua Monsters Provocation

Ok I Found function by Cykotitan:
PHP:
function getPlayersInRange(position, radiusx, radiusy)
	local creaturesList = {}
	for x = -radiusx, radiusx do
		for y = -radiusy, radiusy do
			if not (x == 0 and y == 0) then
				local creature = getTopCreature({x = position.x+x, y = position.y+y, z = position.z})
				if creature.type == 1 then
					table.insert(creaturesList, creature.uid)
				end
			end
		end
	end

	local creature = getTopCreature(position)
	if creature.type == 1 then
		if not(table.find(creaturesList, creature.uid)) then
			table.insert(creaturesList, creature.uid)
		end
	end
    return creaturesList
end

You use it like that:
PHP:
getPlayersInRange({x=123, y=123, z=1}, 5, 5)
Where x y z are your pos and 5 is x range and next 5 is y range



@Edit
Now i know what do u mean, wait a sec.

Create new group (like normal players) with PlayerFlag_CannotBeAttacked
Then use function above and when monster is in range it will hit you but when it isn't it wont
Use storage that changes all the time(delete, create), when its not in your range function will change your group, and when its in range it will change back to normal.

I won't make that, its 12:00pm ;D
 
Last edited:
Back
Top