entWatch: Rework interface code, fix translations in messages.

This commit is contained in:
zaCade 2019-04-02 11:58:13 +02:00
parent 87877c0adc
commit 4a826805fe
2 changed files with 79 additions and 70 deletions

View File

@ -28,85 +28,84 @@ public Plugin myinfo =
//----------------------------------------------------------------------------------------------------
public void OnGameFrame()
{
/* if (EW_GetItemCount())
if (EW_GetItemCount())
{
char sHUDFormat[250];
char sHUDFormat[255];
char sHUDBuffer[64];
for (int index; index < EW_GetItemCount(); index++)
{
any itemArray[items];
EW_GetItemArray(index, itemArray, sizeof(itemArray));
CItem item = EW_GetItemData(index);
if (itemArray[item_display] & DISPLAY_HUD)
if (item.dConfig.bDisplayInterface && item.bOwner)
{
if (itemArray[item_owned] && itemArray[item_owner] >= 0)
{
switch(itemArray[item_mode])
{
case MODE_COOLDOWN:
{
if (itemArray[item_nextuse] > RoundToCeil(GetEngineTime()))
{
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d]: %N", itemArray[item_short], itemArray[item_nextuse] - RoundToCeil(GetEngineTime()), itemArray[item_owner]);
}
else
{
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", itemArray[item_short], "R", itemArray[item_owner]);
}
}
case MODE_MAXUSES:
{
if (itemArray[item_uses] < itemArray[item_maxuses])
{
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d/%d]: %N", itemArray[item_short], itemArray[item_uses], itemArray[item_maxuses], itemArray[item_owner]);
}
else
{
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", itemArray[item_short], "D", itemArray[item_owner]);
}
}
case MODE_COOLDOWNMAXUSES:
{
if (itemArray[item_uses] < itemArray[item_maxuses])
{
if (itemArray[item_nextuse] > RoundToCeil(GetEngineTime()))
{
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d]: %N", itemArray[item_short], itemArray[item_nextuse] - RoundToCeil(GetEngineTime()), itemArray[item_owner]);
}
else
{
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d/%d]: %N", itemArray[item_short], itemArray[item_uses], itemArray[item_maxuses], itemArray[item_owner]);
}
}
else
{
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", itemArray[item_short], "D", itemArray[item_owner]);
}
}
case MODE_COOLDOWNCHARGES:
{
if (itemArray[item_nextuse] > RoundToCeil(GetEngineTime()))
{
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d]: %N", itemArray[item_short], itemArray[item_nextuse] - RoundToCeil(GetEngineTime()), itemArray[item_owner]);
}
else
{
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d/%d]: %N", itemArray[item_short], itemArray[item_uses], itemArray[item_maxuses], itemArray[item_owner]);
}
}
default:
{
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", itemArray[item_short], "N/A", itemArray[item_owner]);
}
}
char sItemShort[32];
item.dConfig.GetShort(sItemShort, sizeof(sItemShort));
if (strlen(sHUDFormat) + strlen(sHUDBuffer) <= sizeof(sHUDFormat) - 2)
switch(item.dConfig.iMode)
{
case MODE_COOLDOWN:
{
Format(sHUDFormat, sizeof(sHUDFormat), "%s\n%s", sHUDFormat, sHUDBuffer);
if (item.iTimeReady > RoundToCeil(GetEngineTime()))
{
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d]: %N", sItemShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iOwner);
}
else
{
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", sItemShort, "R", item.iOwner);
}
}
case MODE_MAXUSES:
{
if (item.iTimesUsed < item.dConfig.iMaxUses)
{
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d/%d]: %N", sItemShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iOwner);
}
else
{
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", sItemShort, "D", item.iOwner);
}
}
case MODE_COOLDOWNMAXUSES:
{
if (item.iTimesUsed < item.dConfig.iMaxUses)
{
if (item.iTimeReady > RoundToCeil(GetEngineTime()))
{
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d]: %N", sItemShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iOwner);
}
else
{
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d/%d]: %N", sItemShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iOwner);
}
}
else
{
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", sItemShort, "D", item.iOwner);
}
}
case MODE_COOLDOWNCHARGES:
{
if (item.iTimeReady > RoundToCeil(GetEngineTime()))
{
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d]: %N", sItemShort, item.iTimeReady - RoundToCeil(GetEngineTime()), item.iOwner);
}
else
{
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%d/%d]: %N", sItemShort, item.iTimesUsed, item.dConfig.iMaxUses, item.iOwner);
}
}
default:
{
Format(sHUDBuffer, sizeof(sHUDBuffer), "%s [%s]: %N", sItemShort, "N/A", item.iOwner);
}
else break;
}
if (strlen(sHUDFormat) + strlen(sHUDBuffer) < sizeof(sHUDFormat))
{
Format(sHUDFormat, sizeof(sHUDFormat), "%s\n%s", sHUDFormat, sHUDBuffer);
}
else break;
}
}
@ -114,5 +113,5 @@ public void OnGameFrame()
BfWriteByte(hMessage, 1);
BfWriteString(hMessage, sHUDFormat);
EndMessage();
}*/
}
}

View File

@ -13,7 +13,7 @@
#include <sourcemod>
#include <entWatch_core>
#define MESSAGEFORMAT "\x07%s[entWatch] \x07%s%s \x07%s(\x07%s%s\x07%s) %s \x07%6s%s"
#define MESSAGEFORMAT "\x07%s[entWatch] \x07%s%s \x07%s(\x07%s%s\x07%s) %t \x07%6s%s"
//----------------------------------------------------------------------------------------------------
// Purpose:
@ -43,6 +43,8 @@ public void EW_OnClientItemDrop(int client, int index)
if (item.dConfig.bDisplayEventMessages)
{
SetGlobalTransTarget(LANG_SERVER);
char sClientName[32];
GetClientName(client, sClientName, sizeof(sClientName));
@ -69,6 +71,8 @@ public void EW_OnClientItemDeath(int client, int index)
if (item.dConfig.bDisplayEventMessages)
{
SetGlobalTransTarget(LANG_SERVER);
char sClientName[32];
GetClientName(client, sClientName, sizeof(sClientName));
@ -95,6 +99,8 @@ public void EW_OnClientItemPickup(int client, int index)
if (item.dConfig.bDisplayEventMessages)
{
SetGlobalTransTarget(LANG_SERVER);
char sClientName[32];
GetClientName(client, sClientName, sizeof(sClientName));
@ -121,6 +127,8 @@ public void EW_OnClientItemDisconnect(int client, int index)
if (item.dConfig.bDisplayEventMessages)
{
SetGlobalTransTarget(LANG_SERVER);
char sClientName[32];
GetClientName(client, sClientName, sizeof(sClientName));
@ -147,6 +155,8 @@ public void EW_OnClientItemActivate(int client, int index)
if (item.dConfig.bDisplayActivateMessages)
{
SetGlobalTransTarget(LANG_SERVER);
char sClientName[32];
GetClientName(client, sClientName, sizeof(sClientName));