• 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++ You lose x mana blocking an attack by (null).

115820

Member
Joined
Feb 27, 2011
Messages
193
Solutions
1
Reaction score
5
Location
London, England
In my server when player use UTAMO VITA, description attack :
  • You lose x mana blocking an attack by (null).

dont show player name attacker.
 
Why broken?

About the problem I had the problem befor too but I think ( unsure ) it was something in datapack xD
that damage string is handled in the source in combat.cpp
the source is broken because not everything was converted to uint64_t/int64_t, thats why people are having problems with that source that he linked
 
But the error is only in mana. When I attack to take life, it appears normally.
If I change the uint64_t / int64_t mana, can I fix this error?
i wasnt saying the problem is the mana values
its just an example of how the source you downloaded is broken
the damage string should be somewhere in combat.cpp
 
post the function at line 1791 in player.cpp
should look like this
C++:
void Player::drainMana(Creature* attacker, CombatType_t combatType, int64_t damage)
{
    Creature::drainMana(attacker, combatType, damage);
    char buffer[150];
    if(attacker)
        sprintf(buffer, "You lose %d mana blocking an attack by %s.", damage, attacker->getNameDescription().c_str());
    else
        sprintf(buffer, "You lose %d mana.", damage);

    sendStats();
    sendTextMessage(MSG_EVENT_DEFAULT, buffer);
}
 
Code:
void Player::drainMana(Creature* attacker, CombatType_t combatType, int64_t damage)
{
    Creature::drainMana(attacker, combatType, damage);
    char buffer[150];
    if(attacker)
        sprintf(buffer, "You lose %d mana blocking an attack by %s.", damage, attacker->getNameDescription().c_str());
    else
        sprintf(buffer, "You lose %d mana.", damage);

    sendStats();
    sendTextMessage(MSG_EVENT_DEFAULT, buffer);
}
 
is the attacker always (null)? even if you get hit by another player
attacker->getNameDescription().c_str() must return NULL for some reason
is this in your creature.h
C++:
virtual const std::string& getNameDescription() const = 0;
 
Last edited:
Code:
virtual const std::string& getName() const = 0;
        virtual const std::string& getNameDescription() const = 0;
        virtual std::string getDescription(int32_t lookDistance) const;
 
Back
Top