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

Lua TFS 1.2 Removing conditions

S

Shadow_

Guest
Hello Developers,
i was trying to add a new script in creature scripts to remove some conditions when you enter pz like :( poison-bleeding-cursed-fire-energy-drunk-paralyze-hunting)
i tried too many scripts ( all the scripts in otland didn't work or me idk why )
 
Solution
creaturescript.xml
Code:
<event type="think" name="Removeconditions" script="Removeconditions.lua" />
Lua:
local conditions = {CONDITION_POISON,
                    CONDITION_FIRE,
                    CONDITION_ENERGY,
                    CONDITION_PARALYZE,
                    CONDITION_DRUNK,
                    CONDITION_DROWN,
                    CONDITION_FREEZING,
                    CONDITION_DAZZLED,
                    CONDITION_CURSED
                }

function onThink(player, interval)
local tile = Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE)
    if tile then
        for _, condition in ipairs(conditions) do
            if(player:getCondition(condition)) then
                player:removeCondition(condition)...
Lua:
local removeConditions = {
    CONDITION_POISON,
    CONDITION_FIRE,
    CONDITION_ENERGY,
    CONDITION_BLEEDING,
    CONDITION_PARALYZE,
    CONDITION_DRUNK,
    CONDITION_EXHAUST_WEAPON,
    CONDITION_EXHAUST,
    CONDITION_EXHAUSTED,
    CONDITION_DROWN,
    CONDITION_FREEZING,
    CONDITION_DAZZLED,
    CONDITION_CURSED,
    CONDITION_EXHAUST_COMBAT,
    CONDITION_EXHAUST_HEAL,
    CONDITION_SPELLCOOLDOWN,
    CONDITION_SPELLGROUPCOOLDOWN,
}

function <YOURFUNCTION>
     for i = 1, #removeConditions do
          if(getCreatureCondition(player, removeConditions[i]) == true) then
                 doRemoveCondition(player, removeConditions[i])
          end
    end
    return true
end
 
creaturescript.xml
Code:
<event type="think" name="Removeconditions" script="Removeconditions.lua" />
Lua:
local conditions = {CONDITION_POISON,
                    CONDITION_FIRE,
                    CONDITION_ENERGY,
                    CONDITION_PARALYZE,
                    CONDITION_DRUNK,
                    CONDITION_DROWN,
                    CONDITION_FREEZING,
                    CONDITION_DAZZLED,
                    CONDITION_CURSED
                }

function onThink(player, interval)
local tile = Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE)
    if tile then
        for _, condition in ipairs(conditions) do
            if(player:getCondition(condition)) then
                player:removeCondition(condition)
            end
        end   
    end
end
 
Solution
creaturescript.xml
Code:
<event type="think" name="Removeconditions" script="Removeconditions.lua" />
Lua:
local conditions = {CONDITION_POISON,
                    CONDITION_FIRE,
                    CONDITION_ENERGY,
                    CONDITION_PARALYZE,
                    CONDITION_DRUNK,
                    CONDITION_DROWN,
                    CONDITION_FREEZING,
                    CONDITION_DAZZLED,
                    CONDITION_CURSED
                }

function onThink(player, interval)
local tile = Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE)
    if tile then
        for _, condition in ipairs(conditions) do
            if(player:getCondition(condition)) then
                player:removeCondition(condition)
            end
        end  
    end
end
There’s actually no need to call player:getCondition here, as player:removeCondition will do that check anyway.
 
creaturescript.xml
Code:
<event type="think" name="Removeconditions" script="Removeconditions.lua" />
Lua:
local conditions = {CONDITION_POISON,
                    CONDITION_FIRE,
                    CONDITION_ENERGY,
                    CONDITION_PARALYZE,
                    CONDITION_DRUNK,
                    CONDITION_DROWN,
                    CONDITION_FREEZING,
                    CONDITION_DAZZLED,
                    CONDITION_CURSED
                }

function onThink(player, interval)
local tile = Tile(player:getPosition()):hasFlag(TILESTATE_PROTECTIONZONE)
    if tile then
        for _, condition in ipairs(conditions) do
            if(player:getCondition(condition)) then
                player:removeCondition(condition)
            end
        end  
    end
end
Thank you worked perfectly !
 
Back
Top