Fougerite Official

Fougerite Official 1.9.7

No permission to download
  • Left a debug msg in
  • Fixed HurtEvent issues in Fougerite and Rust++
  • You should update immediately.
New Research Hook:
Be sure to repatch the assembly with the patcher. (I also included a prepatched assembly)
Class
JavaScript:
// Jint2 and Magma
function On_Research(ResearchEvent)
{
    if (ResearchEvent.Player.Name != "god")
    {
        ResearchEvent.Cancel();
        ResearchEvent.Player.Message("Hah! You're not god!");
        ResearchEvent.Player.Message("You can't get: " + ResearchEvent.ItemName);
    }
}
Python:
def On_Research(self, ResearchEvent):
    if ResearchEvent.Player.Name != "god":
        ResearchEvent.Cancel()
        ResearchEvent.Player.Message("Hah! You're not god!")
        ResearchEvent.Player.Message("You can't get: " + ResearchEvent.ItemName)
Code:
function On_Research(ResearchEvent):
    if (ResearchEvent.Player.Name ~= "god") then
        ResearchEvent.Cancel()
        ResearchEvent.Player.Message("Hah! You're not god!")
        ResearchEvent.Player.Message("You can't get: " .. ResearchEvent.ItemName)
    end
end
Data Class Additions:
Added Data.ToUlong(string)
Added Data.Tolong(string)​
Util Class Addition:
Util.BlueprintOfItem(ItemDataBlock item) - Returns you BlueprintDatablock​
GlitchFix:
GlitchFix is now modified and It is even faster now. (Using LINQ)​
MoonSharp:
Lua Engine was modified a bit to handle stuffs automatically​
Others:
Py, Jint, Magma was also modified.
Added: fougerite.save console command which saves the server and also saves Rust++ If It's enabled
Added: fougerite.rustpp console command which should reload Rust++​

  • Minor modification for all engines
Lots of additions I have to say, so here we go:

MoonSharp Engine (LUA 5.2) was added.
This means you can develope with LUA now, but the plugins only support Fougerite hooks atm. I'm planning to add some sort of Oxide plugin compatibility.​
Patcher was modified.
You should repatch I did some major patching to stabilize the server​
Engine Updates.
Jint,Magma, IronPython is now having an auto command registration feature, which means It will only call the hooks which contains the command that you typed. This register is working 100%, unless the plugin uses custom commands. (Taking the command names out of an INI or a DataStore) Fougerite detects that, and will call all the hooks for that command like It did before. This can be solved by doing:
Code:
Plugin.CommandList.Add(commandname)
at plugin init.

Magma, Jint, MoonSharp received the advanced timer feature which is based on IronPython's.
For Magma and Jint I had to create a variable for that.
Here is the class
To reach this in Magma or Jint:
JavaScript:
function On_PlayerConnected()
{
    var ConnectionData = Plugin.CreateDict();
    ConnectionData["Player"] = Player;
    // Launch a void after 10 seconds
    Plugin.AdvancedTimers.CreateParallelTimer("Connect", 10000, ConnectionData).Start();
}

function ConnectCallback(timer)
{
    timer.Kill();
    var data = timer.Args;
    var player = data["Player"]
    player.Message("I called a timer for you 10 seconds ago!");
}
For Lua:
Code:
function On_PlayerConnected(Player)
    local ConnectionData = Plugin.CreateDict()
    ConnectionData["Player"] = Player
    -- Launch a void after 10 seconds
    Plugin:CreateParallelTimer("Connect", 10000, ConnectionData).Start()
end

function ConnectCallback(timer)
    timer:Kill()
    local data = timer.Args
    local player = data["Player"]
    player:Message("I called a timer for you 10 seconds ago!")
end
Server Class modifications:
I added two lists.
One of them is able to disable calling specific commands for the player. (CommandCancelList)
The 2. one is a list which you can add commands to, and this will also force Fougerite to call all the hooks for the specific command. (ForceCallForCommands)
Class is here
  • Player Property is now available in the InventoryAdd/Remove event
  • Autoban for radiation hackers
  • ClientMove hook for C# users
  • Modified patcher, please re-patch
  • Added an Entity.MaxHealth property
  • Fougerite Ban check/methods are now fixed, and I'm now checking if you are banned OnPlayerApproval event
  • RustPP API got some extras
C#:
        public bool HasPermission(string perm)
        {
            return AdminClass.HasPermission(perm);
        }

        public bool IsAdmin(ulong uid)
        {
            return Administrator.IsAdmin(uid);
        }

        public bool IsAdmin(string name)
        {
            return Administrator.IsAdmin(name);
        }

        public Administrator GetAdmin(ulong userID)
        {
            return Administrator.GetAdmin(userID);
        }

        public Administrator GetAdmin(string name)
        {
            return Administrator.GetAdmin(name);
        }
  • New messages were requested by a user in RustPP, so here It is.
INI:
startermsg=You have spawned a Starter Kit!
startercdmsg=You must wait awhile before using this..
  • Fougerite.dll and RustPP.dll were updated.
  • Fougerite now uses the GlobalBanlist and checks if the player is banned on connection
  • Improved the Ban methods in the Server class
  • RustPP got two new config options (Included in the new config file, Join and Leave message values):
INI:
[Settings]
rust++_enabled=true
chatname=Rust++
help_string1=Chat Commands: /help /location /history /pm /r /players /starter /ping /share /unshare
help_string2=/friends /addfriend /unfriend /about
admin_help_string1=Admin Commands: /addadmin /addflag /addwl /announce /ban /getflags /give /i
admin_help_string2=/god /instako /kick /kill /loadout /mute /reload /saveall /tphere /tpto
admin_help_string3=/unadmin /unban /unfriend /unflag /unmute /location player|all
time=12
airdrop_count=5
starterkit_cooldown=60
shutdown_countdown=60
voice_proximity=true
chat_history_amount=6
keepitems=false
friendly_fire=true
joinmsg=has joined the server
leavemsg=has left the server
default_admin_flags=CanKick|CanTeleport|CanAnnounce|CanGetFlags|CanMute|CanUnmute|Moderator
  • I patched HumanController which bypasses the teleportation hack. Do a repatch. I made a config option in Fougerite.cfg (BanOnInvalidPacket=true) You should update your Fougerite.cfg ... If this option is false, the player will be kicked only.
INI:
[Fougerite]
; uncomment to disable Fougerite, to disable version announce at login,
; or to enable structure and deployed item decay
;enabled=false
;tellversion=false
;deployabledecay=true
;structuredecay=true
;
; Remove players from cache after they disconnect.
RemovePlayersFromCache=false
BanOnInvalidPacket=true

[Modules]
;module = folder
; if a module needs no folder, just use any word, or no word
; you can change folder names to suit your needs
; only modules listed in [Modules] are loaded
; comment out a module to disable it
; Запись должна быть следующего вида: имя_модуля=папка_для_конфигов
; Загружаются только модули, перечисленные в разделе [Modules]
; Закомментируйте строку с плагином чтобы отключить его
RustPP=Rust++
GlitchFix=GlitchFix
MagmaPlugin=Magma
JintPlugin=JsPlugins
IronPythonModule=PyPlugins

[Logging]
; Fougerite logs are in PublicFolder\Logs
; Putting these false will still do the logging, but
; the console won't display them
debug=false
error=true
exception=true
  • Inventory event.. Seems like there is no way to get the looter or the inventory event. Atleast I haven't found one yet. I'm working on it. Same for the airdrop event.
  • Last time I forgot to tell that I created two reflection methods in the Util class, that plugin devs can use.
C#:
        public object GetInstanceField(Type type, object instance, string fieldName)
        {
            BindingFlags bindFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic
                | BindingFlags.Static;
            try
            {
                FieldInfo field = type.GetField(fieldName, bindFlags);
                object v = field.GetValue(instance);
                return v;
            }
            catch (Exception ex)
            {
                Logger.LogError("[Reflection] Failed to get value of " + fieldName + "! " + ex.ToString());
                return null;
            }
        }

        public void SetInstanceField(Type type, object instance, string fieldName, object val)
        {
            BindingFlags bindFlags = BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic
                | BindingFlags.Static;
            FieldInfo field = type.GetField(fieldName, bindFlags);
            try
            {
                field.SetValue(instance, val);
            }
            catch (Exception ex)
            {
                Logger.LogError("[Reflection] Failed to set value of " + fieldName + "! " + ex.ToString());
            }
        }
I couldn't fix the Airdrop patching yet.

New Hooks:


SteamDeny. This might make you bad boys :3
Parameter class
Python:
def On_SteamDeny(self, SteamDenyEvent):
        Server.Broadcast(SteamDenyEvent.ClientConnection.UserName + "is failing to connect. " +
                         str(SteamDenyEvent.ErrorNumber))
JavaScript:
function On_SteamDeny(SteamDenyEvent)
{
    Server.Broadcast(SteamDenyEvent.ClientConnection.UserName + "is failing to connect. " +
                         SteamDenyEvent.ErrorNumber);
}
PlayerApproval. Runs before PlayerConnected event.
Parameter class
Python:
def On_PlayerApproval(self, PlayerApprovalEvent):
        Server.Broadcast("About to deny? " + str(PlayerApprovalEvent.AboutToDeny))
JavaScript:
function On_PlayerApproval(PlayerApprovalEvent)
{
    Server.Broadcast("About to deny? " + PlayerApprovalEvent.AboutToDeny);
}
Some other things I did:

Server class
C#:
        public void BanPlayer(Fougerite.Player player)
        {
            IniParser ini = GlobalBanList;
            ini.AddSetting("Ips", player.IP, player.Name);
            ini.AddSetting("Ids", player.SteamID, player.Name);
            ini.AddSetting("NameIps", player.Name, player.IP);
            ini.AddSetting("NameIds", player.Name, player.SteamID);
            ini.Save();
            player.Disconnect();
        }

        public void BanPlayerIP(string ip, string name = "1")
        {
            IniParser ini = GlobalBanList;
            ini.AddSetting("Ips", ip, name);
            ini.AddSetting("NameIps", name, ip);
            ini.Save();
        }

        public void BanPlayerID(string id, string name = "1")
        {
            IniParser ini = GlobalBanList;
            ini.AddSetting("Ids", id, name);
            ini.AddSetting("NameIds", name, id);
            ini.Save();
        }

        public bool IsBannedID(string id)
        {
            IniParser ini = GlobalBanList;
            if (ini.ContainsSetting("Ids", id))
            {
                return true;
            }
            return false;
        }

        public bool IsBannedIP(string ip)
        {
            IniParser ini = GlobalBanList;
            if (ini.ContainsSetting("Ips", ip))
            {
                return true;
            }
            return false;
        }

        public bool UnbanByName(string name)
        {
            var id = ReturnACNByName2(name);
            var ip = ReturnACNByName(name);
            if (id == null)
            {
                return false;
            }
            IniParser ini = GlobalBanList;
            name = id;
            var iprq = ini.GetSetting("NameIps", ip);
            var idrq = ini.GetSetting("NameIds", id);
            ini.DeleteSetting("Ips", iprq);
            ini.DeleteSetting("Ids", idrq);
            ini.DeleteSetting("NameIps", name);
            ini.DeleteSetting("NameIds", name);
            ini.Save();
            return true;
        }

        public bool UnbanByIP(string ip)
        {
            IniParser ini = GlobalBanList;
            if (ini.ContainsSetting("Ips", ip))
            {
                var name = ini.GetSetting("Ips", ip);
                ini.DeleteSetting("Ips", ip);
                ini.DeleteSetting("NameIps", name);
                ini.Save();
                return true;
            }
            return false;
        }

        public bool UnbanByID(string id)
        {
            IniParser ini = GlobalBanList;
            if (ini.ContainsSetting("Ids", id))
            {
                var name = ini.GetSetting("Ids", id);
                ini.DeleteSetting("Ids", id);
                ini.DeleteSetting("NameIds", name);
                ini.Save();
                return true;
            }
            return false;
        }

        public string ReturnACNByName(string name)
        {
            IniParser ini = GlobalBanList;
            string l = name.ToLower();
            var ips = ini.EnumSection("NameIps");
            foreach (string ip in ips)
            {
                string n = ini.GetSetting("NameIps", ip).ToLower();
                if (l.Equals(n))
                {
                    return ip;
                }
            }
            return null;
        }

        public string ReturnACNByName2(string name)
        {
            IniParser ini = GlobalBanList;
            string l = name.ToLower();
            var ids = ini.EnumSection("NameIds");
            foreach (string id in ids)
            {
                string n = ini.GetSetting("NameIds", id).ToLower();
                if (l.Equals(n))
                {
                    return id;
                }
            }
            return null;
        }