• 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 Storage Issue (Max HP) [OTX3]

Crevasse

惡名昭彰
Joined
Jan 13, 2017
Messages
145
Solutions
16
Reaction score
107
Location
Washington, D.C.
~*~*SOLVED*~*~

I encountered an interesting problem when changing a player's max HP with equipment. I set Knight armor and Knight legs to increase the wearer's max HP by 20% (each) by adding the maxhitpointspercent attribute and then changing movements.xml. This works just fine, the issue comes when the player wearing the equipment relogs (or dies). Example:

My test character's base max HP is 100. I put on knight armor and knight legs, the max HP is now 140. I heal up with exura to get full HP. Then, I relog. When I log back in, the max HP is 140 (the bonus is still there) which is fine, but I'm not at full HP anymore, I'm at 120.

Something is wrong with storage somewhere and it isn't "saving" that the player has healed up to their new max HP. Wearing just one of the two (only K-legs or K-armor) doesn't have a problem. It's when I wear more than 1 item that modifies max HP that the problem arises.

Any help is greatly appreciated.
 
Last edited:
Solution
I need to reopen this, as there is a new issue i encountered. All characters on my account are fine, but when I use a different account the character instantly dies when it logs in. I guess I don't enough about storages to see what the problem is I thought it was working for all players
Lua:
    if player:getLastLoginSaved() > 0 then
        local hp = player:getStorageValue(5678)
        local chp = player:getHealth()
        if (hp ~= -1) then
            player:addHealth(hp - chp)
        end
        local mp = player:getStorageValue(5679)
        local cmp = player:getMana()
        if (mp ~= -1) then
            player:addMana(mp - cmp)
        end
    end
K I will check that. Just curious, why would it save for 1 piece of equipment but not 2? xD
Thanks for letting me know Xeraphus, I changed the title! I knew OTX3 was based off 1.2 but I didn't know how different it was :p
 
Last edited:
K I will check that. Just curious, why would it save for 1 piece of equipment but not 2? xD
Thanks for letting me know Xeraphus, I changed the title! I knew OTX3 was based off 1.2 but I didn't know how different it was :p
it might save only the last piece of eq that you equipped, rather than your whole set.
if you can check that somehow it would be a good start (change the hp% values on 2 pieces and see which saves)
 
I encountered an interesting problem when changing a player's max HP with equipment. I set Knight armor and Knight legs to increase the wearer's max HP by 20% (each) by adding the maxhitpointspercent attribute and then changing movements.xml. This works just fine, the issue comes when the player wearing the equipment relogs (or dies). Example:

My test character's base max HP is 100. I put on knight armor and knight legs, the max HP is now 140. I heal up with exura to get full HP. Then, I relog. When I log back in, the max HP is 140 which is fine, but I'm not at full HP anymore, I'm at 120.

Something is wrong with storage somewhere and it isn't "saving" that the player has healed up to their new max HP. Wearing just one of the two (only K-legs or K-armor) doesn't have a problem. It's when I wear more than 1 item that modifies max HP that the problem arises.

Any help is greatly appreciated.
You should post the script you used to equip the items this would better than everyone guessing what the problem could be.
 
Code:
<movevent event="Equip" itemid="2476" slot="armor" function="onEquipItem" />
   <movevent event="DeEquip" itemid="2476" slot="armor" function="onDeEquipItem" />
   <movevent event="Equip" itemid="2477" slot="legs" function="onEquipItem" />
   <movevent event="DeEquip" itemid="2477" slot="legs" function="onDeEquipItem" />

@Makalo Since you asked. Now the whole world can finally stop guessing what the problem could be LOL
 
Code:
<movevent event="Equip" itemid="2476" slot="armor" function="onEquipItem" />
   <movevent event="DeEquip" itemid="2476" slot="armor" function="onDeEquipItem" />
   <movevent event="Equip" itemid="2477" slot="legs" function="onEquipItem" />
   <movevent event="DeEquip" itemid="2477" slot="legs" function="onDeEquipItem" />

@Makalo Since you asked. Now the whole world can finally stop guessing what the problem could be LOL
Can you post the entries in items.xml as well?
 
@Xeraphus I think you're on to something, it seems to be only saving the HP for the most recent one.
@Makalo
Code:
<item id="2476" article="a" name="knight armor">
        <attribute key="weight" value="12000"/>
        <attribute key="armor" value="12"/>
        <attribute key="slotType" value="body"/>
         <attribute key="maxHitPointsPercent" value="120"/>
    </item>

<item id="2477" name="knight legs">
       <attribute key="weight" value="7000"/>
       <attribute key="armor" value="8"/>
       <attribute key="slotType" value="legs"/>
       <attribute key="maxHitPointsPercent" value="110"/>
   </item>

I changed the % so they weren't the same in order to see which one wasn't saving
 
Last edited:
@Xeraphus I think you're on to something, it seems to be only saving the HP for the most recent one.
@Makalo
Code:
<item id="2476" article="a" name="knight armor">
        <attribute key="weight" value="12000"/>
        <attribute key="armor" value="12"/>
        <attribute key="slotType" value="body"/>
         <attribute key="maxHitPointsPercent" value="120"/>
    </item>

<item id="2477" name="knight legs">
       <attribute key="weight" value="7000"/>
       <attribute key="armor" value="8"/>
       <attribute key="slotType" value="legs"/>
       <attribute key="maxHitPointsPercent" value="110"/>
   </item>

I changed the % so they weren't the same in order to see which one wasn't saving
Why not use a script and apply a different subid for each type of slot, after all you can't wear more than one pair of boots right?
If you do it through a script the server will treat the bonus hp as a condition which can be removed by just removing the item. Even if the player logs out they will still retain the bonus when they log back in and it might even update as the player levels up.
 
You're very correct, I could do that. I am just more familiar with doing the attribute key and movements (because it is simpler). Would I just need to create a creaturescript for the movement?

Could I still make it so different armors do different bonuses though? Yeah I know I can only wear 1 pair of boots but I don't want Knight, Crown and Magic Plate armors to all give the exact same bonus.
 
Last edited:
You're very correct, I could do that. I am just more familiar with doing the attribute key and movements (because it is simpler). Would I just need to create a creaturescript for the movement?

Could I still make it so different armors do different bonuses though? Yeah I know I can only wear 1 pair of boots but I don't want Knight, Crown and Magic Plate armors to all give the exact same bonus.
Yes, you don't really need a complicated script to assign items attributes such as the ones SN4KY linked to. I think it would be a great idea if you started small and just assigned a few attributes to a few items until you become familiar with how it all works together then if you aren't satisfied with your own creativity move on to something more complex.
 
Yeah I've seen those ones that SN4KY linked but I thought they were a bit too complicated for what I was going for (although they look cool), just some simple health boost attributes. Well I'll work on making one and I'll check back if I need help, I'll also wait to see if Xeraphus can discover anything with the info I gave him about the order of the items affecting which bonus is retained
 
on logout do this

Code:
function onLogout(player)
    local playerId = player:getId()
    if nextUseStaminaTime[playerId] ~= nil then
        nextUseStaminaTime[playerId] = nil
    end
local hp = player:getHealth()
player:setStorageValue(5678, hp)
    return true
end

at the end of Login above the last return true
do this

Code:
local hp = player:getStorageValue(5678)
local chp = player:getHealth()
player:addHealth(hp - chp)

not tested
 
Last edited:
the idea is storage the Hp when you logout, use print instead of player:addHealth(hp - chp)
remove the player:addHealth(hp - chp)
and use this
print(hp)
print(chp)
to see the values first
 
@Il Knight hey man thanks for the response but I don't think I understand exactly what you mean. Maybe I'm just not experienced enough but I don't know what "print" means or what it does or why I need to use it. Could you explain it in more detail? Thank you!
 
@Il Knight hey man thanks for the response but I don't think I understand exactly what you mean. Maybe I'm just not experienced enough but I don't know what "print" means or what it does or why I need to use it. Could you explain it in more detail? Thank you!
the print function allows you to see in the console what value is passed to it.
Lua:
local a = "Hello"
print(a)
-- prints Hello to the server console
When you write scripts you will use print quite often to test specific values executing in the scripts.
If you want to test more than one value you would place a comma after the initial value.
Lua:
local a = "Hello"
local b = "World"
print(a, b)
-- prints Hello    World in the server console
 
Back
Top