//==================================================================================================== // // Name: [entWatch] Interface // Author: zaCade & Prometheum // Description: Handle the interface of [entWatch] // //==================================================================================================== #pragma newdecls required #include #include #include //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- public Plugin myinfo = { name = "[entWatch] Interface", author = "zaCade & Prometheum", description = "Handle the interface of [entWatch]", version = "4.0.0" }; //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- public void OnMapStart() { CreateTimer(1.0, OnDisplayHUD, INVALID_HANDLE, TIMER_FLAG_NO_MAPCHANGE|TIMER_REPEAT); } //---------------------------------------------------------------------------------------------------- // Purpose: //---------------------------------------------------------------------------------------------------- public Action OnDisplayHUD(Handle timer) { 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++) { 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.bClient && item.dConfig.bDisplayInterface) { 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\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); } } switch(GetClientTeam(item.iClient)) { 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(); }