Skip to content
This repository has been archived by the owner on Oct 6, 2020. It is now read-only.

Commit

Permalink
fixed default_titles name colors
Browse files Browse the repository at this point in the history
  • Loading branch information
Riccardo H committed Jul 30, 2019
1 parent 83c01b3 commit 4381c12
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 6 deletions.
61 changes: 58 additions & 3 deletions addons/sourcemod/scripting/surftimer/hooks.sp
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,9 @@ public Action Say_Hook(int client, const char[] command, int argc)
WriteChatLog(client, "say", sText);
PrintToServer("%s: %s", szName, sText);

if (GetConVarBool(g_hPointSystem) && GetConVarBool(g_hColoredNames) && !g_bDbCustomTitleInUse[client])
Format(szName, sizeof(szName), "%s%s", g_pr_namecolour[client], szName);
else if (GetConVarBool(g_hPointSystem) && GetConVarBool(g_hColoredNames) && g_bDbCustomTitleInUse[client])
//if (GetConVarBool(g_hPointSystem) && GetConVarBool(g_hColoredNames) && !g_bDbCustomTitleInUse[client])
// Format(szName, sizeof(szName), "%s%s", g_pr_namecolour[client], szName);
if (GetConVarBool(g_hPointSystem) && GetConVarBool(g_hColoredNames) && g_bDbCustomTitleInUse[client])
setNameColor(szName, g_iCustomColours[client][0], 64);

if (GetConVarBool(g_hPointSystem) && GetConVarBool(g_hColoredNames) && g_bDbCustomTitleInUse[client] && g_bHasCustomTextColour[client])
Expand All @@ -487,6 +487,12 @@ public Action Say_Hook(int client, const char[] command, int argc)
{
char szChatRank[1024];
Format(szChatRank, 1024, "%s", g_pr_chat_coloredrank[client]);
char szChatRankColor[1024];
Format(szChatRankColor, 1024, "%s", g_pr_chat_coloredrank[client]);
CGetRankColor(szChatRankColor, 1024);

if (GetConVarBool(g_hPointSystem) && GetConVarBool(g_hColoredNames) && !g_bDbCustomTitleInUse[client])
Format(szName, sizeof(szName), "{%s}%s", szChatRankColor, szName);

if (GetConVarBool(g_hCountry) && (GetConVarBool(g_hPointSystem)))
{
Expand All @@ -512,6 +518,55 @@ public Action Say_Hook(int client, const char[] command, int argc)
return Plugin_Continue;
}

public void CGetRankColor(char[] sMsg, int iSize) // edit from CProcessVariables - colorvars
{
if (!Init()) {
return;
}

char[] sOut = new char[iSize]; char[] sCode = new char[iSize]; char[] sColor = new char[iSize];
int iOutPos = 0; int iCodePos = -1;
int iMsgLen = strlen(sMsg);
int dev = 0;

for (int i = 0; i < iMsgLen; i++) {
if (sMsg[i] == '{') {
iCodePos = 0;
}

if (iCodePos > -1) {
sCode[iCodePos] = sMsg[i];
sCode[iCodePos + 1] = '\0';

if (sMsg[i] == '}' || i == iMsgLen - 1) {
strcopy(sCode, strlen(sCode) - 1, sCode[1]);
StringToLower(sCode);

if (CGetColor(sCode, sColor, iSize)) {
if(dev == 1) break;
dev++;
} else {
Format(sOut, iSize, "%s{%s}", sOut, sCode);
iOutPos += strlen(sCode) + 2;
}

iCodePos = -1;
strcopy(sColor, iSize, "");
} else {
iCodePos++;
}

continue;
}

sOut[iOutPos] = sMsg[i];
iOutPos++;
sOut[iOutPos] = '\0';
}

strcopy(sMsg, iSize, sCode);
}

public Action Event_OnPlayerTeam(Handle event, const char[] name, bool dontBroadcast)
{
int client = GetClientOfUserId(GetEventInt(event, "userid"));
Expand Down
20 changes: 17 additions & 3 deletions addons/sourcemod/scripting/surftimer/misc.sp
Original file line number Diff line number Diff line change
Expand Up @@ -2640,15 +2640,21 @@ stock Action PrintSpecMessageAll(int client)
char szChatRank[64];
Format(szChatRank, 64, "%s", g_pr_chat_coloredrank[client]);

if (GetConVarBool(g_hPointSystem) && GetConVarBool(g_hColoredNames) && !g_bDbCustomTitleInUse[client])
Format(szName, sizeof(szName), "%s%s", g_pr_namecolour[client], szName);
else if (GetConVarBool(g_hPointSystem) && GetConVarBool(g_hColoredNames) && g_bDbCustomTitleInUse[client])
//if (GetConVarBool(g_hPointSystem) && GetConVarBool(g_hColoredNames) && !g_bDbCustomTitleInUse[client])
// Format(szName, sizeof(szName), "%s%s", g_pr_namecolour[client], szName);
if (GetConVarBool(g_hPointSystem) && GetConVarBool(g_hColoredNames) && g_bDbCustomTitleInUse[client])
setNameColor(szName, g_iCustomColours[client][0], 64);
// fluffys

if (g_bHasCustomTextColour[client])
setTextColor(szTextToAll, g_iCustomColours[client][1], 1024);

char szChatRankColor[1024];
Format(szChatRankColor, 1024, "%s", g_pr_chat_coloredrank[client]);
CGetRankColor(szChatRankColor, 1024);
if (GetConVarBool(g_hPointSystem) && GetConVarBool(g_hColoredNames) && !g_bDbCustomTitleInUse[client])
Format(szName, sizeof(szName), "{%s}%s", szChatRankColor, szName);

if (GetConVarBool(g_hCountry))
CPrintToChatAll("%t", "Misc20", g_szCountryCode[client], szChatRank, szName, szTextToAll);
else if (GetConVarBool(g_hPointSystem))
Expand All @@ -2657,6 +2663,10 @@ stock Action PrintSpecMessageAll(int client)
{
char szPlayerTitle2[256][2];
ExplodeString(szChatRank, "{blue}", szPlayerTitle2, 2, 256);
char szPlayerTitleColor[1024];
Format(szPlayerTitleColor, 1024, "%s", szPlayerTitle2[1]);
if (GetConVarBool(g_hPointSystem) && GetConVarBool(g_hColoredNames) && !g_bDbCustomTitleInUse[client])
Format(szName, sizeof(szName), "{%s}%s", szPlayerTitleColor, szName);
if (IsPlayerAlive(client))
CPrintToChatAll("%t", "Misc21", szPlayerTitle2[0], szPlayerTitle2[1], szName, szTextToAll);
else
Expand All @@ -2668,6 +2678,10 @@ stock Action PrintSpecMessageAll(int client)
{
char szPlayerTitle2[256][2];
ExplodeString(szChatRank, "{orange}", szPlayerTitle2, 2, 256);
char szPlayerTitleColor[1024];
Format(szPlayerTitleColor, 1024, "%s", szPlayerTitle2[1]);
if (GetConVarBool(g_hPointSystem) && GetConVarBool(g_hColoredNames) && !g_bDbCustomTitleInUse[client])
Format(szName, sizeof(szName), "{%s}%s", szPlayerTitleColor, szName);
if (IsPlayerAlive(client))
CPrintToChatAll("%t", "Misc23", szPlayerTitle2[0], szPlayerTitle2[1], szName, szTextToAll);
else
Expand Down

0 comments on commit 4381c12

Please sign in to comment.