2017-03-01 21:05:40 +01:00
|
|
|
//====================================================================================================
|
|
|
|
//
|
|
|
|
// Name: [entWatch] Interface
|
|
|
|
// Author: zaCade & Prometheum
|
|
|
|
// Description: Handle the interface of [entWatch]
|
|
|
|
//
|
|
|
|
//====================================================================================================
|
|
|
|
#include <smlib>
|
|
|
|
|
|
|
|
#pragma newdecls required
|
|
|
|
|
|
|
|
#include <sourcemod>
|
|
|
|
#include <entWatch_core>
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
public Plugin myinfo =
|
|
|
|
{
|
|
|
|
name = "[entWatch] Interface",
|
|
|
|
author = "zaCade & Prometheum",
|
|
|
|
description = "Handle the interface of [entWatch]",
|
|
|
|
version = "4.0.0"
|
|
|
|
};
|
|
|
|
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
// Purpose:
|
|
|
|
//----------------------------------------------------------------------------------------------------
|
|
|
|
public void OnGameFrame()
|
|
|
|
{
|
2019-04-02 11:58:13 +02:00
|
|
|
if (EW_GetItemCount())
|
2017-03-01 21:05:40 +01:00
|
|
|
{
|
2019-04-02 11:58:13 +02:00
|
|
|
char sHUDFormat[255];
|
2017-03-01 21:05:40 +01:00
|
|
|
char sHUDBuffer[64];
|
2018-08-08 17:31:50 +02:00
|
|
|
|
2017-03-01 21:05:40 +01:00
|
|
|
for (int index; index < EW_GetItemCount(); index++)
|
|
|
|
{
|
2019-04-02 11:58:13 +02:00
|
|
|
CItem item = EW_GetItemData(index);
|
2018-08-08 17:31:50 +02:00
|
|
|
|
2019-04-06 10:58:19 +02:00
|
|
|
if (item.dConfig.bDisplayInterface && item.bClient)
|
2017-03-01 21:05:40 +01:00
|
|
|
{
|
2019-04-02 11:58:13 +02:00
|
|
|
char sItemShort[32];
|
|
|
|
item.dConfig.GetShort(sItemShort, sizeof(sItemShort));
|
|
|
|
|
|
|
|
switch(item.dConfig.iMode)
|
2017-03-01 21:05:40 +01:00
|
|
|
{
|
2019-04-02 11:58:13 +02:00
|
|
|
case MODE_COOLDOWN:
|
2017-03-01 21:05:40 +01:00
|
|
|
{
|
2019-04-02 11:58:13 +02:00
|
|
|
if (item.iTimeReady > RoundToCeil(GetEngineTime()))
|
2017-03-01 21:05:40 +01:00
|
|
|
{
|
2019-04-06 10:58:19 +02:00
|
|
|
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d]: %N", sItemShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient);
|
2017-03-01 21:05:40 +01:00
|
|
|
}
|
2019-04-02 11:58:13 +02:00
|
|
|
else
|
2017-03-01 21:05:40 +01:00
|
|
|
{
|
2019-04-06 10:58:19 +02:00
|
|
|
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", sItemShort, "R", item.iClient);
|
2017-03-01 21:05:40 +01:00
|
|
|
}
|
2019-04-02 11:58:13 +02:00
|
|
|
}
|
|
|
|
case MODE_MAXUSES:
|
|
|
|
{
|
|
|
|
if (item.iTimesUsed < item.dConfig.iMaxUses)
|
2017-03-01 21:05:40 +01:00
|
|
|
{
|
2019-04-06 10:58:19 +02:00
|
|
|
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d/%d]: %N", sItemShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient);
|
2019-04-02 11:58:13 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-04-06 10:58:19 +02:00
|
|
|
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", sItemShort, "D", item.iClient);
|
2017-03-01 21:05:40 +01:00
|
|
|
}
|
2019-04-02 11:58:13 +02:00
|
|
|
}
|
|
|
|
case MODE_COOLDOWNMAXUSES:
|
|
|
|
{
|
|
|
|
if (item.iTimesUsed < item.dConfig.iMaxUses)
|
2017-03-01 21:05:40 +01:00
|
|
|
{
|
2019-04-02 11:58:13 +02:00
|
|
|
if (item.iTimeReady > RoundToCeil(GetEngineTime()))
|
2017-03-01 21:05:40 +01:00
|
|
|
{
|
2019-04-06 10:58:19 +02:00
|
|
|
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d]: %N", sItemShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient);
|
2017-03-01 21:05:40 +01:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-04-06 10:58:19 +02:00
|
|
|
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d/%d]: %N", sItemShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient);
|
2017-03-01 21:05:40 +01:00
|
|
|
}
|
|
|
|
}
|
2019-04-02 11:58:13 +02:00
|
|
|
else
|
2017-03-01 21:05:40 +01:00
|
|
|
{
|
2019-04-06 10:58:19 +02:00
|
|
|
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", sItemShort, "D", item.iClient);
|
2017-03-01 21:05:40 +01:00
|
|
|
}
|
|
|
|
}
|
2019-04-02 11:58:13 +02:00
|
|
|
case MODE_COOLDOWNCHARGES:
|
|
|
|
{
|
|
|
|
if (item.iTimeReady > RoundToCeil(GetEngineTime()))
|
|
|
|
{
|
2019-04-06 10:58:19 +02:00
|
|
|
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d]: %N", sItemShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient);
|
2019-04-02 11:58:13 +02:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2019-04-06 10:58:19 +02:00
|
|
|
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d/%d]: %N", sItemShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient);
|
2019-04-02 11:58:13 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
default:
|
2017-03-01 21:05:40 +01:00
|
|
|
{
|
2019-04-06 10:58:19 +02:00
|
|
|
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", sItemShort, "N/A", item.iClient);
|
2017-03-01 21:05:40 +01:00
|
|
|
}
|
|
|
|
}
|
2019-04-02 11:58:13 +02:00
|
|
|
|
|
|
|
if (strlen(sHUDFormat) + strlen(sHUDBuffer) < sizeof(sHUDFormat))
|
|
|
|
{
|
|
|
|
Format(sHUDFormat, sizeof(sHUDFormat), "%s\n%s", sHUDFormat, sHUDBuffer);
|
|
|
|
}
|
|
|
|
else break;
|
2017-03-01 21:05:40 +01:00
|
|
|
}
|
|
|
|
}
|
2018-08-08 17:31:50 +02:00
|
|
|
|
2017-03-01 21:05:40 +01:00
|
|
|
Handle hMessage = StartMessageAll("KeyHintText");
|
|
|
|
BfWriteByte(hMessage, 1);
|
|
|
|
BfWriteString(hMessage, sHUDFormat);
|
|
|
|
EndMessage();
|
2019-04-02 11:58:13 +02:00
|
|
|
}
|
2017-03-01 21:05:40 +01:00
|
|
|
}
|