I think this can only be done by the player being offline.
local hp = 30 --- Set the number here and divide by 2 and thats how much hp is added. Ex 15 hp would be added here.
local mp = 30 --- Set the number here and divide by 2 and thats how much mp is added. Ex 15 mp would be added here.
function onUse(cid, item, fromPosition, itemEx, toPosition)
if item.itemid == XXXX then
setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+hp/2)
setCreatureMaxMana(cid, getCreatureMaxMana(cid)+mp/2)
doRemoveItem(item.uid,1)
end
return true
end
Wouldn't it be easier to make it write the change to the database? (add 150k hp there)
Saves you some resource usage.
query << "UPDATE `players` SET `lastlogin` = " << player->lastLogin << ", `lastip` = " << player->lastIP;
query << "`health` = " << player->health << ", ";
query << "`healthmax` = " << player->healthMax << ", ";
Ok, this works while the character is logged in. The math is set to divide whatever number you choose by 2. If you remove that, for some reason it gets a bit glitchy with just the + on there, and it will not add the correct amount of mana or hp. So here you are.
Code:local hp = 30 --- Set the number here and divide by 2 and thats how much hp is added. Ex 15 hp would be added here. local mp = 30 --- Set the number here and divide by 2 and thats how much mp is added. Ex 15 mp would be added here. function onUse(cid, item, fromPosition, itemEx, toPosition) if item.itemid == XXXX then setCreatureMaxHealth(cid, getCreatureMaxHealth(cid)+hp/2) setCreatureMaxMana(cid, getCreatureMaxMana(cid)+mp/2) doRemoveItem(item.uid,1) end return true end
Tested with TFS .3.6pl1
the character has to be offline, because when it logouts, it is going to rewrite the change, to the actual max hp.
Taken from ioLoginData -> savePlayer
PHP:query << "UPDATE `players` SET `lastlogin` = " << player->lastLogin << ", `lastip` = " << player->lastIP; query << "`health` = " << player->health << ", "; query << "`healthmax` = " << player->healthMax << ", ";
local EMPTY_POTION = 7636
local exhaust = createConditionObject(CONDITION_EXHAUST)
setConditionParam(exhaust, CONDITION_PARAM_TICKS, (getConfigInfo('timeBetweenExActions') - 100))
function onUse(cid, item, fromPosition, itemEx, toPosition)
if isPlayer(itemEx.uid) == FALSE then
return FALSE
end
if hasCondition(cid, CONDITION_EXHAUST_HEAL) == TRUE then
doPlayerSendDefaultCancel(cid, RETURNVALUE_YOUAREEXHAUSTED)
return TRUE
end
------------------Knight
if(isKnight(itemEx.uid))then
HEALTHGAINED = 1000
if (getPlayerStorageValue(cid,13001) == -1) then
setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + HEALTHGAINED)
doSendMagicEffect(getThingPos(itemEx.uid), 6)
doCreatureSay(itemEx.uid, "You Gained 1000 life", TALKTYPE_ORANGE_1)
if doCreatureAddHealth(itemEx.uid, HEALTHGAINED) == LUA_ERROR then
return FALSE
end
doAddCondition(cid, exhaust)
setPlayerStorageValue(cid,13001,1)
doTransformItem(item.uid, EMPTY_POTION)
else
doCreatureSay(itemEx.uid, "You have already use this potion before.", TALKTYPE_ORANGE_1)
end
end
------------------Paladin
if(isPaladin(itemEx.uid))then
MANAGAINED = 750
HEALTHGAINED = 500
if (getPlayerStorageValue(cid,13001) == -1) then
setCreatureMaxHealth(cid, getCreatureMaxHealth(cid) + HEALTHGAINED )
setCreatureMaxMana(cid, getCreatureMaxMana(cid) + MANAGAINED )
doSendMagicEffect(getThingPos(itemEx.uid), 6)
doCreatureSay(itemEx.uid, "You Gained 500 life and 750 mana", TALKTYPE_ORANGE_1)
GAINED = 500
if ((doCreatureAddHealth(itemEx.uid, HEALTHGAINED ) == LUA_ERROR) or (doPlayerAddMana(itemEx.uid, MANAGAINED ) == LUA_ERROR)) then
return FALSE
end
doAddCondition(cid, exhaust)
setPlayerStorageValue(cid,13001,1)
doTransformItem(item.uid, EMPTY_POTION)
else
doCreatureSay(itemEx.uid, "You have already use this potion before.", TALKTYPE_ORANGE_1)
end
end
------------------Mages
if(isSorcerer(itemEx.uid) or isDruid(itemEx.uid))then
MANAGAINED = 1750
if (getPlayerStorageValue(cid,13001) == -1) then
setCreatureMaxMana(cid, getCreatureMaxMana(cid) + MANAGAINED)
doSendMagicEffect(getThingPos(itemEx.uid), 6)
doCreatureSay(itemEx.uid, "You Gained 1750 Mana", TALKTYPE_ORANGE_1)
if doCreatureAddMana(itemEx.uid, MANAGAINED ) == LUA_ERROR then
return FALSE
end
doAddCondition(cid, exhaust)
setPlayerStorageValue(cid,13001,1)
doTransformItem(item.uid, EMPTY_POTION)
else
doCreatureSay(itemEx.uid, "You have already use this potion before.", TALKTYPE_ORANGE_1)
end
end
return TRUE
end