Hi, i got these codes from the other forum and it's really helpful when you do announcement or shout outs ingame.
Basically it's a system to Announce a certain announcement ingame with a scrolling text. Here's a screenshot from the coder itself Mr. Avalion all credits go to him.
I have added it successfully using the upgraded v15 source code (VISUAL STUDIO 2017) and it worked. Now the problem is there are people who are using the Visual studio 2003 and i'm also using the 2003 source so what i want is maybe you (Anyone) can revise this code and make it work in Visual studio 2003?
Enjoy and hope to hear from you.
Thanks a lot in advance.
WndWorld.cpp
messagePos = g_Option.m_nResWidth;
if (!prj.srvrMessages.empty())
{
std:

air<bool, std::string>* tmp = &prj.srvrMessages.front();
if (!tmp->second.empty())
{
CRect rect(0, -1, g_Option.m_nResWidth, 22);
p2DRender->RenderFillRect(rect, 0xAA2E2E2E);
messagePos -= 2;
p2DRender->TextOut(messagePos, 3, tmp->second.c_str(), 0xEEffffff);
if (messagePos <= 0)
{
if (messagePos + p2DRender->m_pFont->GetTextExtent(tmp->second.c_str()).cx <= static_cast<int>(g_Option.m_nResWidth / 16.0f))
{
messagePos = g_Option.m_nResWidth;
if (tmp->first) { prj.srvrMessages.push_back(*tmp); }
prj.srvrMessages.pop_front();
}
}
}
else { prj.srvrMessages.pop_front(); }
}
CObj *pFocus = pWorld->GetObjFocus();
WndWorld.h
Project.cpp
Add to File:
#ifdef __WORLDSERVER
#include <fstream>
void CProject::loadServerMessages()
{
std::ifstream ifs("ServerMessages.inc", std::ios::in | std::ios::binary);
if (ifs.is_open())
{
std::string tmp;
while (std::getline(ifs, tmp))
{
if (tmp.empty()) { continue; }
srvrMessages.push_back({ true, tmp });
}
}
}
#endif
CProject::OpenProject
#ifdef __WORLDSERVER
loadServerMessages();
#endif
Project.h
#ifdef __WORLDSERVER
void loadServerMessages();
#endif
std::deque<std:

air<bool, std::string>> srvrMessages;
FuncTextCmd.cpp
You'll have to modify this to how your source is
Add To File
bool TextCmd_ServerMessages(CScanner &s)
{
#ifdef __WORLDSERVER
CUser* pUser = (CUser*)s.dwValue;
if (!IsValidObj(pUser)) { return false; }
switch (s.GetNumber())
{
case 0:
prj.srvrMessages.clear();
prj.loadServerMessages();
prj.srvrMessages.shrink_to_fit();
g_UserMng.sendServerMessages(0);
return true;
case 1:
s.GetToken();
if (s.tokenType == NUMBER)
{
try
{
bool bTmp = static_cast<bool>(std::stoi(s.token));
s.GetToken();
prj.srvrMessages.push_back({ static_cast<bool>(bTmp), s.token });
}
catch (const std::exception & e)
{
s.GetToken();
prj.srvrMessages.push_back({ true, s.token });
}
}
else{ prj.srvrMessages.push_back({ true, s.token }); }
g_UserMng.sendServerMessages(1);
return true;
case 2:
prj.srvrMessages.clear();
prj.srvrMessages.shrink_to_fit();
g_UserMng.sendServerMessages(2);
return true;
default:
pUser->AddText("tpyes: 0 = reload. \n1 + message = append. 2 = clear");
return true;
}
#else
return true;
#endif
}
OnTextCmdFunc Part
ON_TEXTCMDFUNC(TextCmd_ServerMessages, "srvrMessage", "smes", TCM_BOTH, AUTH_ADMINISTRATOR)
dpClient.cpp (neuz)
Add to File
void CDPClient:

nServerMessages(CAr &ar)
{
int type, size;
std::string tmp;
bool noRepeat = false;
ar >> type;
switch (type)
{
case 0:
ar >> size;
prj.srvrMessages.clear();
for (int i = 0; i < size; ++i)
{
ar.ReadString(tmp);
prj.srvrMessages.push_back({ true, std::move(tmp)});
}
prj.srvrMessages.shrink_to_fit();
break;
case 1:
ar >> noRepeat;
ar.ReadString(tmp);
prj.srvrMessages.push_back({ noRepeat, tmp });
break;
case 2:
prj.srvrMessages.clear();
prj.srvrMessages.shrink_to_fit();
break;
default:
break;
}
}
Snapshot area:
case SNAPSHOTTYPE_SERVERMESSAGES: onServerMessages(ar); break;
User.cpp (WorldServer)
Add to File
void CUser::sendServerMessages(int type, bool noRepeat)
{
m_Snapshot.cb++;
m_Snapshot.ar << GetId() << SNAPSHOTTYPE_SERVERMESSAGES << type;
switch (type)
{
case 0:
m_Snapshot.ar << static_cast<unsigned int>(prj.srvrMessages.size());
for (std::deque<std:

air<bool, std::string>>::const_iterator it = prj.srvrMessages.begin(); it != prj.srvrMessages.end(); ++it)
{
m_Snapshot.ar.WriteString(it->second.c_str());
}
break;
case 1:
m_Snapshot.ar << prj.srvrMessages.rbegin()->first;
m_Snapshot.ar.WriteString(prj.srvrMessages.rbegin( )->second.c_str());
break;
case 2: break;
default: break;
}
}
void CUserMng::sendServerMessages(int type, bool noRepeat)
{
for (std::map<unsigned long, CUser*>::const_iterator it = m_users.begin(); it != m_users.end(); ++it)
{
it->second->sendServerMessages(type, noRepeat);
}
}
User.h (WorldServer)
in class CUser
void sendServerMessages(int type, bool noRepeat = false);
in class CUserMng
void sendServerMessages(int type = 0, bool noRepeat = false);
ar.h
class Ar
in file anywhere after class Ar
inline CAr& CAr:

perator<<(bool b)
{
CheckBuf(sizeof(bool));
*reinterpret_cast<bool*>(m_lpBufCur) = b; m_lpBufCur += sizeof(bool); return *this;
}
inline CAr& CAr:

perator>>(bool& b)
{
if (m_lpBufCur + sizeof(bool) <= m_lpBufMax)
{
b = *reinterpret_cast<bool*>(m_lpBufCur);
m_lpBufCur += sizeof(bool);
}
else
{
b = static_cast<bool>(0);
m_lpBufCur = m_lpBufMax;
}
return *this;
}