What TFS? And please refer to https://otland.net/threads/board-rules-for-requests.113384/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.What TFS? And please refer to https://otland.net/threads/board-rules-for-requests.113384/
local health_gain = 1000
function onUse(cid, item, fromPosition, itemEx, toPosition)
setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + health_gain)
doRemoveItem(item.uid, 1)
return true
end
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 ?
--[[---------------------------------------------
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
-------------------------------------------------
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
setCreatureMaxHealth(player:getId())
item:remove(1)
return true
end
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
setCreatureMaxMana(player:getId())
item:remove(1)
return true
end
creature:setMaxHealth(maxHealth)There is no function which increases the max hp or mana in 1.2 unless you use a condition.
Thanks, I checked the sources and don't know why I didn't see that one.creature:setMaxHealth(maxHealth)
player:setMaxMana(maxMana)
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
function onUse(player, item, fromPosition, target, toPosition, isHotkey)
player:setMaxHealth(1000)
item:remove(1)
return true
end
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.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
creature:setMaxHealth((getCreatureMaxHealth)+5)
Thanks zbizu, that's it!player:setMaxHealth(player:getMaxHealth() + 5)