173 lines
		
	
	
		
			5.0 KiB
		
	
	
	
		
			SourcePawn
		
	
	
	
	
	
			
		
		
	
	
			173 lines
		
	
	
		
			5.0 KiB
		
	
	
	
		
			SourcePawn
		
	
	
	
	
	
| //====================================================================================================
 | |
| //
 | |
| // Name: [entWatch] Interface
 | |
| // Author: zaCade & Prometheum
 | |
| // Description: Handle the interface of [entWatch]
 | |
| //
 | |
| //====================================================================================================
 | |
| #pragma newdecls required
 | |
| 
 | |
| #include <sourcemod>
 | |
| #include <entWatch_core>
 | |
| #include <entWatch_helpers>
 | |
| 
 | |
| //----------------------------------------------------------------------------------------------------
 | |
| // 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 iHUDPages[3];
 | |
| 	char sHUDPanels[3][8][255]
 | |
| 
 | |
| 	for (int index; index < EW_GetItemCount(); index++)
 | |
| 	{
 | |
| 		CItem item = EW_GetItemData(index);
 | |
| 
 | |
| 		if (item.bClient && item.dConfig.bDisplayInterface)
 | |
| 		{
 | |
| 			char sShort[32];
 | |
| 			item.dConfig.GetShort(sShort, sizeof(sShort));
 | |
| 
 | |
| 			char sLine[96];
 | |
| 			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);
 | |
| 				}
 | |
| 			}
 | |
| 
 | |
| 			switch(GetClientTeam(item.iClient))
 | |
| 			{
 | |
| 				case(2):
 | |
| 				{
 | |
| 					if (strlen(sHUDPanels[1][iHUDPages[1]]) + strlen(sLine) + 2 >= sizeof(sHUDPanels[][])) iHUDPages[1]++;
 | |
| 
 | |
| 					StrCat(sHUDPanels[1][iHUDPages[1]], sizeof(sHUDPanels[][]), sLine);
 | |
| 					StrCat(sHUDPanels[1][iHUDPages[1]], sizeof(sHUDPanels[][]), "\n");
 | |
| 				}
 | |
| 				case(3):
 | |
| 				{
 | |
| 					if (strlen(sHUDPanels[2][iHUDPages[2]]) + strlen(sLine) + 2 >= sizeof(sHUDPanels[][])) iHUDPages[2]++;
 | |
| 
 | |
| 					StrCat(sHUDPanels[2][iHUDPages[2]], sizeof(sHUDPanels[][]), sLine);
 | |
| 					StrCat(sHUDPanels[2][iHUDPages[2]], sizeof(sHUDPanels[][]), "\n");
 | |
| 				}
 | |
| 			}
 | |
| 
 | |
| 			if (strlen(sHUDPanels[0][iHUDPages[0]]) + strlen(sLine) + 2 >= sizeof(sHUDPanels[][])) iHUDPages[0]++;
 | |
| 
 | |
| 			StrCat(sHUDPanels[0][iHUDPages[0]], sizeof(sHUDPanels[][]), sLine);
 | |
| 			StrCat(sHUDPanels[0][iHUDPages[0]], sizeof(sHUDPanels[][]), "\n");
 | |
| 		}
 | |
| 	}
 | |
| 
 | |
| 	static int iPageUpdate;
 | |
| 	static int iPageCurrent[3];
 | |
| 
 | |
| 	if (iPageUpdate >= 5)
 | |
| 	{
 | |
| 		for (int iPageID; iPageID < 3; iPageID++)
 | |
| 		{
 | |
| 			if (iPageCurrent[iPageID] >= iHUDPages[iPageID])
 | |
| 				iPageCurrent[iPageID] = 0;
 | |
| 			else
 | |
| 				iPageCurrent[iPageID]++;
 | |
| 		}
 | |
| 
 | |
| 		iPageUpdate = 0;
 | |
| 	}
 | |
| 	else
 | |
| 		iPageUpdate++;
 | |
| 
 | |
| 	for (int client = 1; client <= MaxClients; client++)
 | |
| 	{
 | |
| 		if (!IsClientInGame(client) || IsFakeClient(client))
 | |
| 			continue;
 | |
| 
 | |
| 		int iPanelID;
 | |
| 		switch(GetClientTeam(client))
 | |
| 		{
 | |
| 			case(2): iPanelID = 1;
 | |
| 			case(3): iPanelID = 2;
 | |
| 		}
 | |
| 
 | |
| 		if (sHUDPanels[iPanelID][iPageCurrent[iPanelID]][0])
 | |
| 		{
 | |
| 			Handle hMessage = StartMessageOne("KeyHintText", client);
 | |
| 			BfWriteByte(hMessage, 1);
 | |
| 			BfWriteString(hMessage, sHUDPanels[iPanelID][iPageCurrent[iPanelID]]);
 | |
| 			EndMessage();
 | |
| 		}
 | |
| 	}
 | |
| } |