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

C++ HEALTH/MANA percent error with much life

dervin13

Active Member
Joined
Apr 26, 2008
Messages
458
Solutions
1
Reaction score
28
Hello, I use the code of health percent but after something about 23kk of life this stop to show 100 percent and shows the number 65445

C++:
    if (player->getMaxHealth() > 0)
    {
        msg.add<uint16_t>(std::min<int32_t>(player->getHealth() * 100 / player->getMaxHealth(), std::numeric_limits<uint16_t>::max()));
        msg.add<uint16_t>(100);
    }
    else
    {
        msg.add<uint16_t>(0);
        msg.add<uint16_t>(0);
    }

Is it possible to solve?
thanks

Update:

Solved

int32 has an maxvalue, changed gethealth to int64 in protocolgame.cpp, creature.h and player.h

will check for erros now
 
Last edited:
Back
Top