FactionsCore for Rust

A Faction/Team System. Revamp from original Factions.

Total Downloads: 324 - First Release: Apr 13, 2017 - Last Update: Jun 19, 2017

5/5, 6 likes
  1. Absolut
    Factions-Core is a rewrite of my original Factions Plugin with a complete UI overhaul, performance enhancements, and the ability to create modules that use the Factions-Core as a base.

    This will be a work in progress as I know there will be some bugs.. this is the main reason I have separated it from the old thread.

    FOR A PLAYER TO ACCESS THE MENU THEY MUST HAVE PERMISSION: FactionsCore.allow

    The Config Explained:

    Code (C#):
    "Allow_FriendlyFire": false, --> Enable/Disable FriendlyFire.
      "AllowedFactionDifference": 5, --> Amount of players one faction can have more then all others.
      "AuthorizeLeadersOnly": false, --> Changes default Authorization logic to only Leaders.
      "AutoAuthorization": true, --> Enable/Disable Authorization of Turrets and ability to open doors without knowing code locks. Must be authorized on a nearby Tool Cupboard to open the door of a Faction Member.
      "Colors": [ --> List of Colors available for Faction Creation.
        "#e60000",
        "#3366ff",
        "#29a329",
        "#ffff00",
        "#ff9933",
        "#7300e6",
        "#A93226",
        "#4A235A",
        "#1F618D",
        "#117864",
        "#D35400",
        "#626567",
        "#34495E",
        "#FA0091",
        "#3EFF00",
        "#00E0B8",
        "#4D8B98",
        "#9FB1B4",
        "#9569A8",
        "#76125B",
        "#161419",
        "#3A2C09",
        "#9ACD32",
        "#009A9A",
        "#523b2f",
        "#743d1b",
        "#d9dee2",
        "#676862",
        "#273a29"
      ],  "DeleteEmptyFactions": false, --> AutoPurge factions with 0 players.
      "DisableMenu": false, --> Disables the UI menu for everyone but players with Auth2 or permission FactionsCore.admin. Useful for using factions as a team management plugin only.
      "FactionEmblems_URLS": { -->List of Emblems available for Faction Creation.
        "0": "http://i.imgur.com/avnIndo.png",
        "1": "http://i.imgur.com/bDNy4nh.png",
        "10": "http://i.imgur.com/MDi4aEn.png",
        "11": "http://i.imgur.com/4DbaDNJ.png",
        "12": "http://i.imgur.com/yzShlSM.png",
        "13": "http://i.imgur.com/3HppE22.png",
        "14": "http://i.imgur.com/Xs6QN2s.png",
        "15": "http://i.imgur.com/NHGRtgx.png",
        "16": "http://i.imgur.com/PeSghTc.png",
        "17": "http://i.imgur.com/y8wo92P.png",
        "18": "http://i.imgur.com/OhGqJbe.png",
        "19": "http://i.imgur.com/FZk4S8s.png",
        "2": "http://i.imgur.com/iwzGH4W.png",
        "20": "http://i.imgur.com/V41i65b.png",
        "21": "http://i.imgur.com/XTwyNKE.png",
        "22": "http://i.imgur.com/vyI8Dh0.png",
        "23": "http://i.imgur.com/Lwpo4Uk.png",
        "24": "http://i.imgur.com/iKs1J4i.png",
        "25": "http://i.imgur.com/syl5cba.png",
        "26": "http://i.imgur.com/h5fPxsP.png",
        "27": "http://i.imgur.com/ONs75vx.png",
        "28": "http://i.imgur.com/73UHzgO.png",
        "29": "http://i.imgur.com/g35lupC.png",
        "3": "http://i.imgur.com/WAnPTiw.png",
        "30": "http://i.imgur.com/V6x5DEd.png",
        "31": "http://i.imgur.com/whcI2My.png",
        "32": "http://i.imgur.com/3q7CHvO.png",
        "33": "http://i.imgur.com/vqJIHFk.png",
        "34": "http://i.imgur.com/wUoKvyO.png",
        "35": "http://i.imgur.com/Oy7ZY0o.png",
        "36": "http://i.imgur.com/SwCMLVl.png",
        "37": "http://i.imgur.com/FpBbyJd.png",
        "38": "http://i.imgur.com/LkOu53F.png",
        "39": "http://i.imgur.com/NdGUphU.png",
        "4": "http://i.imgur.com/8d78Qnu.png",
        "40": "http://i.imgur.com/f9iakjZ.png",
        "41": "http://i.imgur.com/e9J33lR.png",
        "42": "http://i.imgur.com/oK8gp0b.png",
        "43": "http://i.imgur.com/cQ0hj5s.png",
        "44": "http://i.imgur.com/S9iwCq8.png",
        "45": "http://i.imgur.com/FLPXWvG.png",
        "46": "http://i.imgur.com/uaZoI9g.png",
        "47": "http://i.imgur.com/5mboBg8.png",
        "48": "http://i.imgur.com/41uR2X6.png",
        "49": "http://i.imgur.com/LhyPd3c.png",
        "5": "http://i.imgur.com/gAxeMvK.png",
        "50": "http://i.imgur.com/hrw1Ti9.png",
        "51": "http://i.imgur.com/yclMvuL.png",
        "52": "http://i.imgur.com/ozBS4Kx.png",
        "53": "http://i.imgur.com/lpzn12Y.png",
        "54": "http://i.imgur.com/439Qhnh.png",
        "55": "http://i.imgur.com/NkhVOqe.png",
        "56": "http://i.imgur.com/zc4Pqlm.png",
        "57": "http://i.imgur.com/JiIgA1i.png",
        "58": "http://i.imgur.com/dzLQYMu.png",
        "59": "http://i.imgur.com/J5eyqmq.png",
        "6": "http://i.imgur.com/dNpKRwg.png",
        "7": "http://i.imgur.com/Qu4SNm8.png",
        "8": "http://i.imgur.com/w2IH1Eo.png",
        "9": "http://i.imgur.com/Qzxv1zv.png"
      },
      "FactionLimit": 0, --> Limit number of Factions that can be created on the server (0 is unlimited)
      "FactionPlayerLimit": 0, --> Faction Player Limit (0 is unlimited)
      "FactionStaleTime": 0, --> How long before an inactive Faction is deleted. (Time is in DAYS). On plugin load it will check the last time a faction player logged in for each faction and based on that decide if the faction is stale. If so it will be deleted.
      "FriendlyFire_DamageScale": 0.0, --> FF damage. 0 makes it so no damage is done. 1f is full damage.
      "HomePageMessage": "Welcome!”, --> Message shows on UI Home Page.
      "
    InFactionChat_ChatColor": "#93FF7F", --> Color of IN FACTION Chat Messages.
      "InfoInterval": 15, --> Chat Info Message interval in minutes. (0 is disabled).
      "Kits_and_CustomSets": [
        "faction0",
        "faction1",
        "faction2",
        "faction3"
      ],
      "LockFactionKits_and_CustomSets": true, --> Locks equipment given in a Faction Kit or CustomSet to the player.
      "MenuKeyBinding": "", --> Bind a key to open UI Menu. /faction opens it as well.
      "SafeZones_Allow": true, --> Enables/Disables Safe Zone creation by Leaders and Moderators.
      "SafeZones_Radius": 40.0, --> Safe Zone Size.
      "ShowFactionPlayersOnMap": false, --> Enables/Disables seeing Faction members on built in map. LustyMap support is by default.
      "Use_AllowPlayersToCreateFactions": false, --> Enables/Disables the ability for players to create their own Factions.
      "Use_FactionAnnouncements": false, --> Enables/Disables Faction Announcements
      "Use_FactionChatControl": true, --> Enables/Disables Faction Chat. Does not impact Private Faction Chat or Faction Announcements
      "Use_FactionTags": true, -->Enable/Disable Faction Tag on chat messages.
      "Use_PlayerListMenu": false, --> Enables/Disables All Players Tab.
      "Use_PrivateFactionChat": true --> Enables/Disables Private Faction Chat
     
    FOR DEVELOPERS:

    Code (C#):
            [HookMethod("BroadcastOnScreen")]
            void BroadcastOnScreen(string message, ushort Faction, ushort Faction2 = 0)
            {
                BroadcastOnScreenFaction(message, Faction, Faction2);
            }

            [HookMethod("AssignToFaction")]
            bool AssignToFaction(ulong ID, ushort Faction)
            {
                if (!fdata.Players.ContainsKey(ID)) return false;
                BasePlayer Target = BasePlayer.FindByID(ID);
                if (Target == null)
                {
                    var PlayerData = fdata.Players[ID];
                    PlayerData.faction = Faction;
                    PlayerData.PendingInvites.Clear();
                    fdata.Factions[Faction].factionPlayers.Add(ID);
                    if (fdata.Factions[Faction].factionPlayers.Count() <= 1)
                        fdata.Factions[Faction].Leader = ID;
                    ConsoleSystem.Run(ConsoleSystem.Option.Server, $"usergroup add {ID} {fdata.Factions[Faction].group}");
                    SaveData();
                    Broadcast($"<color={GetMSG("JoinedFaction", null, fdata.Factions[Faction].ChatColor, GetDisplayName(ID), fdata.Factions[Faction].Name)}</color>");
                }
                else
                {
                    if (GetFactionPlayer(Target) == null) return false;
                    AssignPlayerToFaction(Target, Faction);
                }
                return true;
            }

            [HookMethod("ClearFactionPlayers")]
            void ClearFactionPlayers(ushort ID)
            {
                if (!fdata.Factions.ContainsKey(ID)) return;
                foreach (var player in fdata.Factions[ID].factionPlayers)
                {
                    try
                    {
                        var fp = GetFactionPlayer(BasePlayer.FindByID(player));
                        if (fp != null)
                            fp.Faction = 0;
                    }
                    catch
                    {
                        if (fdata.Players.ContainsKey(player))
                            fdata.Players[player].faction = 0;
                    }
                }
                fdata.Factions[ID].factionPlayers.Clear();
                SaveData();
            }


            [HookMethod("GivePlayerFactionGear")]
            bool GivePlayerFactionGear(BasePlayer player)
            {
                GiveFactionGear(player);
                return true;
            }

            [HookMethod("IsFaction")]
            bool IsFaction(ushort ID)
            {
                if (ID != 0 && fdata.Factions.ContainsKey(ID)) return true;
                return false;
            }

            [HookMethod("GetPlayerFaction")]
            object GetPlayerFaction(ulong ID)
            {
                if (fdata.Players.ContainsKey(ID) && fdata.Players[ID].faction != 0) return fdata.Players[ID].faction;
                return false;
            }

            [HookMethod("GetFactionInfo")]
            object GetFactionInfo(ushort ID, string request)
            {
                if (ID == 0 || !fdata.Factions.ContainsKey(ID)) return false;
                switch (request.ToLower())
                {
                    case "name":
                            return fdata.Factions[ID].Name;
                    case "tag":
                            return fdata.Factions[ID].tag;
                    case "group":
                            return fdata.Factions[ID].group;
                    case "embleem":
                            return fdata.Factions[ID].embleem;
                    case "description":
                            return fdata.Factions[ID].description;
                    case "chatcolor":
                            return fdata.Factions[ID].ChatColor;
                    case "uicolor":
                            return fdata.Factions[ID].UIColor;
                    case "members":
                            return fdata.Factions[ID].factionPlayers;
                    case "owner":
                            return fdata.Factions[ID].Leader;
                    case "moderators":
                            return fdata.Factions[ID].Moderators;
                    case "playercount":
                        return fdata.Factions[ID].factionPlayers.Count();
                    default:
                        return false;
                }
            }

            [HookMethod("GetFactionList")]
            List<ushort> GetFactionList()
            {
                if (fdata.Factions == null || fdata.Factions.Count < 1)
                    return null;
                List<ushort> list = new List<ushort>();
                foreach (var entry in fdata.Factions)
                    list.Add(entry.Key);
                return list;
            }

            [HookMethod("CheckSameFaction")]
            bool CheckSameFaction(ulong player1ID, ulong player2ID)
            {
                if (!fdata.Players.ContainsKey(player1ID) || !fdata.Players.ContainsKey(player2ID)) return false;
                var player1faction = fdata.Players[player1ID].faction;
                var player2faction = fdata.Players[player2ID].faction;
                if (player1faction == player2faction && player1faction != 0) return true;
                else return false;

            }
     
    Feel like supporting the Dev? Donate Here

    Images

    1. All Players Menu.PNG
    2. FactionMenu.PNG
    3. HomeMenu.PNG
    4. MapMenu.PNG
    5. Options.PNG
    redBDGR likes this.