• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

globalevent script

kito2

www.masteria.net
Joined
Mar 9, 2009
Messages
3,764
Solutions
1
Reaction score
227
Location
Chile, Santiago
Hello, I need a script that works on a interval defined on the .xml... The idea of the script is to move the player between 8 possible position, choosed in a random way... Can anyone help me on this?

I made this script:

LUA:
function onThink(pid, interval)
	local specificFloor = {x = 49, y = 24, z = 6}
	local z = getTopCreature(specificFloor).uid
		if isPlayer(z) then
			doTeleportThing(z, getTownTemplePosition(getPlayerTown(z)))
			doSendMagicEffect(getThingPos(z), 12)
		end
	return true
end

I don't know how to make it randomly and use a table with positions.
 
math.random(positions)
-->
Code:
lala = {{x=1,y=2,z=5},{x=7,y=3,z=8}}
tp = math.random(1, #lala)
doTeleportThing(cid,tp)
or
Code:
t_x = math.random(232,323)
t_y = math.random(12121,12122131)
t_z= 5
doTeleportThing(cid,{x=t_x, y=t_y, z=z_y})
 
Thanks guys!
Finally made this one, it will move the player from one sqm to the other 8 sqms around.

LUA:
function onThink(pid, interval)
	
	local posx = 46 
	local posy = 56
	local posz = 5
	local square1 = 
	{
	{x=posx-1,y=posy-1,z=posz},
	{x=posx,y=posy-1,z=posz},
	{x=posx+1,y=posy-1,z=posz},
	{x=posx+1,y=posy,z=posz},
	{x=posx-1,y=posy,z=posz},
	{x=posx-1,y=posy+1,z=posz},
	{x=posx,y=posy+1,z=posz},
	{x=posx+1,y=posy+1,z=posz}
	}
	local tp = square1[math.random(1, #square1)]
	
	local specificFloor = {x = posx, y = posy, z = posz}
	local z = getTopCreature(specificFloor).uid
		if isPlayer(z) then
			doTeleportThing(z, tp)
			doSendMagicEffect(getThingPos(z), 12)
		end
	return true
end
 
Back
Top