• 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 onThink (condition) remover

darkmu

Active Member
Joined
Aug 26, 2007
Messages
253
Solutions
1
Reaction score
45
Location
Paraná,Brazil
What is happening is that it is not removing the conditions that I had in the player.

It also happened that, some players started to take paralyze while in a protected zone or also when taking paralyze for a hydra bug .. your speed got to bugar and get 40 speed, can someone help me?

TFS 1.3

Lua:
local condition = Condition(CONDITION_ATTRIBUTES)
      condition:setParameter(CONDITION_PARAM_SUBID, 20)
      condition:setParameter(CONDITION_PARAM_TICKS, -1)
      condition:setParameter(CONDITION_PARAM_SKILL_CRITICAL_HIT_CHANCE, 15)
      condition:setParameter(CONDITION_PARAM_SKILL_CRITICAL_HIT_DAMAGE, 15)
      condition:setParameter(CONDITION_PARAM_SKILL_LIFE_LEECH_CHANCE, 100)
      condition:setParameter(CONDITION_PARAM_SKILL_LIFE_LEECH_AMOUNT, 25)
      condition:setParameter(CONDITION_PARAM_SKILL_MANA_LEECH_CHANCE, 100)
      condition:setParameter(CONDITION_PARAM_SKILL_MANA_LEECH_AMOUNT, 25)     

function onThink(creature, interval)
    local player = Player(creature)
    
    if not player then
        return false
    end
    
    delay = player:getStorageValue(15869)
    
    if delay >= 8000 and player:getStorageValue(15866) >= os.time() then
        player:getPosition():sendMagicEffect(CONST_ME_CRITICAL_DAMAGE)
        player:say("BUFF Veteranos", TALKTYPE_MONSTER_SAY)
        player:setStorageValue(15869, interval)   
    else
        player:setStorageValue(15869, delay + interval)   
    end

    if player:getStorageValue(15866) >= os.time() then       
        player:addCondition(condition)
    end
    
    if player:getStorageValue(15866) <= os.time() and player:getStorageValue(15867) > 0 then   
        player:removeCondition(CONDITION_ATTRIBUTES, 20)
    end
    
    return true
end
 

Snavy

Bakasta
Senator
Joined
Apr 1, 2012
Messages
1,247
Solutions
71
Reaction score
587
Location
Hell
What are you trying to do?

What are these storages for?
15869, 15866, 15867

This part keeps increasing "delay storage" value.
Lua:
    delay = player:getStorageValue(15869)
    
    if delay >= 8000 and player:getStorageValue(15866) >= os.time() then
        player:getPosition():sendMagicEffect(CONST_ME_CRITICAL_DAMAGE)
        player:say("BUFF Veteranos", TALKTYPE_MONSTER_SAY)
        player:setStorageValue(15869, interval)   
    else
        player:setStorageValue(15869, delay + interval)   
    end

This part..
Lua:
if player:getStorageValue(15866) >= os.time() then       
    player:addCondition(condition)
end
    
if player:getStorageValue(15866) <= os.time() and player:getStorageValue(15867) > 0 then   
    player:removeCondition(CONDITION_ATTRIBUTES, 20)
end
.. should be rewritten as:
Lua:
if player:getStorageValue(15866) >= os.time() then
    player:addCondition(condition)
    return true
end

if player:getStorageValue(15867) > 0 then
    player:removeCondition(CONDITION_ATTRIBUTES, 20)
end
 
Top