Jump to content

Recommended Posts

Posted

Hey there I've encountered a little problem when modifying the announce.

This is my code:

diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp
index b2529ae..2263f7d 100644
--- a/src/game/Level1.cpp
+++ b/src/game/Level1.cpp
@@ -128,7 +128,7 @@ bool ChatHandler::HandleAnnounceCommand(const char* args)
    if(!*args)
        return false;

-    sWorld.SendWorldText(LANG_SYSTEMMESSAGE,args);
+    sWorld.SendWorldText(LANG_SYSTEMMESSAGE, m_session->GetPlayerName(), args);
    return true;
}

I also change in database for new use of argument "%s announce %s".

But now when I try to announce from the console ( CLI ? I dont know ), the mangosd crash, I think its because he can't retrieve player name how can I make it use "CONSOLE" instead of "m_session->GetPlayerName()" ? :confused:

Thanks in advance and excuse me my noobish question I'm new with this.

Posted

I don't think that's the problem since WorldSession::GetPlayerName() is defined like this:

char const* WorldSession::GetPlayerName() const
{
   return GetPlayer() ? GetPlayer()->GetName() : "<none>";
}

If I'm not mistaken the problem is the m_session that is null for the console.

Try this:

diff --git a/src/game/Level1.cpp b/src/game/Level1.cpp
index b2529ae..2263f7d 100644
--- a/src/game/Level1.cpp
+++ b/src/game/Level1.cpp
@@ -128,7 +128,7 @@ bool ChatHandler::HandleAnnounceCommand(const char* args)
    if(!*args)
        return false;

-    sWorld.SendWorldText(LANG_SYSTEMMESSAGE,args);
+    sWorld.SendWorldText(LANG_SYSTEMMESSAGE, m_session ? m_session->GetPlayerName() : "CONSOLE", args);
    return true;
}

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use