diff --git a/_entWatch4/scripting/entWatch-interface.sp b/_entWatch4/scripting/entWatch-interface.sp index b4325e33..e7c9753b 100644 --- a/_entWatch4/scripting/entWatch-interface.sp +++ b/_entWatch4/scripting/entWatch-interface.sp @@ -26,12 +26,19 @@ public Plugin myinfo = //---------------------------------------------------------------------------------------------------- // 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 sHUDBuffer[64]; + char sTeamLines[2][255]; for (int index; index < EW_GetItemCount(); index++) { @@ -39,8 +46,9 @@ public void OnGameFrame() if (item.dConfig.bDisplayInterface && item.bClient) { - char sItemShort[32]; - item.dConfig.GetShort(sItemShort, sizeof(sItemShort)); + char sLine[64]; + char sShort[32]; + item.dConfig.GetShort(sShort, sizeof(sShort)); switch(item.dConfig.iMode) { @@ -48,22 +56,22 @@ public void OnGameFrame() { 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 { - 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: { 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 { - 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: @@ -72,46 +80,61 @@ public void OnGameFrame() { 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 { - 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 { - 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: { 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 { - 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: { - 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; } } - Handle hMessage = StartMessageAll("KeyHintText"); - BfWriteByte(hMessage, 1); - BfWriteString(hMessage, sHUDFormat); - EndMessage(); + for (int client = 1; client <= MaxClients; client++) + { + if (!IsClientInGame(client) || IsClientSourceTV(client) || IsFakeClient(client)) + 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(); + } + } } } \ No newline at end of file