From fdd39a1fa4479ac29a76a3304018591ccb8af03f Mon Sep 17 00:00:00 2001 From: zaCade Date: Thu, 11 Apr 2019 18:32:44 +0200 Subject: [PATCH] Update entWatch-interface.sp --- _entWatch4/scripting/entWatch-interface.sp | 214 ++++++++++++--------- 1 file changed, 120 insertions(+), 94 deletions(-) diff --git a/_entWatch4/scripting/entWatch-interface.sp b/_entWatch4/scripting/entWatch-interface.sp index ad5e2541..e9d04889 100644 --- a/_entWatch4/scripting/entWatch-interface.sp +++ b/_entWatch4/scripting/entWatch-interface.sp @@ -35,112 +35,138 @@ 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; - for (int index; index < EW_GetItemCount(); index++) + switch(GetClientTeam(client)) { - CItem item = EW_GetItemData(index); - - if (item.dConfig.bDisplayInterface && item.bClient) - { - char sLine[64]; - char sShort[32]; - item.dConfig.GetShort(sShort, sizeof(sShort)); - - switch(item.dConfig.iMode) - { - case MODE_COOLDOWN: - { - if (item.iTimeReady > RoundToCeil(GetEngineTime())) - { - Format(sLine, sizeof(sLine), "%s [%d]: %N", sShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iClient); - } - else - { - Format(sLine, sizeof(sLine), "%s [%s]: %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); - } - else - { - Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "D", item.iClient); - } - } - case MODE_COOLDOWNMAXUSES: - { - if (item.iTimesUsed < item.dConfig.iMaxUses) - { - if (item.iTimeReady > RoundToCeil(GetEngineTime())) - { - Format(sLine, sizeof(sLine), "%s [%d]: %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); - } - } - else - { - Format(sLine, sizeof(sLine), "%s [%s]: %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); - } - else - { - Format(sLine, sizeof(sLine), "%s [%d/%d]: %N", sShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iClient); - } - } - default: - { - Format(sLine, sizeof(sLine), "%s [%s]: %N", sShort, "N/A", item.iClient); - } - } - - int iTeamLine = GetClientTeam(item.iClient) - 2; - - if (strlen(sTeamLines[iTeamLine]) + strlen(sLine) < sizeof(sTeamLines[])) - { - Format(sTeamLines[iTeamLine], sizeof(sTeamLines[]), "%s\n%s", sTeamLines[iTeamLine], sLine); - } - else break; - } + case(2): iZombies[iZombiesCount++] = client; + case(3): iHumans[iHumansCount++] = client; + default: iSpecs[iSpecsCount++] = client; } + } - for (int client = 1; client <= MaxClients; client++) + 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) { - if (!IsClientInGame(client) || IsClientSourceTV(client) || IsFakeClient(client)) - continue; + char sLine[64]; + char sShort[32]; + item.dConfig.GetShort(sShort, sizeof(sShort)); - int iTeamLine; - if ((iTeamLine = GetClientTeam(client) - 2) < 0) + switch(item.dConfig.iMode) { - int spectatingClient; - if ((spectatingClient = Client_GetObserverTarget(client)) < 0) - continue; - - if ((iTeamLine = GetClientTeam(spectatingClient) - 2) < 0) - continue; + case MODE_COOLDOWN: + { + 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 [%s]: %N\n", sShort, "R", item.iClient); + } + } + case MODE_MAXUSES: + { + if (item.iTimesUsed < item.dConfig.iMaxUses) + { + 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\n", sShort, "D", item.iClient); + } + } + case MODE_COOLDOWNMAXUSES: + { + if (item.iTimesUsed < item.dConfig.iMaxUses) + { + 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); + } + } + else + { + 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\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); + } } - if (sTeamLines[iTeamLine][0]) + switch(GetClientTeam(item.iClient)) { - Handle hMessage = StartMessageOne("KeyHintText", client); - BfWriteByte(hMessage, 1); - BfWriteString(hMessage, sTeamLines[iTeamLine]); - EndMessage(); + 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); + } + } + } + + if (strlen(sSpecHUD) + strlen(sLine) < sizeof(sSpecHUD)) + { + 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(); } \ No newline at end of file