local soulRemoveSeconds = 60
local t = {
[1] = {from = XXX, to = XXX}, -- sorcerer
[2] = {from = XXX, to = XXX}, -- druid
[3] = {from = XXX, to = XXX}, -- paladin
[4] = {from = XXX, to = XXX} -- knight
}
local event = {}
local function removeSoul(uid)
local cid = getTopCreature(getThingPos(uid)).uid
if isPlayer(cid) then
doPlayerAddSoul(cid, -1)
local soul = getPlayerSoul(cid)
if isInArray({30,10,5}, soul) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'You ' .. (soul == 5 and 'only ' or '') .. 'have ' .. i .. ' minutes left of this training period.')
elseif soul == 1 then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_WARNING, 'You will be kicked in less than 1 minute.')
elseif soul == 0 then
event[uid] = nil
local pos, p = getPlayerMasterPos(cid), getThingPos(cid)
doSendMagicEffect(getThingPos(cid), CONST_ME_TELEPORT)
doTeleportThing(cid, pos)
doSendMagicEffect(pos, CONST_ME_TELEPORT)
return
end
event[uid] = addEvent(removeSoul, soulRemoveSeconds * 1000, uid)
else
event[uid] = nil
end
end
function onStepIn(cid, item, pos, fromPos)
if getPlayerSoul(cid) >= 15 then
local voc = getPlayerVocation(cid)
if voc > 4 then voc = voc - 4 end
local v = t[voc]
for i = v.from, v.to do
if not isPlayer(getTopCreature(getThingPos(i)).uid) then
if event[i] then
stopEvent(event[i])
end
doSendMagicEffect(pos, CONST_ME_TELEPORT)
doTeleportThing(cid, getThingPos(i))
doSendMagicEffect(getThingPos(i), CONST_ME_TELEPORT)
removeSoul(i)
return
end
end
doCreatureSay(cid, 'No training slots available!', TALKTYPE_ORANGE_1, false, cid)
else
doCreatureSay(cid, 'You need 15 soul points!', TALKTYPE_ORANGE_1, false, cid)
end
doTeleportThing(cid, fromPos)
doSendMagicEffect(fromPos, CONST_ME_TELEPORT)
end
local config = {
drainInterval = 1 * 60, --time in-between soul drains (seconds, 2 * 60 = 2 mins)
soulToDrain = -1, --how many soul points should be drained
minSoul = 1, --what soul should they be teleported back to temple be?
storageValue = 15000 --storage value to use
}
function onStepIn(cid, item, position, lastPosition, fromPosition, toPosition, actor)
return doPlayerSetStorageValue(cid, config.storageValue, os.time(t))
end
function onStepOut(cid, item, position, lastPosition, fromPosition, toPosition, actor)
return doPlayerSetStorageValue(cid, config.storageValue, -1)
end
function onThink(cid, interval)
local lastTime = getPlayerStorageValue(cid, config.storageValue)
if (lastTime ~= -1) then
if ((os.time(t) - lastTime) >= drainInterval) then
if (getPlayerSoul(cid) > config.minSoul) then
doPlayerSetStorageValue(cid, config.storageValue, os.time(t))
doPlayerAddSoul(cid, config.soulToDrain)
else
doPlayerSendCancel(cid, 'You don\'t have enough soul to stand there!')
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_POFF)
doTeleportThing(cid, getTownTemplePosition(getPlayerTown(cid)))
doSendMagicEffect(getCreaturePosition(cid), CONST_ME_TELEPORT)
doPlayerSetStorageValue(cid, config.storageValue, -1)
end
end
end
end
local t, event = {
drainInterval = 1 * 60,
minSoul = 1,
}, {}
local event = {}
local function removeSoul(cid)
if isPlayer(cid) then
doPlayerAddSoul(cid, -1)
if getPlayerSoul(cid) == t.minSoul then
event[cid] = nil
local pos, p = getPlayerMasterPos(cid), getThingPos(cid)
doTeleportThing(cid, pos)
doSendMagicEffect(p, CONST_ME_TELEPORT)
doSendMagicEffect(pos, CONST_ME_TELEPORT)
else
event[cid] = addEvent(removeSoul, t.drainInterval * 1000, cid)
end
else
event[cid] = nil
end
end
function onStepIn(cid, item, pos, fromPos)
if isPlayer(cid) then
removeSoul(cid)
end
end
local t = {
minSoul = 1
}
local function removeSoul(cid)
if isPlayer(cid) then
doPlayerAddSoul(cid, -1)
if getPlayerSoul(cid) == t.minSoul then
local pos, p = getPlayerMasterPos(cid), getThingPos(cid)
doTeleportThing(cid, pos)
doSendMagicEffect(p, CONST_ME_TELEPORT)
doSendMagicEffect(pos, CONST_ME_TELEPORT)
end
end
end
function onStepIn(cid, item, pos, fromPos)
if isPlayer(cid) then
removeSoul(cid)
end
end
local t, event = {
drainInterval = 1 * 60,
minSoul = 0,
}, {}
local event = {}
local function removeSoul(cid)
if isPlayer(cid) then
doPlayerAddSoul(cid, -1)
if getPlayerSoul(cid) == t.minSoul then
event[cid] = nil
local pos, p = getPlayerMasterPos(cid), getThingPos(cid)
doTeleportThing(cid, pos)
doPlayerSendCancel(cid, 'You don\'t have enough soul to stand there!')
doSendMagicEffect(p, CONST_ME_TELEPORT)
doSendMagicEffect(pos, CONST_ME_TELEPORT)
else
event[cid] = addEvent(removeSoul, t.drainInterval * 1000, cid)
end
else
event[cid] = nil
end
end
function onStepIn(cid, item, pos, fromPos)
if isPlayer(cid) then
removeSoul(cid)
end
end
doPlayerSendCancel(cid, 'You don\'t have enough soul to stand there!')
doCreatureSay(cid, 'You don\'t have enough soul to stand there!', TALKTYPE_ORANGE_1, false, cid)
function onStepIn(cid, item, pos, fromPos)
if isPlayer(cid) then
removeSoul(cid)
end
end
function onStepIn(cid, item, pos, fromPos)
if isPlayer(cid) then
removeSoul(cid)
doCreatureSay(cid, 'Your message here', TALKTYPE_ORANGE_1, false, cid)
end
end