Jump to content

Small fix

Pending 3.4.18

dFxGainwarD
dFxGainwarD

Posted

Hi,

I’ve found a few issues while testing Raid Protection:

  • UI overlap - If the Raid Protection UI stays open for a while, the TC menu overlaps it.
  • Duplicate SimpleStatus entries - After TC auth - unauth, two statuses can appear:
    - Raid Protection (% protection)
    - Raid Protection Upkeep (owner upkeep time) It seems
    SimpleStatus isn’t refreshed properly on auth/unauth.
    Suggestion: Refresh/update SimpleStatus on TC auth/unauth hook.
  • If Always Show For Owners or Always Show For Non Owners is enabled, it should bypass Show When Holding Hammer and Show When Attacking.

Also, I made a scrap balance icon in case you’d like to use it:
https://i.ibb.co/Z1tLBF6W/scraps.png

Just sharing feedback to help improve stability and UX

image.png

image.png

dFxGainwarD

Posted

Fix:

Replace:

if (showForOwners && tc != null && tc.IsAuthed(basePlayer) && tc.IsProtected)
{
    if (tc.HasFreeProtection)
    {
        PLUGIN.SimpleStatus.CallHook("SetStatus", basePlayer.UserId(), ID_STATUS, poptime);
        SetProtectionStatusTextPreference(basePlayer, tc, popup);
        return true;
    }
    else if (!popup)
    {
        var duration = (int)Math.Floor(tc.HoursOfProtection * 3600);
        PLUGIN.SimpleStatus.CallHook("SetStatus", basePlayer.UserId(), ID_STATUS, popup ? poptime : duration);
        SetProtectionStatusTextPreference(basePlayer, tc, popup);
        return duration > 0;
    }
    else
    {
        PLUGIN.SimpleStatus.CallHook("SetStatus", basePlayer.UserId(), ID_VISITOR, poptime);
        PLUGIN.SimpleStatus.CallHook("SetStatusText", basePlayer.UserId(), ID_VISITOR, $"{tc.CurrentProtectionPercent}%");
        return true;
    }
}

to:

if (showForOwners && tc != null && tc.IsAuthed(basePlayer) && tc.IsProtected)
{
    if (tc.HasFreeProtection)
    {
        PLUGIN.SimpleStatus.CallHook("SetStatus", basePlayer.UserId(), ID_VISITOR, 0);
        PLUGIN.SimpleStatus.CallHook("SetStatus", basePlayer.UserId(), ID_STATUS, poptime);
        SetProtectionStatusTextPreference(basePlayer, tc, popup);
        return true;
    }
    else if (!popup)
    {
        var duration = (int)Math.Floor(tc.HoursOfProtection * 3600);
        PLUGIN.SimpleStatus.CallHook("SetStatus", basePlayer.UserId(), ID_VISITOR, 0);
        PLUGIN.SimpleStatus.CallHook("SetStatus", basePlayer.UserId(), ID_STATUS, popup ? poptime : duration);
        SetProtectionStatusTextPreference(basePlayer, tc, popup);
        return duration > 0;
    }
    else
    {
        PLUGIN.SimpleStatus.CallHook("SetStatus", basePlayer.UserId(), ID_STATUS, 0);
        PLUGIN.SimpleStatus.CallHook("SetStatus", basePlayer.UserId(), ID_VISITOR, poptime);
        PLUGIN.SimpleStatus.CallHook("SetStatusText", basePlayer.UserId(), ID_VISITOR, $"{tc.CurrentProtectionPercent}%");
        return true;
    }
}

Replace:

else if (showForNonOwners && tc != null && !tc.IsAuthed(basePlayer) && tc.IsProtected)
{
    PLUGIN.SimpleStatus.CallHook("SetStatus", basePlayer.UserId(), ID_VISITOR, poptime);
    PLUGIN.SimpleStatus.CallHook("SetStatusText", basePlayer.UserId(), ID_VISITOR, $"{tc.CurrentProtectionPercent}%");
    return true;
}

to:

else if (showForNonOwners && tc != null && !tc.IsAuthed(basePlayer) && tc.IsProtected)
{
    PLUGIN.SimpleStatus.CallHook("SetStatus", basePlayer.UserId(), ID_STATUS, 0);
    PLUGIN.SimpleStatus.CallHook("SetStatus", basePlayer.UserId(), ID_VISITOR, poptime);
    PLUGIN.SimpleStatus.CallHook("SetStatusText", basePlayer.UserId(), ID_VISITOR, $"{tc.CurrentProtectionPercent}%");
    return true;
}

Add:

public static HashSet<ulong> PlayersViewingOverlay = new HashSet<ulong>();

after:

public static HashSet<ulong> PlayersViewingInfoPanel = new HashSet<ulong>();

 

Replace:

[Command("tc.info.close")]
private void TcInfoClose(IPlayer player, string command, string[] args)
{
    var basePlayer = player.Object as BasePlayer;
    if (IsNull(basePlayer)) return;
    CloseInfoPanel(basePlayer);
}

to:

[Command("tc.info.close")]
private void TcInfoClose(IPlayer player, string command, string[] args)
{
    var basePlayer = player.Object as BasePlayer;
    if (IsNull(basePlayer)) return;

    PlayersViewingInfoPanel.Remove(basePlayer.userID);
    CloseInfoPanel(basePlayer);
}

 

Replace:

private void ShowInfoPanel(BasePlayer basePlayer, ProtectedEntity tc, int page = 0)
{
    var container = new CuiElementContainer();

to:

private void ShowInfoPanel(BasePlayer basePlayer, ProtectedEntity tc, int page = 0)
{
    PlayersViewingInfoPanel.Add(basePlayer.userID);
    PlayersViewingOverlay.Remove(basePlayer.UserId());

    var container = new CuiElementContainer();

 

Replace:

private void ShowProtectionStatusOverlayTabs(BasePlayer basePlayer, ProtectedEntity tc, int page = 0)
{
    CuiElementContainer container = new CuiElementContainer();

to:

private void ShowProtectionStatusOverlayTabs(BasePlayer basePlayer, ProtectedEntity tc, int page = 0)
{
    if (PlayersViewingInfoPanel.Contains(basePlayer.userID))
        return;

    CuiElementContainer container = new CuiElementContainer();

 

Replace:

private void ShowProtectionStatusOverlay(BasePlayer basePlayer, ProtectedEntity tc)
{
    CuiElementContainer container = new CuiElementContainer();

to:

private void ShowProtectionStatusOverlay(BasePlayer basePlayer, ProtectedEntity tc)
{
    if (PlayersViewingInfoPanel.Contains(basePlayer.userID))
        return;

    CuiElementContainer container = new CuiElementContainer();

 

About Us

Codefling is the largest marketplace for plugins, maps, tools, and more, making it easy for customers to discover new content and for creators to monetize their work.

Downloads
2.4m
Total downloads
Customers
10.9k
Customers served
Files Sold
156.7k
Marketplace sales
Payments
3.4m
Processed total
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.