http://otland.net/threads/jak-wysylac-hp-i-mane-w-procentach.181560/Did you get this working? if so any help?
Thank you =), Now I just need mana and hp limit changed to int64
ey,did u succesfully fix the hp/mana percent? if u did msg meYeah idk if it's because limits or what, but this works, but only works when the characters health is under a certain amount, which is pointless, point of using it is because players can't see their actual health.
Any idea how to make it take % of higher amounts?
nvm fixed it myself,but need hp / mana limitey,did u succesfully fix the hp/mana percent? if u did msg mehelp me
and i can send you some money
void ProtocolGame::AddPlayerStats(NetworkMessage_ptr msg)
{
msg->AddByte(0xA0);
msg->AddU16((uint16_t)std::ceil(player->getHealth() * 100 / player->getPlayerInfo(PLAYERINFO_MAXHEALTH)));
msg->AddU16((uint16_t)100);
msg->AddU32(uint32_t(player->getFreeCapacity() * 100));
uint64_t experience = player->getExperience();
if(experience > 0x7FFFFFFF) // client debugs after 2,147,483,647 exp
msg->AddU32(0x7FFFFFFF);
else
msg->AddU32(experience);
msg->AddU16(player->getPlayerInfo(PLAYERINFO_LEVEL));
msg->AddByte(player->getPlayerInfo(PLAYERINFO_LEVELPERCENT));
msg->AddU16((uint16_t)std::ceil(player->getMana() * 100 / player->getPlayerInfo(PLAYERINFO_MAXMANA)));
msg->AddU16((uint16_t)100);
msg->AddByte(player->getPlayerInfo(PLAYERINFO_MAGICLEVEL));
msg->AddByte(player->getPlayerInfo(PLAYERINFO_MAGICLEVELPERCENT));
msg->AddByte(player->getPlayerInfo(PLAYERINFO_SOUL));
msg->AddU16(player->getStaminaMinutes());
}
But what if player's max mana is equal to 0? You are dividing by 0 thenCode:void ProtocolGame::AddPlayerStats(NetworkMessage_ptr msg) { msg->AddByte(0xA0); msg->AddU16((uint16_t)std::ceil(player->getHealth() * 100 / player->getPlayerInfo(PLAYERINFO_MAXHEALTH))); msg->AddU16((uint16_t)100); msg->AddU32(uint32_t(player->getFreeCapacity() * 100)); uint64_t experience = player->getExperience(); if(experience > 0x7FFFFFFF) // client debugs after 2,147,483,647 exp msg->AddU32(0x7FFFFFFF); else msg->AddU32(experience); msg->AddU16(player->getPlayerInfo(PLAYERINFO_LEVEL)); msg->AddByte(player->getPlayerInfo(PLAYERINFO_LEVELPERCENT)); msg->AddU16((uint16_t)std::ceil(player->getMana() * 100 / player->getPlayerInfo(PLAYERINFO_MAXMANA))); msg->AddU16((uint16_t)100); msg->AddByte(player->getPlayerInfo(PLAYERINFO_MAGICLEVEL)); msg->AddByte(player->getPlayerInfo(PLAYERINFO_MAGICLEVELPERCENT)); msg->AddByte(player->getPlayerInfo(PLAYERINFO_SOUL)); msg->AddU16(player->getStaminaMinutes()); }