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

vitorelias1

New Member
Joined
Sep 27, 2022
Messages
27
Reaction score
2
In this case, I wanted to put it while the player does not reach 65535 life and mana, his life and mana are not in %, it would remain standard there when he reaches 65535 life there it would be in % 100 the same thing for mana in theory it worked when caught a character that has 65535 he is 100% the same for mana, now if I take a low level character he is literally 0 life and mana.

i'm sorry inglish bad google translate

if (player->getPlayerInfo(PLAYERINFO_MAXMANA) -> 65535)
{
msg->put<uint16_t>(player->getPlayerInfo(PLAYERINFO_MANA) * 100 / player->getPlayerInfo(PLAYERINFO_MAXMANA));
msg->put<uint16_t>(100);
}
else
{
msg->put<uint16_t>(0);
msg->put<uint16_t>(0);
}


1681249444106.png
 
1) Use
1681257959137.png
2) Specify which tfs you have
3) add if player->getMaxHealth() > 0
Lua:
    if (player->getMaxHealth()) > 65535 {
        if (player->getMaxMana() > 0)
        {
            msg.add<uint16_t>(std::min<int32_t>(player->getMana() * 100 / player->getMaxMana(), std::numeric_limits<uint16_t>::max()));
            msg.add<uint16_t>(100);
        }
        else
        {
            msg.add<uint16_t>(0);
            msg.add<uint16_t>(0);
        }
    }
    else
    {
        msg.add<uint16_t>(std::min<int32_t>(player->getMana(), std::numeric_limits<uint16_t>::max()));
        msg.add<uint16_t>(std::min<int32_t>(player->getMaxMana(), std::numeric_limits<uint16_t>::max()));


    }
i don't know what tfs you have but +1.X should work
use your functions
4) an operator is missing here greater than
Lua:
if (player->getPlayerInfo(PLAYERINFO_MAXMANA) -> 65535)
 
Last edited:
1) Use
Code:
[CODE=lua]
[/CODE]
2) Specify which tfs you have
3) add if
I don't know what tfs you have but +1.X should work
Lua:
    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);
        }
i don't know what tfs you have but +1.X should work
use your functions
bro

I use The Forgotten Server, version 0.4_SVN () I'll post some pictures to make it better.
In this photo below the char is level 43 I wanted it to show the real life he has I used the command !life he has 360 the idea is when he has 65535 life he is 100% stay in percentage the same thing.
Now I'm going to send another photo of another character that has more than 65535 life and mana, that's right, it's in %.

that is, the player will only have life in % only after he reaches 65535 life and mana, I don't know if I was able to express myself correctly


1681258260378.png

1681258499473.png
 
bro

I use The Forgotten Server, version 0.4_SVN () I'll post some pictures to make it better.
In this photo below the char is level 43 I wanted it to show the real life he has I used the command !life he has 360 the idea is when he has 65535 life he is 100% stay in percentage the same thing.
Now I'm going to send another photo of another character that has more than 65535 life and mana, that's right, it's in %.

that is, the player will only have life in % only after he reaches 65535 life and mana, I don't know if I was able to express myself correctly


View attachment 74736

View attachment 74739



C++:
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));
 
}
 
C++:
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));
 
}
thank youuu bro!!!
 
Back
Top