entWatch4: Rework interface, show only own team.

This commit is contained in:
zaCade 2019-04-07 17:00:23 +02:00
parent fb87c025af
commit 0007b28285

View File

@ -26,12 +26,19 @@ public Plugin myinfo =
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
// Purpose: // Purpose:
//---------------------------------------------------------------------------------------------------- //----------------------------------------------------------------------------------------------------
public void OnGameFrame() public void OnMapStart()
{ {
if (EW_GetItemCount()) CreateTimer(1.0, OnDisplayHUD, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT);
}
//----------------------------------------------------------------------------------------------------
// Purpose:
//----------------------------------------------------------------------------------------------------
public Action OnDisplayHUD(Handle timer)
{
if (EW_GetItemCount() >= 1)
{ {
char sHUDFormat[255]; char sTeamLines[2][255];
char sHUDBuffer[64];
for (int index; index < EW_GetItemCount(); index++) for (int index; index < EW_GetItemCount(); index++)
{ {
@ -39,8 +46,9 @@ public void OnGameFrame()
if (item.dConfig.bDisplayInterface && item.bClient) if (item.dConfig.bDisplayInterface && item.bClient)
{ {
char sItemShort[32]; char sLine[64];
item.dConfig.GetShort(sItemShort, sizeof(sItemShort)); char sShort[32];
item.dConfig.GetShort(sShort, sizeof(sShort));
switch(item.dConfig.iMode) switch(item.dConfig.iMode)
{ {
@ -48,22 +56,22 @@ public void OnGameFrame()
{ {
if (item.iTimeReady > RoundToCeil(GetEngineTime())) if (item.iTimeReady > RoundToCeil(GetEngineTime()))
{ {
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d]: %N", sItemShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient); Format(sLine, sizeof(sLine), "%s [%d]: %N", sShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient);
} }
else else
{ {
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", sItemShort, "R", item.iClient); Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "R", item.iClient);
} }
} }
case MODE_MAXUSES: case MODE_MAXUSES:
{ {
if (item.iTimesUsed < item.dConfig.iMaxUses) if (item.iTimesUsed < item.dConfig.iMaxUses)
{ {
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d/%d]: %N", sItemShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient); Format(sLine, sizeof(sLine), "%s [%d/%d]: %N", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient);
} }
else else
{ {
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", sItemShort, "D", item.iClient); Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "D", item.iClient);
} }
} }
case MODE_COOLDOWNMAXUSES: case MODE_COOLDOWNMAXUSES:
@ -72,46 +80,61 @@ public void OnGameFrame()
{ {
if (item.iTimeReady > RoundToCeil(GetEngineTime())) if (item.iTimeReady > RoundToCeil(GetEngineTime()))
{ {
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d]: %N", sItemShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient); Format(sLine, sizeof(sLine), "%s [%d]: %N", sShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient);
} }
else else
{ {
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d/%d]: %N", sItemShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient); Format(sLine, sizeof(sLine), "%s [%d/%d]: %N", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient);
} }
} }
else else
{ {
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", sItemShort, "D", item.iClient); Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "D", item.iClient);
} }
} }
case MODE_COOLDOWNCHARGES: case MODE_COOLDOWNCHARGES:
{ {
if (item.iTimeReady > RoundToCeil(GetEngineTime())) if (item.iTimeReady > RoundToCeil(GetEngineTime()))
{ {
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d]: %N", sItemShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient); Format(sLine, sizeof(sLine), "%s [%d]: %N", sShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient);
} }
else else
{ {
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d/%d]: %N", sItemShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient); Format(sLine, sizeof(sLine), "%s [%d/%d]: %N", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient);
} }
} }
default: default:
{ {
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", sItemShort, "N/A", item.iClient); Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "N/A", item.iClient);
} }
} }
if (strlen(sHUDFormat) + strlen(sHUDBuffer) < sizeof(sHUDFormat)) int iTeamLine = GetClientTeam(item.iClient) - 2;
if (strlen(sTeamLines[iTeamLine]) + strlen(sLine) < sizeof(sTeamLines[]))
{ {
Format(sHUDFormat, sizeof(sHUDFormat), "%s\n%s", sHUDFormat, sHUDBuffer); Format(sTeamLines[iTeamLine], sizeof(sTeamLines[]), "%s\n%s", sTeamLines[iTeamLine], sLine);
} }
else break; else break;
} }
} }
Handle hMessage = StartMessageAll("KeyHintText"); for (int client = 1; client <= MaxClients; client++)
BfWriteByte(hMessage, 1); {
BfWriteString(hMessage, sHUDFormat); if (!IsClientInGame(client) || IsClientSourceTV(client) || IsFakeClient(client))
EndMessage(); continue;
int iTeamLine;
if ((iTeamLine = GetClientTeam(client) - 2) < 0)
continue;
if (sTeamLines[iTeamLine][0])
{
Handle hMessage = StartMessageOne("KeyHintText", client);
BfWriteByte(hMessage, 1);
BfWriteString(hMessage, sTeamLines[iTeamLine]);
EndMessage();
}
}
} }
} }