• 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++ life and mana by %

felp

New Member
Joined
May 30, 2023
Messages
8
Reaction score
1
hy guys i have this codigo what, makes life is mana stay for %

if (player->getPlayerInfo(PLAYERINFO_MAXHEALTH)) > 65535 {

if (player->getPlayerInfo(PLAYERINFO_MAXHEALTH) > 0)
{
msg->put<uint16_t>(uint16_t(player->getHealth() * 100 / player->getPlayerInfo(PLAYERINFO_MAXHEALTH)));
msg->put<uint16_t>(100);
}
else
{
msg->put<uint16_t>(0);
msg->put<uint16_t>(0);
}

} else {

msg->put<uint16_t>(player->getHealth());
msg->put<uint16_t>(player->getPlayerInfo(PLAYERINFO_MAXHEALTH));

}

on my 8.6 server it works perfectly
the player's life is only in % when the player reaches life 65535 the same thing for mana i wanted to make this change in tfs 1.4 my server version is 12.70

I already got for life and mana for % with this code below but I wanted to modify the same serial code above as possible?


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);
    }
 
Back
Top