Skip to content
Permalink
Browse files

Fix #1223: Regression: double chat messages if player is in team (#1241)

  • Loading branch information
StrixG committed Jan 31, 2020
1 parent 19eb2e6 commit a5508d8cead013a0b08e9c2cddb5914e46be1abd
@@ -9970,29 +9970,15 @@ bool CStaticFunctionDefinitions::OutputChatBox(const char* szText, CElement* pEl
{
assert(pElement);
assert(szText);

RUN_CHILDREN(OutputChatBox(szText, *iter, ucRed, ucGreen, ucBlue, bColorCoded, pLuaMain))

if (IS_PLAYER(pElement))
{
CPlayer* pPlayer = static_cast<CPlayer*>(pElement);
pPlayer->Send(CChatEchoPacket(szText, ucRed, ucGreen, ucBlue, bColorCoded));
return true;
}
else if (IS_TEAM(pElement))
{
CTeam* pTeam = static_cast<CTeam*>(pElement);
list<CPlayer*>::const_iterator iter = pTeam->PlayersBegin();
for (; iter != pTeam->PlayersEnd(); iter++)
{
CPlayer* pPlayer = *iter;
pPlayer->Send(CChatEchoPacket(szText, ucRed, ucGreen, ucBlue, bColorCoded));
}
return true;
}
else
{
// Fixes issue 1223: https://github.com/multitheftauto/mtasa-blue/issues/1223 (Luxy.c)
RUN_CHILDREN(OutputChatBox(szText, *iter, ucRed, ucGreen, ucBlue, bColorCoded, pLuaMain))
}

if (pElement == m_pMapManager->GetRootElement())
{
@@ -83,11 +83,23 @@ int CLuaFunctionDefs::OutputChatBox(lua_State* luaVM)
{
if (pElement)
{
CStaticFunctionDefinitions::OutputChatBox((const char*)ssChat, pElement, ucRed, ucGreen, ucBlue, bColorCoded, pLuaMain);
lua_pushboolean(luaVM, true);
return 1;
if (IS_TEAM(pElement))
{
CTeam* pTeam = static_cast<CTeam*>(pElement);
for (auto iter = pTeam->PlayersBegin(); iter != pTeam->PlayersEnd(); iter++)
{
sendList.push_back(*iter);
}
}
else
{
CStaticFunctionDefinitions::OutputChatBox((const char*)ssChat, pElement, ucRed, ucGreen, ucBlue, bColorCoded, pLuaMain);
lua_pushboolean(luaVM, true);
return 1;
}
}
else if (sendList.size() > 0)

if (sendList.size() > 0)
{
CStaticFunctionDefinitions::OutputChatBox((const char*)ssChat, sendList, ucRed, ucGreen, ucBlue, bColorCoded);
lua_pushboolean(luaVM, true);

0 comments on commit a5508d8

Please sign in to comment.
You can’t perform that action at this time.