a1b24ac6ca
(admins still global)
211 lines
6.9 KiB
SourcePawn
211 lines
6.9 KiB
SourcePawn
//====================================================================================================
|
|
//
|
|
// Name: [entWatch] Messages
|
|
// Author: zaCade & Prometheum
|
|
// Description: Handle the chat messages of [entWatch]
|
|
//
|
|
//====================================================================================================
|
|
#include <multicolors>
|
|
|
|
#pragma newdecls required
|
|
|
|
#include <sourcemod>
|
|
#include <entWatch_core>
|
|
#include <entWatch_helpers>
|
|
|
|
#define MESSAGEFORMAT "\x07%s[entWatch] \x07%s%s \x07%s(\x07%s%s\x07%s) %t \x07%6s%s"
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
// Purpose:
|
|
//----------------------------------------------------------------------------------------------------
|
|
public Plugin myinfo =
|
|
{
|
|
name = "[entWatch] Messages",
|
|
author = "zaCade & Prometheum",
|
|
description = "Handle the chat messages of [entWatch]",
|
|
version = "4.0.0"
|
|
};
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
// Purpose:
|
|
//----------------------------------------------------------------------------------------------------
|
|
public void OnPluginStart()
|
|
{
|
|
LoadTranslations("entWatch.messages.phrases");
|
|
}
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
// Purpose:
|
|
//----------------------------------------------------------------------------------------------------
|
|
public void EW_OnClientItemDrop(int client, int index)
|
|
{
|
|
CItem item = EW_GetItemData(index);
|
|
int iTeam = GetClientTeam(client);
|
|
|
|
if (item.dConfig.bDisplayEventMessages)
|
|
{
|
|
SetGlobalTransTarget(LANG_SERVER);
|
|
|
|
char sClientName[32];
|
|
GetClientName(client, sClientName, sizeof(sClientName));
|
|
|
|
char sClientAuth[32];
|
|
GetClientAuthId(client, AuthId_Steam2, sClientAuth, sizeof(sClientAuth));
|
|
|
|
char sItemName[32];
|
|
item.dConfig.GetName(sItemName, sizeof(sItemName));
|
|
|
|
char sItemColor[6];
|
|
item.dConfig.GetColor(sItemColor, sizeof(sItemColor));
|
|
|
|
CRemoveTags(sClientName, sizeof(sClientName));
|
|
for(int i = 1; i <= MaxClients; i++)
|
|
{
|
|
if(CheckIfTeamOrAdmin(iTeam, i))
|
|
CPrintToChat(i, MESSAGEFORMAT, "E01B5D", "EDEDED", sClientName, "E562BA", "B2B2B2", sClientAuth, "E562BA", "Item Drop", sItemColor, sItemName);
|
|
}
|
|
}
|
|
}
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
// Purpose:
|
|
//----------------------------------------------------------------------------------------------------
|
|
public void EW_OnClientItemDeath(int client, int index)
|
|
{
|
|
CItem item = EW_GetItemData(index);
|
|
int iTeam = GetClientTeam(client);
|
|
|
|
if (item.dConfig.bDisplayEventMessages)
|
|
{
|
|
SetGlobalTransTarget(LANG_SERVER);
|
|
|
|
char sClientName[32];
|
|
GetClientName(client, sClientName, sizeof(sClientName));
|
|
|
|
char sClientAuth[32];
|
|
GetClientAuthId(client, AuthId_Steam2, sClientAuth, sizeof(sClientAuth));
|
|
|
|
char sItemName[32];
|
|
item.dConfig.GetName(sItemName, sizeof(sItemName));
|
|
|
|
char sItemColor[6];
|
|
item.dConfig.GetColor(sItemColor, sizeof(sItemColor));
|
|
|
|
CRemoveTags(sClientName, sizeof(sClientName));
|
|
for(int i = 1; i <= MaxClients; i++)
|
|
{
|
|
if(CheckIfTeamOrAdmin(iTeam, i))
|
|
CPrintToChat(i, MESSAGEFORMAT, "E01B5D", "EDEDED", sClientName, "F1B567", "B2B2B2", sClientAuth, "F1B567", "Item Death", sItemColor, sItemName);
|
|
}
|
|
}
|
|
}
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
// Purpose:
|
|
//----------------------------------------------------------------------------------------------------
|
|
public void EW_OnClientItemPickup(int client, int index)
|
|
{
|
|
CItem item = EW_GetItemData(index);
|
|
int iTeam = GetClientTeam(client);
|
|
|
|
if (item.dConfig.bDisplayEventMessages)
|
|
{
|
|
SetGlobalTransTarget(LANG_SERVER);
|
|
|
|
char sClientName[32];
|
|
GetClientName(client, sClientName, sizeof(sClientName));
|
|
|
|
char sClientAuth[32];
|
|
GetClientAuthId(client, AuthId_Steam2, sClientAuth, sizeof(sClientAuth));
|
|
|
|
char sItemName[32];
|
|
item.dConfig.GetName(sItemName, sizeof(sItemName));
|
|
|
|
char sItemColor[6];
|
|
item.dConfig.GetColor(sItemColor, sizeof(sItemColor));
|
|
|
|
CRemoveTags(sClientName, sizeof(sClientName));
|
|
for(int i = 1; i <= MaxClients; i++)
|
|
{
|
|
if(CheckIfTeamOrAdmin(iTeam, i))
|
|
CPrintToChat(i, MESSAGEFORMAT, "E01B5D", "EDEDED", sClientName, "C9EF66", "B2B2B2", sClientAuth, "C9EF66", "Item Pickup", sItemColor, sItemName);
|
|
}
|
|
}
|
|
}
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
// Purpose:
|
|
//----------------------------------------------------------------------------------------------------
|
|
public void EW_OnClientItemDisconnect(int client, int index)
|
|
{
|
|
CItem item = EW_GetItemData(index);
|
|
int iTeam = GetClientTeam(client);
|
|
|
|
if (item.dConfig.bDisplayEventMessages)
|
|
{
|
|
SetGlobalTransTarget(LANG_SERVER);
|
|
|
|
char sClientName[32];
|
|
GetClientName(client, sClientName, sizeof(sClientName));
|
|
|
|
char sClientAuth[32];
|
|
GetClientAuthId(client, AuthId_Steam2, sClientAuth, sizeof(sClientAuth));
|
|
|
|
char sItemName[32];
|
|
item.dConfig.GetName(sItemName, sizeof(sItemName));
|
|
|
|
char sItemColor[6];
|
|
item.dConfig.GetColor(sItemColor, sizeof(sItemColor));
|
|
|
|
CRemoveTags(sClientName, sizeof(sClientName));
|
|
for(int i = 1; i <= MaxClients; i++)
|
|
{
|
|
if(CheckIfTeamOrAdmin(iTeam, i))
|
|
CPrintToChat(i, MESSAGEFORMAT, "E01B5D", "EDEDED", sClientName, "67ADDF", "B2B2B2", sClientAuth, "67ADDF", "Item Activate", sItemColor, sItemName);
|
|
}
|
|
}
|
|
}
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
// Purpose:
|
|
//----------------------------------------------------------------------------------------------------
|
|
public void EW_OnClientItemActivate(int client, int index)
|
|
{
|
|
CItem item = EW_GetItemData(index);
|
|
int iTeam = GetClientTeam(client);
|
|
|
|
if (item.dConfig.bDisplayActivateMessages)
|
|
{
|
|
SetGlobalTransTarget(LANG_SERVER);
|
|
|
|
char sClientName[32];
|
|
GetClientName(client, sClientName, sizeof(sClientName));
|
|
|
|
char sClientAuth[32];
|
|
GetClientAuthId(client, AuthId_Steam2, sClientAuth, sizeof(sClientAuth));
|
|
|
|
char sItemName[32];
|
|
item.dConfig.GetName(sItemName, sizeof(sItemName));
|
|
|
|
char sItemColor[6];
|
|
item.dConfig.GetColor(sItemColor, sizeof(sItemColor));
|
|
|
|
CRemoveTags(sClientName, sizeof(sClientName));
|
|
for(int i = 1; i <= MaxClients; i++)
|
|
{
|
|
if(CheckIfTeamOrAdmin(iTeam, i))
|
|
CPrintToChat(i, MESSAGEFORMAT, "E01B5D", "EDEDED", sClientName, "E562BA", "B2B2B2", sClientAuth, "E562BA", "Item Activate", sItemColor, sItemName);
|
|
}
|
|
}
|
|
}
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
// Purpose:
|
|
//----------------------------------------------------------------------------------------------------
|
|
public bool CheckIfTeamOrAdmin(int team, int client)
|
|
{
|
|
if(client > 0 && client <= MaxClients && IsClientInGame(client) && (team == GetClientTeam(client) || CheckCommandAccess(client, "", ADMFLAG_GENERIC)))
|
|
return true;
|
|
else
|
|
return false;
|
|
} |