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

Solved Add health to all players?

AnarchGov

Member
Joined
Oct 3, 2011
Messages
263
Reaction score
6
I recently made an update to all vocations on my server so that they would gain an EXTRA 3 health and mana every level. Everything worked out fine, however i realized that the people who already have players did not get the boost the boost from the levels they got before the update. So their hp stays the same, and yes they will gain the extra for each level they gain from here on out, but another player who starts at 8 and gets their level, will have much more hp and mana at the same level.

Is there a way to simply add the hp and health that the existing players need? So +3 for every level they have already achieved? I hope i was clear enough. Its kind of hard to explain.

REP++
 
Last edited:
well you can do that with an easy formula:
LUA:
local formula_health = 185 + ((getPlayerLevel(cid) - 8) * (getVocationInfo(getPlayerVocationId(cid)).healthGain + 3)
local formula_mana = 35 + ((getPlayerLevel(cid) - 8) * (getVocationInfo(getPlayerVocationId(cid)).manaGain + 3)
setCreatureMaxHealth(cid, formula_health)
setCreatureMaxMana(cid, formula_mana)

this way you can correct the difference between them.


Kind regards, Evil Hero.
 
Would you mind explaining how this works? I just want to make sure it will do what i need it to. Also, where would i put it? Is it a one time use kind of thing?
 
put it into login.lua
LUA:
local storage = 9999 -- use whatever storage you do not need.
if getPlayerStorageValue(cid, storage) == -1 then
local formula_health = 185 + ((getPlayerLevel(cid) - 8) * (getVocationInfo(getPlayerVocationId(cid)).healthGain + 3))
local formula_mana = 35 + ((getPlayerLevel(cid) - 8) * (getVocationInfo(getPlayerVocationId(cid)).manaGain + 3))
setCreatureMaxHealth(cid, formula_health)
setCreatureMaxMana(cid, formula_mana)
setPlayerStorageValue(cid, storage, 1)
end
this will correct the hp/mana once the player logs in, after a few weeks you can remove it then.
another way would be doing a query update for the database but that's up to you.



Kind regards, Evil Hero.
 
What would the query look like? Also, Won't it keep adding hp and mana everytime players login? Also it looks like you have the script starting at 185, all my players start with 180 hp. Do i just change that?
 
ohh nvm, yea just change it to 180, just took a look into my database and the player somehow had 185 at lvl 8 so used it as reference :P
and no, because of the storagevalue it'll just do it at the first login and then never again unless you reset the storagevalue.
 
Back
Top