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

[1.2 TFS] Max health/mana potion

xoiox

New Member
Joined
Aug 20, 2009
Messages
46
Reaction score
2
Hey everybody! I'm looking for script for 1.0+ TFS, which makes drink potion add max health points and other potion makes an increase of max mana points.
 
His post contains the TFS required.
He has an identifiable thread name.
He describes what the script is meant to do.
Only thing missing is what type of script it is, however that is easily guessable as it's a potion script.

I can't find the applicable functions for 1.0+..
Here is 0.3.7
Maybe someone can convert it?
Code:
local health_gain = 1000

function onUse(cid, item, fromPosition, itemEx, toPosition)
    setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + health_gain)
    doRemoveItem(item.uid, 1)
    return true
end

Code:
local mana_gain = 1000

function onUse(cid, item, fromPosition, itemEx, toPosition)
    setCreatureMaxMana(cid, getCreatureMaxMana(cid) + mana_gain)
    doRemoveItem(item.uid, 1)
    return true
end
 
So it is possible to make this script for TFS 1.2 ?
There is no function which increases the max hp or mana in 1.2 unless you use a condition.

This would be saved inside a global file such as compat.lua
Code:
--[[---------------------------------------------
    This should be placed in a global file
]]
hp, mana, max, maxhp, maxmana = {}, {}, 255, 1000, 1000
for i = 1, max do
    hp[i] = Condition(CONDITION_ATTRIBUTES)
    hp[i]:setParameter(CONDITION_PARAM_SUBID, i)
    hp[i]:setParameter(CONDITION_PARAM_TICKS, -1)
    hp[i]:setParameter(CONDITION_PARAM_STAT_MAXHITPOINTS, maxhp)
 
    mana[i] = Condition(CONDITION_ATTRIBUTES)
    mana[i]:setParameter(CONDITION_PARAM_SUBID, i)
    mana[i]:setParameter(CONDITION_PARAM_TICKS, -1)
    mana[i]:setParameter(CONDITION_PARAM_STAT_MAXMANAPOINTS, maxmana)
end

buffstorage = { -- change the storage values to fit your needs
    hp = 123456,
    mana = 654321
}

function setCreatureMaxHealth(cid)
    local player = Player(cid)
    local n = player:getStorageValue(buffstorage.hp)
    if n > 1 then
        player:addCondition(hp[n])
    else
        player:addCondition(hp[1])
    end
    player:setStorageValue(buffstorage.hp, n > 1 and n or 1)
end

function setCreatureMaxMana(cid)
    local player = Player(cid)
    local n = player:getStorageValue(buffstorage.mana)
    if n > 1 then
        player:addCondition(mana[n])
    else
        player:addCondition(mana[1])
    end
    player:setStorageValue(buffstorage.mana, n > 1 and n or 1)
end
-------------------------------------------------

Then you would create the scripts.

One for health.
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    setCreatureMaxHealth(player:getId())
    item:remove(1)
    return true
end
And another for mana.
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    setCreatureMaxMana(player:getId())
    item:remove(1)
    return true
end
 
Last edited:
okay, so how can I set up this function if I want to give life potions +5 max health? I'm asking because I don't know how functions of TFS 1.2 working. Thanks
PS. will be fine if anybody give me link to tutorial of TFS 1.2 scripting
 
okay, so how can I set up this function if I want to give life potions +5 max health? I'm asking because I don't know how functions of TFS 1.2 working. Thanks
PS. will be fine if anybody give me link to tutorial of TFS 1.2 scripting
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    player:setMaxHealth(1000)
    item:remove(1)
    return true
end
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    player:setMaxMana(1000)
    item:remove(1)
    return true
end
 
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    player:setMaxHealth(1000)
    item:remove(1)
    return true
end
Code:
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
    player:setMaxMana(1000)
    item:remove(1)
    return true
end
but I see, "1000" means, every player get 1000 hp by drinking potion. I need script that player who has 250 hp get 255 and who has 500 hp get 505.
I need something like this:
Code:
creature:setMaxHealth((getCreatureMaxHealth)+5)
but this not working.
 
Back
Top