Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement SCP support #90

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 46 additions & 10 deletions addons/sourcemod/scripting/hextags.sp
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,31 @@
* You should have received a copy of the GNU General Public License along with
* this program. If not, see <http://www.gnu.org/licenses/>.
*/

#pragma semicolon 1
#pragma newdecls required


#include <sourcemod>
#include <sdktools>
#include <chat-processor>



#include <geoip>
#include <hexstocks>
#include <logger>
#include <hextags>
#include <clientprefs>
#include <colorlib>

#undef REQUIRE_EXTENSIONS
#undef REQUIRE_PLUGIN
#include <scp>

#undef MAXLENGTH_NAME
#undef MAXLENGTH_MESSAGE

#include <chat-processor>

#include <mostactive>
#include <cstrike>
#include <kento_rankme/rankme>
Expand All @@ -40,11 +54,12 @@
#define REQUIRE_EXTENSIONS
#define REQUIRE_PLUGIN

#include <hextags>


#define PLUGIN_AUTHOR "Hexah"
#define PLUGIN_VERSION "<VERSION>"

#pragma semicolon 1
#pragma newdecls required


// EVENTS
Expand Down Expand Up @@ -168,7 +183,6 @@ public void OnPluginStart()
hSelTagCookie = RegClientCookie("HexTags_SelectedTag", "Selected Tag", CookieAccess_Private);
hVibilityAdminsCookie = RegClientCookie("HexTags_Visibility_Admins", "Show or hide the admin tags.", CookieAccess_Private);
hIsAnonymousCookie = RegClientCookie("HexTags_AnonymousCookie", "Plugin that defines wether or not an admin is anonymous.", CookieAccess_Protected);

}

public void OnConfigsExecuted() {
Expand Down Expand Up @@ -200,7 +214,10 @@ public void ConVar_ForceTimerHook(ConVar convar, const char[] oldValue, const ch
public void OnAllPluginsLoaded()
{
logger.debug("Called OnAllPlugins!");


// if (!LibraryExists("scp") && !LibraryExists("chat-processor"))
// SetFailState("[HexTags] Either chat-processor or Simple Chat Processor is required to run this plugin.");

if (FindPluginByFile("custom-chatcolors-cp.smx") || LibraryExists("ccc"))
LogMessage("[HexTags] Found Custom Chat Colors running!\n Please avoid running it with this plugin!");

Expand Down Expand Up @@ -547,7 +564,19 @@ public void warden_OnDeputyRemoved(int client)
RequestFrame(Frame_LoadTag, client);
}

public Action CP_OnChatMessage(int & author, ArrayList recipients, char[] flagstring, char[] name, char[] message, bool & processcolors, bool & removecolors)
public Action CP_OnChatMessage(int &author, ArrayList recipients, char[] flagstring, char[] name, char[] message, bool &processcolors, bool &removecolors)
{
return OnChatMessageEx(author, name, message, processcolors, removecolors, false);
}

public Action OnChatMessage(int &author, ArrayList recipients, char[] name, char[] message)
{
bool dummy;
return OnChatMessageEx(author, name, message, dummy, dummy, true);
}


public Action OnChatMessageEx(int& author, char[] name, char[] message, bool& processcolors, bool& removecolors, bool processvariables)
{
if (bHideTag[author])
{
Expand Down Expand Up @@ -593,7 +622,7 @@ public Action CP_OnChatMessage(int & author, ArrayList recipients, char[] flagst
if (IsCharMB(name[i]))
i += bytes - 2;
}
Format(sNewName, MAXLENGTH_NAME, "%s%s{default}", selectedTags[author].ChatTag, sTemp);
Format(sNewName, MAXLENGTH_NAME, " %s%s", selectedTags[author].ChatTag, sTemp);
}
else if (StrEqual(selectedTags[author].NameColor, "{random}")) //Random name
{
Expand All @@ -616,12 +645,12 @@ public Action CP_OnChatMessage(int & author, ArrayList recipients, char[] flagst
if (IsCharMB(name[i]))
i += bytes - 2;
}
Format(sNewName, MAXLENGTH_NAME, "%s%s{default}", selectedTags[author].ChatTag, sTemp);
Format(sNewName, MAXLENGTH_NAME, " %s%s", selectedTags[author].ChatTag, sTemp);
}
else
{
logger.debug("Default name");
Format(sNewName, MAXLENGTH_NAME, "%s%s%s{default}", selectedTags[author].ChatTag, selectedTags[author].NameColor, name);
Format(sNewName, MAXLENGTH_NAME, " %s%s%s", selectedTags[author].ChatTag, selectedTags[author].NameColor, name); // The first color won't work if there is not a space at the beginning
}
Format(sNewMessage, MAXLENGTH_MESSAGE, "%s%s", selectedTags[author].ChatColor, message);

Expand Down Expand Up @@ -749,6 +778,13 @@ public Action CP_OnChatMessage(int & author, ArrayList recipients, char[] flagst

processcolors = true;
removecolors = false;

if (processvariables)
{
logger.debug("Message: %s --- %s", name, message);
CFormat(name, MAXLENGTH_NAME);
CFormat(message, MAXLENGTH_MESSAGE);
}

//Call the (post)forward
Call_StartForward(fMessageProcessed);
Expand Down
Loading