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

[LUA] Soul Drain Tile!

Sweddy

Well-Known Member
Joined
Feb 14, 2009
Messages
2,907
Reaction score
93
Location
Sweden
I want a Soul Drain Tile That Drains x Soul each x min on a specific action id tile.

If the guy dont got more than x soul he get teleported to temple. Thanks :)
 
Here's something I made long ago, but I made it for trainers so I had to use uids not actionids
LUA:
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
You didn't want it for trainers?
 
Last edited:
Well, Yea. But i want one for everything :P heres a sample Icy made but didnt work:

LUA:
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
 
LUA:
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
Its a movement
 
When the player step on the tile then one soul goes down and if he stay there 1 soul go own each 1 minute but after that he will get teleported when he got 0 soul, but if he have 1 soul and stays on the tile he can stay there forever :S. I need to make a message appear when he step on the tile and ect..
 
Last edited:
Try this:
LUA:
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
 
well, this one is working now:
LUA:
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
but i want that message appear in the middle of screen. and i want a message to be when on stepin.
 
s/
LUA:
doPlayerSendCancel(cid, 'You don\'t have enough soul to stand there!')
/
LUA:
doCreatureSay(cid, 'You don\'t have enough soul to stand there!', TALKTYPE_ORANGE_1, false, cid)
&& s/
LUA:
function onStepIn(cid, item, pos, fromPos)
	if isPlayer(cid) then
		removeSoul(cid)
	end
end
/
LUA:
function onStepIn(cid, item, pos, fromPos)
	if isPlayer(cid) then
		removeSoul(cid)
		doCreatureSay(cid, 'Your message here', TALKTYPE_ORANGE_1, false, cid)
	end
end
 
Back
Top