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

Mana Bar for others

jestem pro

That is the question
Joined
Apr 20, 2013
Messages
650
Solutions
14
Reaction score
87
Hello, I have the code from this forum for displaying mana bar under health.

But the problem is that the mana bar displays itself on "local player" so just everyone can see only own mana bar. I tried to do it displays mana bar to everyone can see it. And I gave up cause I don't have any ideas.
Lua:
void Creature::drawInformation(const Point& point, bool useGray, const Rect& parentRect, int drawFlags)
{
 
    if(m_healthPercent < 1) // creature is dead
        return;
    Color fillColor = Color(96, 96, 96);
    if(!useGray)
        fillColor = m_informationColor;
    // calculate main rects
    Rect backgroundRect = Rect(point.x-(13.5), point.y, 27, 4); //27 , 4
    backgroundRect.bind(parentRect);
    Size nameSize = m_nameCache.getTextSize();
    Rect textRect = Rect(point.x - nameSize.width() / 2.0, point.y -12, nameSize);
    textRect.bind(parentRect);
    // recalculate rects to draw manabar
    LocalPlayerPtr localPlayer;
    Rect manaBackgroundRect;
    if (isLocalPlayer()){
        backgroundRect.move(backgroundRect.x(), backgroundRect.y() - 4);
        textRect.move(textRect.x(), backgroundRect.y() - 12);
        manaBackgroundRect = Rect(backgroundRect.x(), backgroundRect.bottom()+ (1.7), 27, 4);
        localPlayer = g_game.getLocalPlayer();
    }
    // distance them
    if(textRect.top() == parentRect.top())
        backgroundRect.moveTop(textRect.top() + 12);
    if(backgroundRect.bottom() == parentRect.bottom())
        textRect.moveTop(backgroundRect.top() - 12);
    // health rect is based on background rect, so no worries
    Rect healthRect = backgroundRect.expanded(-1);
    healthRect.setWidth((m_healthPercent / 100.0) * 25);
    //create mana rect
    Rect manaRect;
    if (isLocalPlayer()){
        manaRect = manaBackgroundRect.expanded(-1);
        double manaPercent = ((localPlayer->getMana() * 100) / localPlayer->getMaxMana());
        manaRect.setWidth((manaPercent/ 100.0) * 25);
    }
    // draw
    if(g_game.getFeature(Otc::GameBlueNpcNameColor) && isNpc() && m_healthPercent == 100 && !useGray)
        fillColor = Color(0x66, 0xcc, 0xff);
    if(drawFlags & Otc::DrawBars && (!isNpc() || !g_game.getFeature(Otc::GameHideNpcNames))) {
        g_painter->setColor(Color::black);
        g_painter->drawFilledRect(backgroundRect);
        g_painter->setColor(fillColor);
        g_painter->drawFilledRect(healthRect);
        //draw mana bar
        if(isLocalPlayer()){
            g_painter->setColor(Color::black);
            g_painter->drawFilledRect(manaBackgroundRect);
            g_painter->setColor(Color::blue);
            g_painter->drawFilledRect(manaRect);
        }
    }
    if(drawFlags & Otc::DrawNames) {
        if(g_painter->getColor() != fillColor)
            g_painter->setColor(fillColor);
        m_nameCache.draw(textRect);
    }
    if(m_skull != Otc::SkullNone && m_skullTexture) {
        g_painter->setColor(Color::white);
        Rect skullRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 5, m_skullTexture->getSize());
        g_painter->drawTexturedRect(skullRect, m_skullTexture);
    }
    if(m_shield != Otc::ShieldNone && m_shieldTexture && m_showShieldTexture) {
        g_painter->setColor(Color::white);
        Rect shieldRect = Rect(backgroundRect.x() + 13.5, backgroundRect.y() + 5, m_shieldTexture->getSize());
        g_painter->drawTexturedRect(shieldRect, m_shieldTexture);
    }
    if(m_emblem != Otc::EmblemNone && m_emblemTexture) {
        g_painter->setColor(Color::white);
        Rect emblemRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 16, m_emblemTexture->getSize());
        g_painter->drawTexturedRect(emblemRect, m_emblemTexture);
    }
    if(m_icon != Otc::NpcIconNone && m_iconTexture) {
        g_painter->setColor(Color::white);
        Rect iconRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 5, m_iconTexture->getSize());
        g_painter->drawTexturedRect(iconRect, m_iconTexture);
    }
}
Lines of mana:
from 17 to 24
from 34 to 39
from 49 to 54

Could someone help me to change "localPlayer" to everyone can see mana bar?
Thanks
 
If I'm not mistaken you also have to change it on server sides since "I think" the server just sends your own not others
 
wow thanks . If it needs changes by server sides I dont touch to that.
 
sorry to revive the topic but which version would it be for? 8.54 or 8.6 old client
 
Back
Top