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

Action TFS 1.x Potions System : Percents and Summons!

Potions are work, but when someone who is level lower than needed its do this errorlog.

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/other/potions.lua:onUse
data/actions/scripts/other/potions.lua:88: attempt to concatenate field 'level' (a nil value)
stack traceback:
               [C]: in function '__concat'
               data/actions/scripts/other/potions.lua:88: in function <data/actions/scripts/other/potions.lua:33>

And sometimes this error:

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/other.potions.lua:onUse
data/actions/scripts/other/potions.lua:100: attempt to call method 'isCreatureFriend' (a nil value)
stack traceback:
  [C]: in function 'isCreatureFriend'
  data/actions/scripts/other/potions.lua:100: in function <data/actions/scripts/other/potions.lua:33>
 
Last edited:
Potions are work, but when someone who is level lower than needed its do this errorlog.

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/other/potions.lua:onUse
data/actions/scripts/other/potions.lua:88: attempt to concatenate field 'level' (a nil value)
stack traceback:
               [C]: in function '__concat'
               data/actions/scripts/other/potions.lua:88: in function <data/actions/scripts/other/potions.lua:33>

And sometimes this error:

Code:
Lua Script Error: [Action Interface]
data/actions/scripts/other.potions.lua:onUse
data/actions/scripts/other/potions.lua:100: attempt to call method 'isCreatureFriend' (a nil value)
stack traceback:
  [C]: in function 'isCreatureFriend'
  data/actions/scripts/other/potions.lua:100: in function <data/actions/scripts/other/potions.lua:33>

You are using the wrong version for your server, plz make sure to use the one listed for your server type. Also you didn't add the library in my link if you get that random one last. First instinct is that you have 1.2 for a 1.0 server
 
You are using the wrong version for your server, plz make sure to use the one listed for your server type. Also you didn't add the library in my link if you get that random one last. First instinct is that you have 1.2 for a 1.0 server

Im using tfs 1.1 and this script ~> http://pastebin.com/FnXcZLuf

Its anything else that i must do? How to inject new libs?
 
I have error :(
Lua Script Error: [Action Interface]
data/actions/scripts/other/potions.lua:eek:nUse
data/actions/scripts/other/potions.lua:173: attempt to index local 'cooldown' (a nil value)
stack traceback:
[C]: in function '__index'
data/actions/scripts/other/potions.lua:173: in function <data/actions/scripts/other/potions.lua:31>
help!
 
Im using tfs 1.1 and this script ~> [Lua] potion - Pastebin.com

Its anything else that i must do? How to inject new libs?

I have error :(
Lua Script Error: [Action Interface]
data/actions/scripts/other/potions.lua:eek:nUse
data/actions/scripts/other/potions.lua:173: attempt to index local 'cooldown' (a nil value)
stack traceback:
[C]: in function '__index'
data/actions/scripts/other/potions.lua:173: in function <data/actions/scripts/other/potions.lua:31>
help!

You all ever get this working?

@demon088 Thanks man I appreciate that!

Can anyone tell me if this works with 1.3 without alteration?
 
I could update this script, I just don't have the time right now. :(
 
Thinking about adding some more features guys. Such as the conditions that come with the standard potions.lua (bullseye, antidote, berzerk and mastermind) as well as maybe some more custom condition bonus's. If I added them, it would be configurable to each individual potion and I would allow for more than one "buff" per potion if you would like. Also thought about adding some detail and maybe some rpg'sh features too. Such as adding the empty flash back after potion use, listing the level requirement and/or vocation requirement when player doesn't meet said requirement and tries to use the potion.

Anyways what do you guys think? Yay or nay on those features? Got any other bright ideas? Trying to make this the #1 all around used potion script. For everyone!
 
Lua Script Error: [Action Interface]
data/actions/scripts/other/potions.lua:eek:nUse
data/actions/scripts/other/potions.lua:124: attempt to index local 'cooldown' (a nil value)
stack traceback:
[C]: in function '__index'
data/actions/scripts/other/potions.lua:124: in function <data/actions/scripts/other/potions.lua:31>

How can I fix this?
 
Lua Script Error: [Action Interface]
data/actions/scripts/other/potions.lua:eek:nUse
data/actions/scripts/other/potions.lua:124: attempt to index local 'cooldown' (a nil value)
stack traceback:
[C]: in function '__index'
data/actions/scripts/other/potions.lua:124: in function <data/actions/scripts/other/potions.lua:31>

How can I fix this?

Take the script that you are using, and copy it somewhere I can see if you edited it at all.

I need to know which version of the script you are using, and which server you are using it on. If it is an OTX, which one?
 
Take the script that you are using, and copy it somewhere I can see if you edited it at all.

I need to know which version of the script you are using, and which server you are using it on. If it is an OTX, which one?

I am using otx server 3, path 8.6, tfs 1.2.

The original potion.lua in this server is:

Code:
local berserk = Condition(CONDITION_ATTRIBUTES)
berserk:setParameter(CONDITION_PARAM_SUBID, 7)
berserk:setParameter(CONDITION_PARAM_TICKS, 10 * 60 * 1000)
berserk:setParameter(CONDITION_PARAM_SKILL_MELEE, 5)
berserk:setParameter(CONDITION_PARAM_SKILL_SHIELD, -10)
berserk:setParameter(CONDITION_PARAM_BUFF_SPELL, true)

local mastermind = Condition(CONDITION_ATTRIBUTES)
mastermind:setParameter(CONDITION_PARAM_SUBID, 8)
mastermind:setParameter(CONDITION_PARAM_TICKS, 10 * 60 * 1000)
mastermind:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, 3)
mastermind:setParameter(CONDITION_PARAM_BUFF_SPELL, true)

local bullseye = Condition(CONDITION_ATTRIBUTES)
bullseye:setParameter(CONDITION_PARAM_SUBID, 9)
bullseye:setParameter(CONDITION_PARAM_TICKS, 10 * 60 * 1000)
bullseye:setParameter(CONDITION_PARAM_SKILL_DISTANCE, 5)
bullseye:setParameter(CONDITION_PARAM_SKILL_SHIELD, -10)
bullseye:setParameter(CONDITION_PARAM_BUFF_SPELL, true)

local antidote = Combat()
antidote:setParameter(COMBAT_PARAM_TYPE, COMBAT_HEALING)
antidote:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
antidote:setParameter(COMBAT_PARAM_DISPEL, CONDITION_POISON)
antidote:setParameter(COMBAT_PARAM_AGGRESSIVE, false)
antidote:setParameter(COMBAT_PARAM_TARGETCASTERORTOPMOST, true)

local potions = {
    [6558] = {transform = {id = {7588, 7589}}, effect = CONST_ME_DRAWBLOOD},
    [7439] = {condition = berserk, vocations = {4, 8}, effect = CONST_ME_MAGIC_RED,
            description = "Only knights may drink this potion.", text = "You feel stronger."},

    [7440] = {condition = mastermind, vocations = {1, 2, 5, 6}, effect = CONST_ME_MAGIC_BLUE,
            description = "Only sorcerers and druids may drink this potion.", text = "You feel smarter."},

    [7443] = {condition = bullseye, vocations = {3, 7}, effect = CONST_ME_MAGIC_GREEN,
            description = "Only paladins may drink this potion.", text = "You feel more accurate."},

    [7588] = {health = {250, 350}, vocations = {3, 4, 7, 8}, level = 50, flask = 7634,
            description = "Only knights and paladins of level 50 or above may drink this fluid."},

    [7589] = {mana = {115, 185}, vocations = {1, 2, 3, 5, 6, 7}, level = 50, flask = 7634,
            description = "Only sorcerers, druids and paladins of level 50 or above may drink this fluid."},

    [7590] = {mana = {150, 250}, vocations = {1, 2, 5, 6}, level = 80, flask = 7635,
            description = "Only druids and sorcerers of level 80 or above may drink this fluid."},

    [7591] = {health = {425, 575}, vocations = {4, 8}, level = 80, flask = 7635,
            description = "Only knights of level 80 or above may drink this fluid."},

    [7618] = {health = {125, 175}, flask = 7636},
    [7620] = {mana = {75, 125}, flask = 7636},
    [8472] = {health = {250, 350}, mana = {100, 200}, vocations = {3, 7}, level = 80, flask = 7635,
            description = "Only paladins of level 80 or above may drink this fluid."},

    [8473] = {health = {650, 850}, vocations = {4, 8}, level = 130, flask = 7635,
            description = "Only knights of level 130 or above may drink this fluid."},

    [8474] = {combat = antidote, flask = 7636},
    [8704] = {health = {60, 90}, flask = 7636}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if type(target) == "userdata" and not target:isPlayer() then
        return false
    end

    local potion = potions[item:getId()]
    if potion.level and player:getLevel() < potion.level or potion.vocations and not table.contains(potion.vocations, player:getVocation():getBase():getId()) and not (player:getGroup():getId() >= 2) then
        player:say(potion.description, TALKTYPE_MONSTER_SAY)
        return true
    end

    if potion.health or potion.mana or potion.combat then
        if potion.health then
            doTargetCombatHealth(0, target, COMBAT_HEALING, potion.health[1], potion.health[2], CONST_ME_MAGIC_BLUE)
        end

        if potion.mana then
            doTargetCombatMana(0, target, potion.mana[1], potion.mana[2], CONST_ME_MAGIC_BLUE)
        end

        if potion.combat then
            potion.combat:execute(target, Variant(target:getId()))
        end

        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
        player:addItem(potion.flask, 1)
    end

    if potion.condition then
        player:addCondition(potion.condition)
        player:say(potion.text, TALKTYPE_MONSTER_SAY)
        player:getPosition():sendMagicEffect(potion.effect)
    end

    if potion.transform then
        item:transform(potion.transform.id[math.random(#potion.transform.id)])
        item:getPosition():sendMagicEffect(potion.effect)
        return true
    end

    item:remove(1)
    return true
end
 
I am using otx server 3, path 8.6, tfs 1.2.

The original potion.lua in this server is:

Code:
local berserk = Condition(CONDITION_ATTRIBUTES)
berserk:setParameter(CONDITION_PARAM_SUBID, 7)
berserk:setParameter(CONDITION_PARAM_TICKS, 10 * 60 * 1000)
berserk:setParameter(CONDITION_PARAM_SKILL_MELEE, 5)
berserk:setParameter(CONDITION_PARAM_SKILL_SHIELD, -10)
berserk:setParameter(CONDITION_PARAM_BUFF_SPELL, true)

local mastermind = Condition(CONDITION_ATTRIBUTES)
mastermind:setParameter(CONDITION_PARAM_SUBID, 8)
mastermind:setParameter(CONDITION_PARAM_TICKS, 10 * 60 * 1000)
mastermind:setParameter(CONDITION_PARAM_STAT_MAGICPOINTS, 3)
mastermind:setParameter(CONDITION_PARAM_BUFF_SPELL, true)

local bullseye = Condition(CONDITION_ATTRIBUTES)
bullseye:setParameter(CONDITION_PARAM_SUBID, 9)
bullseye:setParameter(CONDITION_PARAM_TICKS, 10 * 60 * 1000)
bullseye:setParameter(CONDITION_PARAM_SKILL_DISTANCE, 5)
bullseye:setParameter(CONDITION_PARAM_SKILL_SHIELD, -10)
bullseye:setParameter(CONDITION_PARAM_BUFF_SPELL, true)

local antidote = Combat()
antidote:setParameter(COMBAT_PARAM_TYPE, COMBAT_HEALING)
antidote:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
antidote:setParameter(COMBAT_PARAM_DISPEL, CONDITION_POISON)
antidote:setParameter(COMBAT_PARAM_AGGRESSIVE, false)
antidote:setParameter(COMBAT_PARAM_TARGETCASTERORTOPMOST, true)

local potions = {
    [6558] = {transform = {id = {7588, 7589}}, effect = CONST_ME_DRAWBLOOD},
    [7439] = {condition = berserk, vocations = {4, 8}, effect = CONST_ME_MAGIC_RED,
            description = "Only knights may drink this potion.", text = "You feel stronger."},

    [7440] = {condition = mastermind, vocations = {1, 2, 5, 6}, effect = CONST_ME_MAGIC_BLUE,
            description = "Only sorcerers and druids may drink this potion.", text = "You feel smarter."},

    [7443] = {condition = bullseye, vocations = {3, 7}, effect = CONST_ME_MAGIC_GREEN,
            description = "Only paladins may drink this potion.", text = "You feel more accurate."},

    [7588] = {health = {250, 350}, vocations = {3, 4, 7, 8}, level = 50, flask = 7634,
            description = "Only knights and paladins of level 50 or above may drink this fluid."},

    [7589] = {mana = {115, 185}, vocations = {1, 2, 3, 5, 6, 7}, level = 50, flask = 7634,
            description = "Only sorcerers, druids and paladins of level 50 or above may drink this fluid."},

    [7590] = {mana = {150, 250}, vocations = {1, 2, 5, 6}, level = 80, flask = 7635,
            description = "Only druids and sorcerers of level 80 or above may drink this fluid."},

    [7591] = {health = {425, 575}, vocations = {4, 8}, level = 80, flask = 7635,
            description = "Only knights of level 80 or above may drink this fluid."},

    [7618] = {health = {125, 175}, flask = 7636},
    [7620] = {mana = {75, 125}, flask = 7636},
    [8472] = {health = {250, 350}, mana = {100, 200}, vocations = {3, 7}, level = 80, flask = 7635,
            description = "Only paladins of level 80 or above may drink this fluid."},

    [8473] = {health = {650, 850}, vocations = {4, 8}, level = 130, flask = 7635,
            description = "Only knights of level 130 or above may drink this fluid."},

    [8474] = {combat = antidote, flask = 7636},
    [8704] = {health = {60, 90}, flask = 7636}
}

function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    if type(target) == "userdata" and not target:isPlayer() then
        return false
    end

    local potion = potions[item:getId()]
    if potion.level and player:getLevel() < potion.level or potion.vocations and not table.contains(potion.vocations, player:getVocation():getBase():getId()) and not (player:getGroup():getId() >= 2) then
        player:say(potion.description, TALKTYPE_MONSTER_SAY)
        return true
    end

    if potion.health or potion.mana or potion.combat then
        if potion.health then
            doTargetCombatHealth(0, target, COMBAT_HEALING, potion.health[1], potion.health[2], CONST_ME_MAGIC_BLUE)
        end

        if potion.mana then
            doTargetCombatMana(0, target, potion.mana[1], potion.mana[2], CONST_ME_MAGIC_BLUE)
        end

        if potion.combat then
            potion.combat:execute(target, Variant(target:getId()))
        end

        target:say("Aaaah...", TALKTYPE_MONSTER_SAY)
        player:addItem(potion.flask, 1)
    end

    if potion.condition then
        player:addCondition(potion.condition)
        player:say(potion.text, TALKTYPE_MONSTER_SAY)
        player:getPosition():sendMagicEffect(potion.effect)
    end

    if potion.transform then
        item:transform(potion.transform.id[math.random(#potion.transform.id)])
        item:getPosition():sendMagicEffect(potion.effect)
        return true
    end

    item:remove(1)
    return true
end

That doesn't even have 124 lines. This cannot be the script that is calling the error. I think you are asking for help with the wrong thing for this board.
 
That doesn't even have 124 lines. This cannot be the script that is calling the error. I think you are asking for help with the wrong thing for this board.

I'm sorry, the script I posted is the one I used before, which I changed for yours but is giving me that error. I just copy and paste the potion v12 script you posted, but I have no idea how to fix it.
 
I'm sorry, the script I posted is the one I used before, which I changed for yours but is giving me that error. I just copy and paste the potion v12 script you posted, but I have no idea how to fix it.

No man, no way that's possible, the attached script to this thread for v12 does not have "cooldown" anywhere near line 124, I can't help you if I don't see the script, and the script you are using, wherever you got it, is not the original from this thread.
 
Hello Otland!

Today I bring a release for everyone. I have worked on this script for awhile now and I have gotten it ready for everyone here. I became inspired when I seen a script for TFS 1.x for healing potions using a percent of max health, same thing with the mana potions for mana. Anyways the script was very very much bugged, and missed alot of features. It also relied heavily on functions from compat.lua instead of meta methods. So I did my best to convert it to something for an RPG type feel. During that process I decided to make options that you guys may want to change, and started creating a super configurable potions system.

CREDITS:

@Ninja for helping me with a problem determining if the summon was a guild or party members.
@otland for all the resources and help with learning.
@Limos and @forgee both special thanks for helping me to develop my skills and easing the learning process.

||||Features||||
-- Potions are based of Max Percents and individually configurable for each potion.
-- Potions are also based of Level and Magic level, which can be configured for all potions.
-- Potions can be used on Summons -- Configurable
--- Can be used on Guild Members Summon -- Configurable
--- Can be used on Party Members Summon -- Configurable
-- Potion's formula has min and max percents -- Configurable
-- Anti-Hotkey protection (realPvpMode) -- Configurable
-- Remove on Use -- Configurable
-- Splashable (with decay) -- Configurable for individual potions.
-- Level Requirements -- Configurable for individual potions.
-- Vocation Requirements -- Configurable for individual potions.
-- Unique Exhaust/Cooldown System -- Configurable for individual potions.
--- Potions with same "spellid" share same exhaust. However two potions with same "spellid" can have different exhaust values. Default set up for different exhausts for mana potions, health (little) and health (big), and spirit potion. Spell Id is sent as icon. Cooldown don't interfere with spells of same spell Id.
-- Misclick Protection: Doesn't allow use on stuff far away (good because it's splashable and if you have remove on use enabled), summons (if disabled), monsters, and Npc's.

If there is any other features I am missing that should be mentioned please let me know.

Only thing that should be explained that isn't in comments in the script is the table, but really that should be self-explanatory. If anyone has a problem, just post here and I will help you.

FULLY TESTED BUG FREE

If you do use this, please keep my credits in the script, and it wouldn't hurt to get a like. :D

[Lua] potions.lua - Pastebin.com

Version 1.1 is done.
Fixed enum causing debug.
Updated for tfs 1.1 compatibility
Cleaned up monster checks: Now depend upon Player:isCreatureFriend() method.

New version depends on this lib.
[TFS 1.X] Player:isCreatureFriend()

[Lua] potion - Pastebin.com

Sorry guys, apparently the code is over 1000 characters by itself.

NEW VERSION v12

Changelog:
  • Replaced some parameters eg. player = caster ect.
  • Updated for 1.2 and 1.3 (unoffically) compatibility.
  • Integrated isCreatureFriend function in from lib.
  • Updated Commentation.
  • Reworked some variables (removed unused, renamed, added new).
How do I create an empty flash after using?
 
Back
Top