• 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++ hp/mana if i have 65535 i see procent 100

kaszanalubizryc

New Member
Joined
Sep 10, 2015
Messages
148
Reaction score
1
hello someone can help i want do
when i have health 0-65535 i see it
when i have more
65535 then i see 100 procent health

Code:
    msg.AddU16((uint16_t)std::floor((float)player->getHealth() * 100 / std::max(player->getPlayerInfo(PLAYERINFO_MAXHEALTH), 1)));
    msg.AddU16(100);
 
No, i'm guessing that's the percentage code?
Gimme the old code without percent aswell and i'll fit it for ya
Code:
void Protocol76::AddPlayerStats(NetworkMessage &msg,const Player *player)
{
    msg.AddByte(0xA0);
    msg.AddU16(player->getHealth());
    msg.AddU16((uint32_t)player->getPlayerInfo(PLAYERINFO_MAXHEALTH));
    msg.AddU16((uint16_t)std::floor(player->getFreeCapacity()));
 
Try this, wrote it on my phone omw home so don't expect any miracles
Code:
msg.AddU16(player->getHealth() < 65536 ? player->getHealth() : 100);
msg.AddU16(player->getHealth() < 65536 ? (uint32_t)player->getPlayerInfo(PLAYERINFO_MAXHEALTH) : 100);
 
Last edited:
Try this, wrote it on my phone omw home so don't expect any miracles
Code:
msg.AddU16(player->getHealth() < 65536 ? player->getHealth() & 100);
msg.AddU16(player->getHealth() < 65536 ? (uint32_t)player->getPlayerInfo(PLAYERINFO_MAXHEALTH) & 100);
error
Screen_Shot_11_04_15_at_07_39_PM.png
 
My bad, replace the & for a :, editing my code.
Replace the first 2 adU16 of the code u sent me, third one is for cap so leave that one be
it works! thanks you very much on mana i recopy the code and change just getMana etc PLAYERINFO_MAXMANA?
and last question if i die and my health drop to 65500
i back see 65500?
 
Yeah, same code but with getMana and such. And yeah, it's coded so if ur hp is less than 65536 it shows ur normal hp
it little change here i have else and if ;]
Code:
 if(player->getMana()>=65535)
        msg.AddU16(65535);
     else   
     msg.AddU16(player->getMana());
        if(player->getPlayerInfo(PLAYERINFO_MAXMANA)>=65535)
     msg.AddU16(65535);
     else
     msg.AddU16(player->getPlayerInfo(PLAYERINFO_MAXMANA));
can i remove and only
Code:
msg.AddU16(player->getMana) < 65536 ? player->getMana() : 100);
msg.AddU16(player->getMana() < 65536 ? (uint32_t)player->getPlayerInfo(PLAYERINFO_MAXMANA) : 100);
?
 
Yep,
Code:
return (player->getMana() < 65536 ? true : false);
Does the exact thing as
Code:
if(player->getMana() < 65536)
return true;
else
return false;
Would do, it's pretty much just a slimmed down if statement :3
 
Yep,
Code:
return (player->getMana() < 65536 ? true : false);
Does the exact thing as
Code:
if(player->getMana() < 65536)
return true;
else
return false;
Would do, it's pretty much just a slimmed down if statement :3
maybe this need to magic level? i give you full code

Code:
    msg.AddByte(player->getPlayerInfo(PLAYERINFO_LEVELPERCENT));
    if(player->getMana()>=65535)
       msg.AddU16(65535);
    else   
    msg.AddU16(player->getMana());
       if(player->getPlayerInfo(PLAYERINFO_MAXMANA)>=65535)
    msg.AddU16(65535);
    else
    msg.AddU16(player->getPlayerInfo(PLAYERINFO_MAXMANA));
    msg.AddByte(player->getMagicLevel());
    msg.AddByte(player->getPlayerInfo(PLAYERINFO_MAGICLEVELPERCENT));
    msg.AddByte(player->getPlayerInfo(PLAYERINFO_SOUL));
this no need to magic level?
here is msg.AddByte(player->getPlayerInfo(PLAYERINFO_LEVELPERCENT))
byte is 255 so is magic level maximum?
 
Back
Top