mirror of
https://github.com/shavitush/bhoptimer.git
synced 2025-12-15 18:18:44 +00:00
handle chat gags
This commit is contained in:
parent
3daa4187f1
commit
299fb91bc6
@ -145,7 +145,8 @@ Web Interface
|
||||
Chat **(NEW!)**
|
||||
--
|
||||
- [x] Add logic that processes chat without requiring an external plugin such as `Simple Chat Processor (Redux)`.
|
||||
- [ ] Custom chat titles/colors for rank ranges. (will require shavit-rankings)
|
||||
- [ ] Custom chat titles/colors for rank ranges.
|
||||
- [ ] Add `sm_ranks` `sm_chatranks`
|
||||
- [ ] Custom chat titles/colors per individual player.
|
||||
- [ ] Add `Shavit_FormatChat` native
|
||||
- [ ] Optional - add server/player local time to chat message.
|
||||
|
||||
@ -22,12 +22,20 @@
|
||||
#include <cstrike>
|
||||
#include <shavit>
|
||||
|
||||
#undef REQUIRE_PLUGIN
|
||||
#include <basecomm>
|
||||
|
||||
#pragma newdecls required
|
||||
#pragma semicolon 1
|
||||
#pragma dynamic 131072
|
||||
|
||||
// cache
|
||||
float gF_LastMessage[MAXPLAYERS+1];
|
||||
|
||||
// modules
|
||||
bool gB_BaseComm = false;
|
||||
|
||||
// game-related
|
||||
ServerGame gSG_Type = Game_Unknown;
|
||||
|
||||
public Plugin myinfo =
|
||||
@ -48,6 +56,10 @@ public void OnAllPluginsLoaded()
|
||||
|
||||
// placed here and not in OnPluginStart() as `chat` is coming before `core` if sorted alphabetically
|
||||
gSG_Type = Shavit_GetGameType();
|
||||
|
||||
// modules
|
||||
gB_BaseComm = LibraryExists("basecomm");
|
||||
MarkNativeAsOptional("BaseComm_IsClientGagged");
|
||||
}
|
||||
|
||||
public void OnPluginStart()
|
||||
@ -65,6 +77,11 @@ public void OnClientPutInServer(int client)
|
||||
|
||||
public Action OnClientSayCommand(int client, const char[] command, const char[] sArgs)
|
||||
{
|
||||
if(gB_BaseComm && BaseComm_IsClientGagged(client))
|
||||
{
|
||||
return Plugin_Continue;
|
||||
}
|
||||
|
||||
if(GetEngineTime() - gF_LastMessage[client] < 0.70)
|
||||
{
|
||||
return Plugin_Handled;
|
||||
@ -75,12 +92,14 @@ public Action OnClientSayCommand(int client, const char[] command, const char[]
|
||||
bool bTeam = StrEqual(command, "say_team");
|
||||
int iTeam = GetClientTeam(client);
|
||||
|
||||
char[] sMessage = new char[255];
|
||||
FormatChat(client, sArgs, IsPlayerAlive(client), iTeam, bTeam, sMessage, 255);
|
||||
char[] sMessage = new char[300];
|
||||
FormatChat(client, sArgs, IsPlayerAlive(client), iTeam, bTeam, sMessage, 300);
|
||||
|
||||
int[] clients = new int[MaxClients];
|
||||
int count = 0;
|
||||
|
||||
PrintToServer("%N: %s", client, sArgs);
|
||||
|
||||
for(int i = 1; i <= MaxClients; i++)
|
||||
{
|
||||
if(IsValidClient(i))
|
||||
@ -88,6 +107,8 @@ public Action OnClientSayCommand(int client, const char[] command, const char[]
|
||||
if(GetClientTeam(i) == iTeam || !bTeam)
|
||||
{
|
||||
clients[count++] = i;
|
||||
|
||||
PrintToConsole(i, "%N: %s", client, sArgs);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -130,7 +151,7 @@ public void FormatChat(int client, const char[] sMessage, bool bAlive, int iTeam
|
||||
}
|
||||
}
|
||||
|
||||
FormatEx(buffer, maxlen, "\x03%s%s %N :\x01 %s", (bAlive || iTeam == CS_TEAM_SPECTATOR)? "":"*DEAD*", sTeam, client, sMessage);
|
||||
FormatEx(buffer, maxlen, " \x03%s%s %N :\x01 %s", Shavit_GetRank(client), (bAlive || iTeam == CS_TEAM_SPECTATOR)? "":"*DEAD*", sTeam, client, sMessage);
|
||||
}
|
||||
|
||||
public void ChatMessage(int from, int[] clients, int count, const char[] sMessage)
|
||||
|
||||
@ -62,6 +62,8 @@ public void OnAllPluginsLoaded()
|
||||
{
|
||||
SetFailState("shavit-wr is required for the plugin to work.");
|
||||
}
|
||||
|
||||
gB_Rankings = LibraryExists("shavit-rankings");
|
||||
}
|
||||
|
||||
public void OnPluginStart()
|
||||
@ -73,9 +75,6 @@ public void OnPluginStart()
|
||||
// translations
|
||||
LoadTranslations("common.phrases");
|
||||
|
||||
// modules
|
||||
gB_Rankings = LibraryExists("shavit-rankings");
|
||||
|
||||
// database connections
|
||||
Shavit_GetDB(gH_SQL);
|
||||
SQL_SetPrefix();
|
||||
|
||||
@ -98,6 +98,12 @@ public APLRes AskPluginLoad2(Handle myself, bool late, char[] error, int err_max
|
||||
return APLRes_Success;
|
||||
}
|
||||
|
||||
public void OnAllPluginsLoaded()
|
||||
{
|
||||
// modules
|
||||
gB_Rankings = LibraryExists("shavit-rankings");
|
||||
}
|
||||
|
||||
public void OnPluginStart()
|
||||
{
|
||||
// debug because I was making this all by myself and no one wanted to help me *sniff*
|
||||
@ -122,9 +128,6 @@ public void OnPluginStart()
|
||||
// cvars
|
||||
gCV_RecordsLimit = CreateConVar("shavit_wr_recordlimit", "50", "Limit of records shown in the WR menu.\nAdvised to not set above 1,000 because scrolling through so many pages is useless.\n(And can also cause the command to take long time to run)", 0, true, 1.0);
|
||||
|
||||
// modules
|
||||
gB_Rankings = LibraryExists("shavit-rankings");
|
||||
|
||||
AutoExecConfig();
|
||||
|
||||
OnAdminMenuReady(null);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user