Update entWatch-interface.sp

This commit is contained in:
zaCade 2019-04-11 18:32:44 +02:00
parent 43135b501a
commit b73a9dbf49

View File

@ -35,15 +35,37 @@ public void OnMapStart()
//----------------------------------------------------------------------------------------------------
public Action OnDisplayHUD(Handle timer)
{
if (EW_GetItemCount() >= 1)
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++)
{
char sTeamLines[2][255];
if (!IsClientInGame(client) || IsFakeClient(client))
continue;
switch(GetClientTeam(client))
{
case(2): iZombies[iZombiesCount++] = client;
case(3): iHumans[iHumansCount++] = client;
default: iSpecs[iSpecsCount++] = client;
}
}
char sZombieHUD[255];
char sHumanHUD[255];
char sSpecHUD[255];
for (int index; index < EW_GetItemCount(); index++)
{
CItem item = EW_GetItemData(index);
if (item.dConfig.bDisplayInterface && item.bClient)
if (item.bClient && item.dConfig.bDisplayInterface)
{
char sLine[64];
char sShort[32];
@ -55,22 +77,22 @@ public Action OnDisplayHUD(Handle timer)
{
if (item.iTimeReady > RoundToCeil(GetEngineTime()))
{
Format(sLine, sizeof(sLine), "%s [%d]: %N", sShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient);
Format(sLine, sizeof(sLine), "%s [%d]: %N\n", sShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient);
}
else
{
Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "R", item.iClient);
Format(sLine, sizeof(sLine), "%s [%s]: %N\n", sShort, "R", item.iClient);
}
}
case MODE_MAXUSES:
{
if (item.iTimesUsed < item.dConfig.iMaxUses)
{
Format(sLine, sizeof(sLine), "%s [%d/%d]: %N", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient);
Format(sLine, sizeof(sLine), "%s [%d/%d]: %N\n", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient);
}
else
{
Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "D", item.iClient);
Format(sLine, sizeof(sLine), "%s [%s]: %N\n", sShort, "D", item.iClient);
}
}
case MODE_COOLDOWNMAXUSES:
@ -79,68 +101,72 @@ public Action OnDisplayHUD(Handle timer)
{
if (item.iTimeReady > RoundToCeil(GetEngineTime()))
{
Format(sLine, sizeof(sLine), "%s [%d]: %N", sShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient);
Format(sLine, sizeof(sLine), "%s [%d]: %N\n", sShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient);
}
else
{
Format(sLine, sizeof(sLine), "%s [%d/%d]: %N", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient);
Format(sLine, sizeof(sLine), "%s [%d/%d]: %N\n", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient);
}
}
else
{
Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "D", item.iClient);
Format(sLine, sizeof(sLine), "%s [%s]: %N\n", sShort, "D", item.iClient);
}
}
case MODE_COOLDOWNCHARGES:
{
if (item.iTimeReady > RoundToCeil(GetEngineTime()))
{
Format(sLine, sizeof(sLine), "%s [%d]: %N", sShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient);
Format(sLine, sizeof(sLine), "%s [%d]: %N\n", sShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient);
}
else
{
Format(sLine, sizeof(sLine), "%s [%d/%d]: %N", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient);
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", sShort, "N/A", item.iClient);
Format(sLine, sizeof(sLine), "%s [%s]: %N\n", sShort, "N/A", item.iClient);
}
}
int iTeamLine = GetClientTeam(item.iClient) - 2;
if (strlen(sTeamLines[iTeamLine]) + strlen(sLine) < sizeof(sTeamLines[]))
switch(GetClientTeam(item.iClient))
{
Format(sTeamLines[iTeamLine], sizeof(sTeamLines[]), "%s\n%s", sTeamLines[iTeamLine], sLine);
}
else break;
}
}
for (int client = 1; client <= MaxClients; client++)
case(2):
{
if (!IsClientInGame(client) || IsClientSourceTV(client) || IsFakeClient(client))
continue;
int iTeamLine;
if ((iTeamLine = GetClientTeam(client) - 2) < 0)
if (strlen(sZombieHUD) + strlen(sLine) < sizeof(sZombieHUD))
{
int spectatingClient;
if ((spectatingClient = Client_GetObserverTarget(client)) < 0)
continue;
if ((iTeamLine = GetClientTeam(spectatingClient) - 2) < 0)
continue;
StrCat(sZombieHUD, sizeof(sZombieHUD), sLine);
}
}
case(3):
{
if (strlen(sHumanHUD) + strlen(sLine) < sizeof(sHumanHUD))
{
StrCat(sHumanHUD, sizeof(sHumanHUD), sLine);
}
}
}
if (sTeamLines[iTeamLine][0])
if (strlen(sSpecHUD) + strlen(sLine) < sizeof(sSpecHUD))
{
Handle hMessage = StartMessageOne("KeyHintText", client);
BfWriteByte(hMessage, 1);
BfWriteString(hMessage, sTeamLines[iTeamLine]);
StrCat(sSpecHUD, sizeof(sSpecHUD), sLine);
}
}
}
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();
}
}
}
}