Skip to content

Commit

Permalink
Version 1.3.0 for the latest csgo update
Browse files Browse the repository at this point in the history
  • Loading branch information
Franc1sco committed Apr 27, 2022
1 parent 55a5346 commit ffe767e
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 69 deletions.
Binary file modified FixHintColorMessages.smx
Binary file not shown.
111 changes: 42 additions & 69 deletions FixHintColorMessages.sp
@@ -1,54 +1,38 @@
UserMsg g_TextMsg, g_HintText, g_KeyHintText;

static char g_sSpace[2048];

public Plugin myinfo =
{
name = "Fix Hint Color Messages",
description = "Fix for PrintHintText and PrintCenterText colors msgs in csgo",
author = "Phoenix (˙·٠●Феникс●٠·˙)",
version = "1.2.2 Franc1sco franug github version",
version = "1.3.0 Franc1sco franug github version",
url = "https://github.com/Franc1sco/FixHintColorMessages"
};

public void OnPluginStart()
{
for(int i = 0; i < sizeof g_sSpace - 1; i++)
{
g_sSpace[i] = ' ';
}

g_TextMsg = GetUserMessageId("TextMsg");
g_HintText = GetUserMessageId("HintText");
g_KeyHintText = GetUserMessageId("KeyHintText");
g_HintText = GetUserMessageId("HintText");

HookUserMessage(g_TextMsg, TextMsgHintTextHook, true);
HookUserMessage(g_HintText, TextMsgHintTextHook, true);
HookUserMessage(g_KeyHintText, TextMsgHintTextHook, true);
HookUserMessage(g_KeyHintText, HintTextHook, true)
HookUserMessage(g_HintText, HintTextHook, true);
}

Action TextMsgHintTextHook(UserMsg msg_id, Protobuf msg, const int[] players, int playersNum, bool reliable, bool init)
Action HintTextHook(UserMsg msg_id, Protobuf msg, const int[] players, int playersNum, bool reliable, bool init)
{
static char sBuf[sizeof g_sSpace];
char szBuf[2048];

if(msg_id == g_HintText)
{
msg.ReadString("text", sBuf, sizeof sBuf);
}
else if(msg_id == g_KeyHintText)
{
msg.ReadString("hints", sBuf, sizeof sBuf, 0);
}
else if(msg.ReadInt("msg_dst") == 4)
if(msg_id == g_KeyHintText)
{
msg.ReadString("params", sBuf, sizeof sBuf, 0);
msg.ReadString("hints", szBuf, sizeof szBuf, 0);
}
else
{
return Plugin_Continue;
msg.ReadString("text", szBuf, sizeof szBuf);
}
if(StrContains(sBuf, "<font") != -1 || StrContains(sBuf, "<span") != -1) // only hook msg with colored tags

if(StrContains(szBuf, "</") != -1)
{
DataPack hPack = new DataPack();

Expand All @@ -59,68 +43,57 @@ Action TextMsgHintTextHook(UserMsg msg_id, Protobuf msg, const int[] players, in
hPack.WriteCell(players[i]);
}

hPack.WriteString(sBuf);
hPack.WriteString(szBuf);

hPack.Reset();

RequestFrame(TextMsgFix, hPack);
RequestFrame(HintTextFix, hPack);

return Plugin_Handled;
}

return Plugin_Continue;
}

void TextMsgFix(DataPack hPack)
void HintTextFix(DataPack hPack)
{
int iCount = hPack.ReadCell();
int iCountNew = 0, iCountOld = hPack.ReadCell();

static int iPlayers[MAXPLAYERS+1];
int iPlayers[MAXPLAYERS+1];

for(int i = 0; i < iCount; i++)
for(int i = 0, iPlayer; i < iCountOld; i++)
{
iPlayers[i] = hPack.ReadCell();
}

int[] newClients = new int[MaxClients];
int newTotal = 0;

for (int i = 0; i < iCount; i++) {
int client = iPlayers[i];

if (IsClientInGame(client)) {

newClients[newTotal] = client;
newTotal++;
iPlayer = hPack.ReadCell();

if(IsClientInGame(iPlayer))
{
iPlayers[iCountNew++] = iPlayer;
}
}

if (newTotal == 0) {
delete hPack;
return;
}

static char sBuf[sizeof g_sSpace];

hPack.ReadString(sBuf, sizeof sBuf);

delete hPack;

Protobuf hMessage = view_as<Protobuf>(StartMessageEx(g_TextMsg, newClients, newTotal, USERMSG_RELIABLE|USERMSG_BLOCKHOOKS));

if(hMessage)
if(iCountNew != 0)
{
hMessage.SetInt("msg_dst", 4);
hMessage.AddString("params", "#SFUI_ContractKillStart");
char szBuf[2048];

Format(sBuf, sizeof sBuf, "</font>%s%s", sBuf, g_sSpace);
hMessage.AddString("params", sBuf);
hPack.ReadString(szBuf, sizeof szBuf);

hMessage.AddString("params", NULL_STRING);
hMessage.AddString("params", NULL_STRING);
hMessage.AddString("params", NULL_STRING);
hMessage.AddString("params", NULL_STRING);
Protobuf hMessage = view_as<Protobuf>(StartMessageEx(g_TextMsg, iPlayers, iCountNew, USERMSG_RELIABLE|USERMSG_BLOCKHOOKS));

EndMessage();
if(hMessage)
{
hMessage.SetInt("msg_dst", 4);
hMessage.AddString("params", "#SFUI_ContractKillStart");

Format(szBuf, sizeof szBuf, "</font>%s<script>", szBuf);
hMessage.AddString("params", szBuf);

hMessage.AddString("params", NULL_STRING);
hMessage.AddString("params", NULL_STRING);
hMessage.AddString("params", NULL_STRING);

EndMessage();
}
}

hPack.Close();
}

0 comments on commit ffe767e

Please sign in to comment.