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

MoveEvent Training monk with Time!

Mooosie

- Lua Scripter -
Joined
Aug 2, 2008
Messages
702
Reaction score
27
Location
Sweden
I just made a training monk system with time train. So you are allowed to train in e.g 15 min and then you will be teleported to temple.

  • No ActionsIds
  • No UniqueIds
Just a single movement script, pretty easy to script:

data/movements/scripts/trM.lua:
Lua:
local timeT = 15 -- minutes
local s = 258 -- storagevalue

local function tPzola(cid) -- Mooosie
	doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
	return true
end
local function tPzolaa(cid) -- Mooosie
	setPlayerStorageValue(cid, s, -1)
	return true
end

function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) -- Mooosie
if isInRange(getCreaturePosition(cid), {x=864, y=1075, z=7}, {x=864, y=1075, z=7}) 
	or isInRange(getCreaturePosition(cid), {x=875, y=1075, z=7}, {x=875, y=1075, z=7}) then
	if getPlayerStorageValue(cid, s) == 1 then
		setPlayerStorageValue(cid, s, -1)
		doSendMagicEffect(getCreaturePosition(cid), 13)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You've just ended the training.")
		stopEvent(stoPeVentzalal)
		stopEvent(stoPeVentzalala)
	end
end
		
	if getPlayerStorageValue(cid, s) < 0 then
		if isInRange(getCreaturePosition(cid), {x=861, y=1076, z=7}, {x=861, y=1166, z=7})
			or isInRange(getCreaturePosition(cid), {x=868, y=1076, z=7}, {x=868, y=1166, z=7})
				or isInRange(getCreaturePosition(cid), {x=872, y=1076, z=7}, {x=872, y=1166, z=7}) 
					or isInRange(getCreaturePosition(cid), {x=879, y=1076, z=7}, {x=879, y=1166, z=7})
					-- FLOOR 2
						or isInRange(getCreaturePosition(cid), {x=861, y=1076, z=6}, {x=861, y=1166, z=6})
							or isInRange(getCreaturePosition(cid), {x=868, y=1076, z=6}, {x=868, y=1166, z=6})
								or isInRange(getCreaturePosition(cid), {x=872, y=1076, z=6}, {x=872, y=1166, z=6}) 
									or isInRange(getCreaturePosition(cid), {x=879, y=1076, z=6}, {x=879, y=1166, z=6})then
			doSendMagicEffect(getCreaturePosition(cid), 12)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have ".. timeT .." minutes on you to train. You will be teleported to temple when the times is up!")
			setPlayerStorageValue(cid, s, 1)
			stoPeVentzalal = addEvent(tPzola, timeT*60*1000, cid)
			stoPeVentzalala = addEvent(tPzolaa, timeT*60*1000, cid)
		end
	end
return true
end

function onStepOut(cid, item, position, fromPosition) -- Mooosie
	if isInRange(getCreaturePosition(cid), {x=862, y=1076, z=7}, {x=862, y=1166, z=7}) 
		or isInRange(getCreaturePosition(cid), {x=867, y=1076, z=7}, {x=867, y=1166, z=7})
			or isInRange(getCreaturePosition(cid), {x=873, y=1076, z=7}, {x=873, y=1166, z=7})
				or isInRange(getCreaturePosition(cid), {x=878, y=1076, z=7}, {x=878, y=1166, z=7}) 
					-- FLOOR 2
					or isInRange(getCreaturePosition(cid), {x=862, y=1076, z=6}, {x=862, y=1166, z=6}) 
						or isInRange(getCreaturePosition(cid), {x=867, y=1076, z=6}, {x=867, y=1166, z=6})
							or isInRange(getCreaturePosition(cid), {x=873, y=1076, z=6}, {x=873, y=1166, z=6})
								or isInRange(getCreaturePosition(cid), {x=878, y=1076, z=6}, {x=878, y=1166, z=6})then
		if getPlayerStorageValue(cid, s) == 1 then
			setPlayerStorageValue(cid, s, -1)
			doSendMagicEffect(getCreaturePosition(cid), 13)
			doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You've just ended the training.")
			stopEvent(stoPeVentzalal)
			stopEvent(stoPeVentzalala)
		end
	end
	return true
end

XML:
	<movevent type="StepIn" itemid="406" event="script" value="trM.lua" />
	<movevent type="StepOut" itemid="406" event="script" value="trM.lua" />
I think someone could do it with loops but I just copied and pasted.

CONFIG?
This:
Lua:
if getPlayerStorageValue(cid, s) < 0 then
if isInRange(getCreaturePosition(cid), {x=861, y=1076, z=7}, {x=861, y=1166, z=7})
is these positions [That is marked with red]:
datj.jpg

These are the positions were the players are stepping and gets the 15 minutes of training.

AND

This:
Lua:
function onStepOut(cid, item, position, fromPosition)
	if isInRange(getCreaturePosition(cid), {x=862, y=1076, z=7}, {x=862, y=1166, z=7})
is these positions [that is marked with black]:
dattm.jpg

These are the positions were the players are stepping and reseting the 15 minutes of training.

ALSO:
If you have training monk with a teleport inside the room. You have to mark the destination of the teleport in this line:
Lua:
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor) -- Mooosie
if isInRange(getCreaturePosition(cid), {x=864, y=1075, z=7}, {x=864, y=1075, z=7}) 
	or isInRange(getCreaturePosition(cid), {x=875, y=1075, z=7}, {x=875, y=1075, z=7}) then
	if getPlayerStorageValue(cid, s) == 1 then
		setPlayerStorageValue(cid, s, -1)
		doSendMagicEffect(getCreaturePosition(cid), 13)
		doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You've just ended the training.")
		stopEvent(stoPeVentzalal)
		stopEvent(stoPeVentzalala)
	end
end
dattt.jpg


That is my destination of the teleport inside the training room. [That is marked with black]

END OF CONFIG!

Enjoy!
 
Last edited:
no good :)
much better for example:

local positions = {{x=861, y=1076, z=7}, {x=861, y=1076, z=7}, {x=861, y=1076, z=7}, {x=861, y=1076, z=7}, {x=861, y=1076, z=7}........}
.
.
for _, pos in ipairs(positions) do
.
.
end
 
and much better with actionid/uniqueid -.-

It is faster with inRange... Too much to do with actionid/uniqueid...

no good
much better for example:

local positions = {{x=861, y=1076, z=7}, {x=861, y=1076, z=7}, {x=861, y=1076, z=7}, {x=861, y=1076, z=7}, {x=861, y=1076, z=7}........}
.
.
for _, pos in ipairs(positions) do
.
.
end

Yea, could do it, but i wanted to do it fast xd
 
Back
Top