2017-03-01 21:05:40 +01:00
|
|
|
//====================================================================================================
|
|
|
|
//
|
|
|
|
// Name: [entWatch] Interface
|
|
|
|
// Author: zaCade & Prometheum
|
|
|
|
// Description: Handle the interface of [entWatch]
|
|
|
|
//
|
|
|
|
//====================================================================================================
|
|
|
|
#pragma newdecls required
|
|
|
|
|
|
|
|
#include <sourcemod>
|
|
|
|
#include <entWatch_core>
|
2019-04-08 12:19:03 +02:00
|
|
|
#include <entWatch_helpers>
|
2017-03-01 21:05:40 +01:00
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
public Plugin myinfo =
|
|
|
|
{
|
|
|
|
name = "[entWatch] Interface",
|
|
|
|
author = "zaCade & Prometheum",
|
|
|
|
description = "Handle the interface of [entWatch]",
|
|
|
|
version = "4.0.0"
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
2019-04-07 17:00:23 +02:00
|
|
|
public void OnMapStart()
|
2017-03-01 21:05:40 +01:00
|
|
|
{
|
2019-04-07 17:00:23 +02:00
|
|
|
CreateTimer(1.0, OnDisplayHUD, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT);
|
|
|
|
}
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
public Action OnDisplayHUD(Handle timer)
|
|
|
|
{
|
2019-04-11 18:32:44 +02:00
|
|
|
int iZombiesCount;
|
|
|
|
int iZombies[MAXPLAYERS+1];
|
|
|
|
|
|
|
|
int iHumansCount;
|
|
|
|
int iHumans[MAXPLAYERS+1];
|
|
|
|
|
|
|
|
int iSpecsCount;
|
|
|
|
int iSpecs[MAXPLAYERS+1];
|
|
|
|
|
|
|
|
for (int client = 1; client <= MaxClients; client++)
|
2017-03-01 21:05:40 +01:00
|
|
|
{
|
2019-04-11 18:32:44 +02:00
|
|
|
if (!IsClientInGame(client) || IsFakeClient(client))
|
|
|
|
continue;
|
2018-08-08 17:31:50 +02:00
|
|
|
|
2019-04-11 18:32:44 +02:00
|
|
|
switch(GetClientTeam(client))
|
2017-03-01 21:05:40 +01:00
|
|
|
{
|
2019-04-11 18:32:44 +02:00
|
|
|
case(2): iZombies[iZombiesCount++] = client;
|
|
|
|
case(3): iHumans[iHumansCount++] = client;
|
|
|
|
default: iSpecs[iSpecsCount++] = client;
|
|
|
|
}
|
|
|
|
}
|
2018-08-08 17:31:50 +02:00
|
|
|
|
2019-04-11 18:32:44 +02:00
|
|
|
char sZombieHUD[255];
|
|
|
|
char sHumanHUD[255];
|
|
|
|
char sSpecHUD[255];
|
|
|
|
|
|
|
|
for (int index; index < EW_GetItemCount(); index++)
|
|
|
|
{
|
|
|
|
CItem item = EW_GetItemData(index);
|
|
|
|
|
|
|
|
if (item.bClient && item.dConfig.bDisplayInterface)
|
|
|
|
{
|
|
|
|
char sLine[64];
|
|
|
|
char sShort[32];
|
|
|
|
item.dConfig.GetShort(sShort, sizeof(sShort));
|
2019-04-02 11:58:13 +02:00
|
|
|
|
2019-04-11 18:32:44 +02:00
|
|
|
switch(item.dConfig.iMode)
|
|
|
|
{
|
|
|
|
case MODE_COOLDOWN:
|
2017-03-01 21:05:40 +01:00
|
|
|
{
|
2019-04-11 18:32:44 +02:00
|
|
|
if (item.iTimeReady > RoundToCeil(GetEngineTime()))
|
2017-03-01 21:05:40 +01:00
|
|
|
{
|
2019-04-11 18:32:44 +02:00
|
|
|
Format(sLine, sizeof(sLine), "%s [%d]: %N\n", sShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient);
|
2019-04-02 11:58:13 +02:00
|
|
|
}
|
2019-04-11 18:32:44 +02:00
|
|
|
else
|
2019-04-02 11:58:13 +02:00
|
|
|
{
|
2019-04-11 18:32:44 +02:00
|
|
|
Format(sLine, sizeof(sLine), "%s [%s]: %N\n", sShort, "R", item.iClient);
|
2019-04-02 11:58:13 +02:00
|
|
|
}
|
2019-04-11 18:32:44 +02:00
|
|
|
}
|
|
|
|
case MODE_MAXUSES:
|
|
|
|
{
|
|
|
|
if (item.iTimesUsed < item.dConfig.iMaxUses)
|
2019-04-02 11:58:13 +02:00
|
|
|
{
|
2019-04-11 18:32:44 +02:00
|
|
|
Format(sLine, sizeof(sLine), "%s [%d/%d]: %N\n", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient);
|
2017-03-01 21:05:40 +01:00
|
|
|
}
|
2019-04-11 18:32:44 +02:00
|
|
|
else
|
|
|
|
{
|
|
|
|
Format(sLine, sizeof(sLine), "%s [%s]: %N\n", sShort, "D", item.iClient);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case MODE_COOLDOWNMAXUSES:
|
|
|
|
{
|
|
|
|
if (item.iTimesUsed < item.dConfig.iMaxUses)
|
2019-04-02 11:58:13 +02:00
|
|
|
{
|
|
|
|
if (item.iTimeReady > RoundToCeil(GetEngineTime()))
|
|
|
|
{
|
2019-04-11 18:32:44 +02:00
|
|
|
Format(sLine, sizeof(sLine), "%s [%d]: %N\n", sShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient);
|
2019-04-02 11:58:13 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-04-11 18:32:44 +02:00
|
|
|
Format(sLine, sizeof(sLine), "%s [%d/%d]: %N\n", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient);
|
2019-04-02 11:58:13 +02:00
|
|
|
}
|
|
|
|
}
|
2019-04-11 18:32:44 +02:00
|
|
|
else
|
2017-03-01 21:05:40 +01:00
|
|
|
{
|
2019-04-11 18:32:44 +02:00
|
|
|
Format(sLine, sizeof(sLine), "%s [%s]: %N\n", sShort, "D", item.iClient);
|
2017-03-01 21:05:40 +01:00
|
|
|
}
|
|
|
|
}
|
2019-04-11 18:32:44 +02:00
|
|
|
case MODE_COOLDOWNCHARGES:
|
2019-04-02 11:58:13 +02:00
|
|
|
{
|
2019-04-11 18:32:44 +02:00
|
|
|
if (item.iTimeReady > RoundToCeil(GetEngineTime()))
|
|
|
|
{
|
|
|
|
Format(sLine, sizeof(sLine), "%s [%d]: %N\n", sShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
Format(sLine, sizeof(sLine), "%s [%d/%d]: %N\n", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
{
|
|
|
|
Format(sLine, sizeof(sLine), "%s [%s]: %N\n", sShort, "N/A", item.iClient);
|
2019-04-02 11:58:13 +02:00
|
|
|
}
|
2017-03-01 21:05:40 +01:00
|
|
|
}
|
2018-08-08 17:31:50 +02:00
|
|
|
|
2019-04-11 18:32:44 +02:00
|
|
|
switch(GetClientTeam(item.iClient))
|
2019-04-07 17:12:42 +02:00
|
|
|
{
|
2019-04-11 18:32:44 +02:00
|
|
|
case(2):
|
|
|
|
{
|
|
|
|
if (strlen(sZombieHUD) + strlen(sLine) < sizeof(sZombieHUD))
|
|
|
|
{
|
|
|
|
StrCat(sZombieHUD, sizeof(sZombieHUD), sLine);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
case(3):
|
|
|
|
{
|
|
|
|
if (strlen(sHumanHUD) + strlen(sLine) < sizeof(sHumanHUD))
|
|
|
|
{
|
|
|
|
StrCat(sHumanHUD, sizeof(sHumanHUD), sLine);
|
|
|
|
}
|
|
|
|
}
|
2019-04-07 17:12:42 +02:00
|
|
|
}
|
2019-04-07 17:00:23 +02:00
|
|
|
|
2019-04-11 18:32:44 +02:00
|
|
|
if (strlen(sSpecHUD) + strlen(sLine) < sizeof(sSpecHUD))
|
2019-04-07 17:00:23 +02:00
|
|
|
{
|
2019-04-11 18:32:44 +02:00
|
|
|
StrCat(sSpecHUD, sizeof(sSpecHUD), sLine);
|
2019-04-07 17:00:23 +02:00
|
|
|
}
|
|
|
|
}
|
2019-04-02 11:58:13 +02:00
|
|
|
}
|
2019-04-11 18:32:44 +02:00
|
|
|
|
|
|
|
Handle hZombieMessage = StartMessage("KeyHintText", iZombies, iZombiesCount);
|
|
|
|
BfWriteByte(hZombieMessage, 1);
|
|
|
|
BfWriteString(hZombieMessage, sZombieHUD);
|
|
|
|
EndMessage();
|
|
|
|
|
|
|
|
Handle hHumanMessage = StartMessage("KeyHintText", iHumans, iHumansCount);
|
|
|
|
BfWriteByte(hHumanMessage, 1);
|
|
|
|
BfWriteString(hHumanMessage, sHumanHUD);
|
|
|
|
EndMessage();
|
|
|
|
|
|
|
|
Handle hSpecMessage = StartMessage("KeyHintText", iSpecs, iSpecsCount);
|
|
|
|
BfWriteByte(hSpecMessage, 1);
|
|
|
|
BfWriteString(hSpecMessage, sSpecHUD);
|
|
|
|
EndMessage();
|
2017-03-01 21:05:40 +01:00
|
|
|
}
|