Jump to content

Add Temporary Ban Support

Pending 2.2.7

 Plugin has ability to remove stats on ban, but doesn't care if the player is tempbanned (not EAC) or not, which results in players who are banned for a specified period of time to lose all of the stats they've accumulated. I sent you a DM regarding the issue, however, I have a feeling it went into DM requests, so I am making a more formal approach.


Should be able to just add the following method:

private bool IsUserPermaBanned(ulong id)
{
    ServerUsers.User user = ServerUsers.Get(id);
    if (user.group == ServerUsers.UserGroup.Banned && user.expiry == -1) return true;
    return false;
}

and modify the following hooks:

void OnPlayerBanned(string name, ulong id, string address, string reason)
{
    if (conf.Options.deleteOnBan && IsUserPermaBanned(id))
        data.PlayerRankData.Remove(id);
}

 

void OnPlayerConnected(BasePlayer player)
{
    if (IsUserPermaBanned(player.userID))
    {
        if (conf.Options.deleteOnBan && data.PlayerRankData.ContainsKey(player.userID))
            data.PlayerRankData.Remove(player.userID);
        return;
    }
    DestroyMenu(String.Empty, player);
    if (!data.PlayerRankData.ContainsKey(player.userID))
    {
        data.PlayerRankData.Add(player.userID, new Dictionary<string, object>());
        foreach (var entry in PRDATA)
            data.PlayerRankData[player.userID].Add(entry.Key, entry.Value);
    }
    UpdatePlayer(player);
    GiveDelayedRewards(player);
}


and modify the method void SaveData(bool sql):

if (conf.Options.deleteOnBan)
{
    List<ulong> banlist = Pool.GetList<ulong>(); // no reason not to use pooled list.
    try
    {
        foreach (var entry in data.PlayerRankData)
        {
            if (IsUserPermaBanned(entry.Key))
                banlist.Add(entry.Key);
            entry.Value["Status"] = "offline";
        }
        foreach (var banned in banlist)
            data.PlayerRankData.Remove(banned);
    }
    catch (Exception e)
    {
        Console.WriteLine(e);
    }
    finally
    {
        Pool.FreeList(ref banlist);
    }
}

 

Edited by ViolationHandler.exe
Noticed it uses delete on ban elsewhere.

Share this comment


Link to comment
1.1m

Downloads

Total number of downloads.

5.7k

Customers

Total customers served.

83.6k

Files Sold

Total number of files sold.

1.6m

Payments Processed

Total payments processed.

×
×
  • 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.