• 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 Actions TFS 1.3

MopdaAll

New Member
Joined
May 29, 2020
Messages
26
Reaction score
2
This is a mana and health rune, but how do I add a level requirement to it and how do I make the runes clickable like potions so that it can be used on other players? Like lvl 20 for itemid 12596 and lvl 200 for itemid 12600.
Lua:
local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, 1200)

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if type(target) == "userdata" and not target:isPlayer() then
        return false
    end
    
  if player:getCondition(CONDITION_EXHAUST_HEAL) then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
        return true
    end

    if item:getId() == 12596 then
        doTargetCombatMana(0, player, (40), (60), CONST_ME_MAGIC_BLUE)
        doTargetCombatHealth(0, player, (20), (50), CONST_ME_MAGIC_BLUE)
        item:remove(1)
        player:say("Aaaah...", TALKTYPE_MONSTER_SAY)
    end

    if item:getId() == 12600 then
        doTargetCombatMana(0, player, (150), (240), CONST_ME_MAGIC_BLUE)
        doTargetCombatHealth(0, player, (90), (120), CONST_ME_MAGIC_BLUE)
        item:remove(1)
        player:say("Aaaah...", TALKTYPE_MONSTER_SAY)
    end
    return true
end
 
Solution
Just elseif instead of only else.
Lua:
local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, 1200)

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if type(target) == "userdata" and not target:isPlayer() then
        return false
    end
   
  if player:getCondition(CONDITION_EXHAUST_HEAL) then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
        return true
    end

    if item:getId() == 12596 and player:getLevel() >= 20 then
        doTargetCombatMana(0, player, (40), (60), CONST_ME_MAGIC_BLUE)
        doTargetCombatHealth(0, player, (20), (50), CONST_ME_MAGIC_BLUE)
        item:remove(1)...
Lua:
local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, 1200)

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if type(target) == "userdata" and not target:isPlayer() then
        return false
    end
  
  if player:getCondition(CONDITION_EXHAUST_HEAL) then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
        return true
    end

    if item:getId() == 12596 and player:getLevel() >= 20 then
        doTargetCombatMana(0, player, (40), (60), CONST_ME_MAGIC_BLUE)
        doTargetCombatHealth(0, player, (20), (50), CONST_ME_MAGIC_BLUE)
        item:remove(1)
        player:say("Aaaah...", TALKTYPE_MONSTER_SAY)
    end

    if item:getId() == 12600 and player:getLevel() >= 200 then
        doTargetCombatMana(0, player, (150), (240), CONST_ME_MAGIC_BLUE)
        doTargetCombatHealth(0, player, (90), (120), CONST_ME_MAGIC_BLUE)
        item:remove(1)
        player:say("Aaaah...", TALKTYPE_MONSTER_SAY)
    end
    return true
end
and to make it use-able you'll have to edit your items.otb and mark same attributes as other/normal runes/potions.
useable.PNG
 
Last edited:
Lua:
local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, 1200)

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if type(target) == "userdata" and not target:isPlayer() then
        return false
    end
 
  if player:getCondition(CONDITION_EXHAUST_HEAL) then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
        return true
    end

    if item:getId() == 12596 and player:getLevel() >= 20 then
        doTargetCombatMana(0, player, (40), (60), CONST_ME_MAGIC_BLUE)
        doTargetCombatHealth(0, player, (20), (50), CONST_ME_MAGIC_BLUE)
        item:remove(1)
        player:say("Aaaah...", TALKTYPE_MONSTER_SAY)
    end

    if item:getId() == 12600 and player:getLevel() >= 200 then
        doTargetCombatMana(0, player, (150), (240), CONST_ME_MAGIC_BLUE)
        doTargetCombatHealth(0, player, (90), (120), CONST_ME_MAGIC_BLUE)
        item:remove(1)
        player:say("Aaaah...", TALKTYPE_MONSTER_SAY)
    end
    return true
end
and to make it use-able you'll have to edit your items.otb and mark same attributes as other/normal runes/potions.
View attachment 46302
one more thing, is this the right way to make an else statement if the player does not have required level?
Lua:
local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, 1200)

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if type(target) == "userdata" and not target:isPlayer() then
        return false
    end
    
  if player:getCondition(CONDITION_EXHAUST_HEAL) then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
        return true
    end

    if item:getId() == 12596 and player:getLevel() >= 20 then
        doTargetCombatMana(0, player, (40), (60), CONST_ME_MAGIC_BLUE)
        doTargetCombatHealth(0, player, (20), (50), CONST_ME_MAGIC_BLUE)
        item:remove(1)
        player:say("Aaaah...", TALKTYPE_MONSTER_SAY)
            else player:getLevel() >= 200 then
                player:say("You need to be level 200 or above!", TALKTYPE_MONSTER_SAY)   
    end

    if item:getId() == 12600 and player:getLevel() >= 200 then
        doTargetCombatMana(0, player, (150), (240), CONST_ME_MAGIC_BLUE)
        doTargetCombatHealth(0, player, (90), (120), CONST_ME_MAGIC_BLUE)
        item:remove(1)
        player:say("Aaaah...", TALKTYPE_MONSTER_SAY)
            else player:getLevel() >= 200 then
                player:say("You need to be level 200 or above!", TALKTYPE_MONSTER_SAY)               
    end
    return true
end
 
Just elseif instead of only else.
Lua:
local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, 1200)

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if type(target) == "userdata" and not target:isPlayer() then
        return false
    end
   
  if player:getCondition(CONDITION_EXHAUST_HEAL) then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
        return true
    end

    if item:getId() == 12596 and player:getLevel() >= 20 then
        doTargetCombatMana(0, player, (40), (60), CONST_ME_MAGIC_BLUE)
        doTargetCombatHealth(0, player, (20), (50), CONST_ME_MAGIC_BLUE)
        item:remove(1)
        player:say("Aaaah...", TALKTYPE_MONSTER_SAY)
            elseif player:getLevel() >= 20 then
                player:say("You need to be level 20 or above!", TALKTYPE_MONSTER_SAY)  
    end

    if item:getId() == 12600 and player:getLevel() >= 200 then
        doTargetCombatMana(0, player, (150), (240), CONST_ME_MAGIC_BLUE)
        doTargetCombatHealth(0, player, (90), (120), CONST_ME_MAGIC_BLUE)
        item:remove(1)
        player:say("Aaaah...", TALKTYPE_MONSTER_SAY)
            elseif player:getLevel() >= 200 then
                player:say("You need to be level 200 or above!", TALKTYPE_MONSTER_SAY)              
    end
    return true
end
 
Solution
Just elseif instead of only else.
Lua:
local exhaust = Condition(CONDITION_EXHAUST_HEAL)
exhaust:setParameter(CONDITION_PARAM_TICKS, 1200)

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if type(target) == "userdata" and not target:isPlayer() then
        return false
    end
 
  if player:getCondition(CONDITION_EXHAUST_HEAL) then
        player:sendTextMessage(MESSAGE_STATUS_SMALL, Game.getReturnMessage(RETURNVALUE_YOUAREEXHAUSTED))
        return true
    end

    if item:getId() == 12596 and player:getLevel() >= 20 then
        doTargetCombatMana(0, player, (40), (60), CONST_ME_MAGIC_BLUE)
        doTargetCombatHealth(0, player, (20), (50), CONST_ME_MAGIC_BLUE)
        item:remove(1)
        player:say("Aaaah...", TALKTYPE_MONSTER_SAY)
            elseif player:getLevel() >= 20 then
                player:say("You need to be level 20 or above!", TALKTYPE_MONSTER_SAY)
    end

    if item:getId() == 12600 and player:getLevel() >= 200 then
        doTargetCombatMana(0, player, (150), (240), CONST_ME_MAGIC_BLUE)
        doTargetCombatHealth(0, player, (90), (120), CONST_ME_MAGIC_BLUE)
        item:remove(1)
        player:say("Aaaah...", TALKTYPE_MONSTER_SAY)
            elseif player:getLevel() >= 200 then
                player:say("You need to be level 200 or above!", TALKTYPE_MONSTER_SAY)            
    end
    return true
end
Thanks so much, it works now
 
Last edited:
Back
Top