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

Damage with interval when standing on a tile

  • Thread starter Thread starter Forsakenfate
  • Start date Start date
F

Forsakenfate

Guest
I'm looking for a function/script that does damage every 2 seconds on the player/monster standing on a certain tile.
I need the function to check the ID of the tile not the unique or action id.
For example when you trap someone, and cast one of these tiles under him, he will receive damage every 2 seconds.
So not on StepIn if that's possible.
Thanks for your time, rep for help.
 
Code:
	<movevent type="StepIn" itemid="trapid" event="script" value="trap.lua"/>
	<movevent type="StepOut" itemid="trapid" event="script" value="trap.lua"/>

LUA:
local condition = createConditionObject(CONDITION_INFIGHT)
setConditionParam(condition, CONDITION_PARAM_PERIODICDAMAGE, -20) -- damage
setConditionParam(condition, CONDITION_PARAM_TICKS, -1)
setConditionParam(condition, CONDITION_PARAM_TICKINTERVAL, 2000) -- time

function onStepIn(cid, item, position, fromPosition)
doAddCondition(cid, condition)
return true
end

function onStepOut(cid, item, position, fromPosition)
doRemoveCondition(cid, CONDITION_INFIGHT)
return true
end
 
Thanks for your quick reply, but it doesn't work.
No errors, just no damage when you walk on them.
Btw I'm using TFS 0.3.6.
 
LUA:
local storage = 55555
local max = 20
local min = 10

function onStepIn(cid, item, position, fromPosition)
if getPlayerStorageValue(cid, storage) <= 0 then
doPlayerSetStorageValue(cid, storage, 1)
local function damage(cid)
if isCreature(cid) and getPlayerStorageValue(cid, storage) >= 1 then
doTargetCombatHealth(0, cid, COMBAT_PHYSICALDAMAGE, -min, -max, CONST_ME_NONE)
addEvent(damage, 2000, cid)
end
end
damage(cid)
end
return true
end
 
function onStepOut(cid, item, position, fromPosition)
doPlayerSetStorageValue(cid, storage, 0)
return true
end

try it
 
Works good ^^ but damage doesn't stop it keeps damaging until the player dies and is it possible with interval instead of StepIn?
LUA:
local storage = 55555
local max = 20
local min = 10

function onStepIn(cid, item, position, fromPosition)
if getPlayerStorageValue(cid, storage) <= 0 then
doPlayerSetStorageValue(cid, storage, 1)
local function damage(cid)
if isCreature(cid) and getPlayerStorageValue(cid, storage) >= 1 then
doTargetCombatHealth(0, cid, COMBAT_PHYSICALDAMAGE, -min, -max, CONST_ME_NONE)
addEvent(damage, 2000, cid)
end
end
damage(cid)
end
return true
end
 
function onStepOut(cid, item, position, fromPosition)
doPlayerSetStorageValue(cid, storage, 0)
return true
end

try it

Same as Narko it works good but the damage doesn't stop until death and is it possible with an interval maybe? =]
 
Back
Top