Skip to content

Commit

Permalink
Fixed {purple} in CS:GO
Browse files Browse the repository at this point in the history
  • Loading branch information
ErikMinekus committed Mar 23, 2016
1 parent fcc0296 commit d29919a
Showing 1 changed file with 11 additions and 5 deletions.
16 changes: 11 additions & 5 deletions addons/sourcemod/scripting/advertisements.sp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
#pragma newdecls required
#pragma semicolon 1

#define PL_VERSION "2.0.1"
#define PL_VERSION "2.0.2"
#define UPDATE_URL "http://ErikMinekus.github.io/sm-advertisements/update.txt"

public Plugin myinfo =
Expand All @@ -23,7 +23,6 @@ public Plugin myinfo =
/**
* Globals
*/
bool g_bSayText2;
KeyValues g_hAdvertisements;
ConVar g_hEnabled;
ConVar g_hFile;
Expand All @@ -41,14 +40,13 @@ public void OnPluginStart()
g_hFile = CreateConVar("sm_advertisements_file", "advertisements.txt", "File to read the advertisements from.");
g_hInterval = CreateConVar("sm_advertisements_interval", "30", "Amount of seconds between advertisements.");

g_hFile.AddChangeHook(ConVarChange_File);
g_hInterval.AddChangeHook(ConVarChange_Interval);

RegServerCmd("sm_advertisements_reload", Command_ReloadAds, "Reload the advertisements");

AddTopColors();

g_bSayText2 = (GetUserMessageId("SayText2") != INVALID_MESSAGE_ID);

if (LibraryExists("updater")) {
Updater_AddPlugin(UPDATE_URL);
}
Expand All @@ -68,6 +66,11 @@ public void OnLibraryAdded(const char[] name)
}
}

public void ConVarChange_File(ConVar convar, const char[] oldValue, const char[] newValue)
{
ParseAds();
}

public void ConVarChange_Interval(ConVar convar, const char[] oldValue, const char[] newValue)
{
if (g_hTimer) {
Expand Down Expand Up @@ -162,14 +165,17 @@ public Action Timer_DisplayAd(Handle timer)
delete hPl;
}
if (sChat[0]) {
bool bTeamColor = StrContains(sChat, "{teamcolor}", false) != -1;

ProcessVariables(sChat);
CProcessVariables(sChat, sizeof(sChat));
CAddWhiteSpace(sChat, sizeof(sChat));

for (int i = 1; i <= MaxClients; i++) {
if (IsClientInGame(i) && !IsFakeClient(i) &&
((!bAdmins && !(bFlags && (GetUserFlagBits(i) & (iFlags|ADMFLAG_ROOT)))) ||
(bAdmins && (GetUserFlagBits(i) & (ADMFLAG_GENERIC|ADMFLAG_ROOT))))) {
if (g_bSayText2) {
if (bTeamColor) {
CSayText2(i, sChat, i);
} else {
PrintToChat(i, sChat);
Expand Down

0 comments on commit d29919a

Please sign in to comment.