I am looking for an npc that sells hp and mana. The one that buys mana or hp will increase his/hers maximum hp/mana permanently. Is this possible? If so can anyone make one?
Thanks in advance(rep++)
addEvent(healingPuffs, 5000, {cid = cid , health = 10 , id = 0})
function healingPuffs(parameters)
local cid = parameters.cid
local health = parameters.health
local id = parameters.id + 1
if id < 10 then
doSendAnimatedText(getCreaturePosition(cid), health, TEXTCOLOR_GREEN)
setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + health)
doSendMagicEffect(getCreaturePosition(cid), 12)
addEvent(healingPuffs, 2000, {cid = cid , health = 10 * id , id = id})
end
return TRUE
end
local config = {
healthCost = 50000,
healthAmount = 100,
manaCost = 70000,
manaAmount = 100
}
function onSay(cid, words, param)
local fSet, fGet, fAdd = setCreatureMaxHealth, getCreatureMaxHealth, doCreatureAddHealth
local cost, amount = config.healthCost, config.healthAmount
local str = "health"
if(words == "!buymana") then
fSet, fGet, fAdd = setCreatureMaxMana, getCreatureMaxMana, doCreatureAddMana
cost, amount = config.manaCost, config.healthAmount
str = "mana"
end
if(doPlayerRemoveMoney(cid, cost) ~= TRUE) then
doPlayerSendTextMessage(cid, MESSAGE_STATUS_CONSOLE_BLUE, "Sorry, you dont have enough money.")
return TRUE
end
fSet(cid, fGet(cid) + amount)
fAdd(cid, amount)
doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You have bought " .. amount .. " " .. str .. " points.")
return TRUE
end
<talkaction words="!buyhp" script="buy_hpmana.lua"/>
<talkaction words="!buymana" script="buy_hpmana.lua"/>
I noticed that by adding doCreatureAddHealth(cid, getCreatureMaxHealth(cid), TRUE) after the setCreatureMaxHealth() function, it will automatically update your healthbar instead of you having to logout and login.