• 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 Need Globalevents - Move Players

Nuckles

New Member
Joined
Mar 19, 2010
Messages
39
Reaction score
0
I need a globaleventes that move players within an area every 10 seconds. The movement is random between: left, right, up, down.

Does anyone have any idea how to do?

Thanks Cya.
 
You could try doing a math.rand(1,4) and then set 1 = turn left, 2 = turn right, etc. in the code, and do it something like, it triggers when they move, so they just have to move once then it moves them which triggers it to move them again, and again, and again. That might work.

And search through the doc folder in lua_functions for functions that you could use to make this script work, tomorrow I'll have more time and I could help you out more with it.
 
XML:
<globalevent name="randomMove" interval="5000" event="script" value="randomMove.lua"/>
Lua:
local area = {
	{x = 837, y = 964, z = 7},  -- top left position of area
	{x = 842, y = 967, z = 7}   -- bottom right position of area
}

function onThink(interval)
	for _, pid in pairs(getPlayersOnline()) do
		local pos = getThingPos(pid)
		if pos.x >= area[1].x and pos.x <= area[2].x and pos.y >= area[1].y and pos.y <= area[2].y and pos.z == area[1].z then
			doMoveCreature(pid, math.random(0, 3))
		end
	end
	return true
end
 
Back
Top