local config = {
storage = 12681, -- storage
timeToRemoveMin = 8, -- minutes min
timeToRemoveMax = 15, -- minutes max
timeToResolve = 30 -- seconds
}
local event = 0
local event2 = 0
function onStepIn(cid, item, frompos, item2, topos)
timeToRemove = math.random(config.timeToRemoveMin, config.timeToRemoveMax)
doPlayerPopupFYI(cid, "Training moderator:\n\nYou now have ".. timeToRemove .." minutes to train without disturbance.\n\nYou are noted that botting is illegal.")
setPlayerStorageValue(cid, config.storage, 1)
event = addEvent(_doTeleportThing, timeToRemove * 60000, cid)
end
function onStepOut(cid, item, frompos, item2, topos)
if(getPlayerStorageValue(cid, config.storage) == 1) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_RED, "Your training session has ended.")
setPlayerStorageValue(cid, config.storage, -1)
stopEvent(event)
stopEvent(event2)
end
end
function _doTeleportThing(cid)
if(getPlayerStorageValue(cid, config.storage) == 1) then
doPlayerPopupFYI(cid, "Training moderator:\n\nStep off and on the tile to continue training.\nYou have ".. config.timeToResolve .." seconds to complete this request.")
event2 = addEvent(expireTime, config.timeToResolve * 1000, cid)
end
end
function expireTime(cid)
if(isPlayer(cid) == TRUE) then
setPlayerStorageValue(cid, config.storage, -1)
doTeleportThing(cid, getClosestFreeTile(cid, getTownTemplePosition(getPlayerTown(cid))))
doRemoveCreature(cid)
end
end