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

help with Drowning condition

robertorb12

New Member
Joined
Jan 15, 2020
Messages
65
Reaction score
3
the drowning effect never disappears, need to log out to remove
im using tfs 1.3

i use this script: Drowning.lua in movements
Code:
local condition = Condition(CONDITION_DROWN)
condition:setParameter(CONDITION_PARAM_PERIODICDAMAGE, -20)
condition:setParameter(CONDITION_PARAM_TICKS, -1)
condition:setParameter(CONDITION_PARAM_TICKINTERVAL, 2000)

function onStepIn(creature, item, position, fromPosition)
    if creature:isPlayer() then
        if math.random(1, 10) == 1 then
            position:sendMagicEffect(CONST_ME_BUBBLES)
        end
        creature:addCondition(condition)
    end
    return true
end

function onStepOut(creature, item, position, fromPosition)
    if not creature:isPlayer() then
        creature:removeCondition(CONDITION_DROWN)
    end
    return true
end
please help
 
maybe you are leaving the underwater in a way that is not executing the stepOut event
 
Last edited by a moderator:
Code:
    <!-- Swimming -->
    <movevent event="StepIn" fromid="4620" toid="4625" script="others/swimming.lua" />
    <movevent event="StepOut" fromid="4620" toid="4625" script="others/swimming.lua" />
    <movevent event="StepIn" fromid="5406" toid="5410" script="others/drowning.lua"/>
    <movevent event="StepOut" fromid="5406" toid="5410" script="others/drowning.lua"/>
    <movevent event="StepIn" fromid="5743" toid="5744" script="others/drowning.lua"/>
    <movevent event="StepOut" fromid="5743" toid="5744" script="others/drowning.lua"/>
     <movevent event="StepIn" itemid="5764" script="others/drowning.lua"/>
    <movevent event="StepOut" itemid="5764" script="others/drowning.lua"/>
    <movevent event="StepIn" fromid="9671" toid="9673" script="others/drowning.lua"/>
    <movevent event="StepOut" fromid="9671" toid="9673" script="others/drowning.lua"/>
    <movevent event="StepIn" itemid="10019" script="others/drowning.lua"/>
    <movevent event="StepOut" itemid="10019" script="others/drowning.lua"/>
Post automatically merged:

tfs 1.3 or OTBR?
tfs 1.3 based on otbr
Post automatically merged:

Post how its added in your data\movements\movements.xml
Code:
    <!-- Swimming -->
    <movevent event="StepIn" fromid="4620" toid="4625" script="others/swimming.lua" />
    <movevent event="StepOut" fromid="4620" toid="4625" script="others/swimming.lua" />
    <movevent event="StepIn" fromid="5406" toid="5410" script="others/drowning.lua"/>
    <movevent event="StepOut" fromid="5406" toid="5410" script="others/drowning.lua"/>
    <movevent event="StepIn" fromid="5743" toid="5744" script="others/drowning.lua"/>
    <movevent event="StepOut" fromid="5743" toid="5744" script="others/drowning.lua"/>
     <movevent event="StepIn" itemid="5764" script="others/drowning.lua"/>
    <movevent event="StepOut" itemid="5764" script="others/drowning.lua"/>
    <movevent event="StepIn" fromid="9671" toid="9673" script="others/drowning.lua"/>
    <movevent event="StepOut" fromid="9671" toid="9673" script="others/drowning.lua"/>
    <movevent event="StepIn" itemid="10019" script="others/drowning.lua"/>
    <movevent event="StepOut" itemid="10019" script="others/drowning.lua"/>
 
Try this one

Lua:
local condition = Condition(CONDITION_DROWN)
condition:setParameter(CONDITION_PARAM_PERIODICDAMAGE, -20)
condition:setParameter(CONDITION_PARAM_TICKS, -1)
condition:setParameter(CONDITION_PARAM_TICKINTERVAL, 2000)

function onStepIn(creature, item, position, fromPosition)
    if creature:isPlayer() then
        if math.random(1, 10) == 1 then
            position:sendMagicEffect(CONST_ME_BUBBLES)
        end
        creature:addCondition(condition)
    end
    return true
end

function onStepOut(creature, item, position, fromPosition)
    if creature:isPlayer() then
        creature:removeCondition(CONDITION_DROWN)
    end
    return true
end
 
Last edited:
Try this one
Lua:
local condition = Condition(CONDITION_DROWN)
condition:setParameter(CONDITION_PARAM_PERIODICDAMAGE, -20)
condition:setParameter(CONDITION_PARAM_TICKS, -1)
condition:setParameter(CONDITION_PARAM_TICKINTERVAL, 2000)

function onStepIn(creature, item, position, fromPosition)
    if creature:isPlayer() then
        if math.random(1, 10) == 1 then
            position:sendMagicEffect(CONST_ME_BUBBLES)
        end
        creature:addCondition(condition)
    end
    return true
end

function onStepOut(creature, item, position, fromPosition)
    if creature:isPlayer() then
        creature:removeCondition(CONDITION_DROWN)
    end
    return true
end

still the same, when leaving the water continues with the drowning effect
 
Edited it try now and check if you get any console errors on Stepout.
 
Edited it try now and check if you get any console errors on Stepout.

Code:
Lua Script Error: [MoveEvents Interface]
data/movements/scripts/others/drowning.lua:onStepOut
data/movements/scripts/others/drowning.lua:17: attempt to index global 'player' (a nil value)
stack traceback:
        [C]: in function '__index'
        data/movements/scripts/others/drowning.lua:17: in function <data/movements/scripts/others/drowning.lua:16>


I got that error in console
 
What is your ground id for drowning? it is supposed to work I edited it retry.
 
Back
Top