From 4a826805fe6994847257ee4deb8875b8579e5f33 Mon Sep 17 00:00:00 2001 From: zaCade Date: Tue, 2 Apr 2019 11:58:13 +0200 Subject: [PATCH] entWatch: Rework interface code, fix translations in messages. --- _entWatch4/scripting/entWatch-interface.sp | 137 ++++++++++----------- _entWatch4/scripting/entWatch-messages.sp | 12 +- 2 files changed, 79 insertions(+), 70 deletions(-) diff --git a/_entWatch4/scripting/entWatch-interface.sp b/_entWatch4/scripting/entWatch-interface.sp index a481d556..43d8a491 100644 --- a/_entWatch4/scripting/entWatch-interface.sp +++ b/_entWatch4/scripting/entWatch-interface.sp @@ -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(); - }*/ + } } \ No newline at end of file diff --git a/_entWatch4/scripting/entWatch-messages.sp b/_entWatch4/scripting/entWatch-messages.sp index b5e4bc08..162a5c04 100644 --- a/_entWatch4/scripting/entWatch-messages.sp +++ b/_entWatch4/scripting/entWatch-messages.sp @@ -13,7 +13,7 @@ #include #include -#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));