1. Hello,

    I recently put in more logging for my server into Logger made by Wulf. I specifically wanted logging for chest looting, which i have made, there is a problem though, but a rare one.

    Here is the logger code:

    Code:
            void OnLootEntity(BasePlayer player, BaseEntity entity)
            {
                if (player == null) return;
                if (entity == null) return;            if (logLoot) Logg("loot", Lang(player.displayName + " (" + player.UserIDString + ")" + " has started looting " + entity + " at " + entity.transform.position));
            }
    Error code:

    Code:
    Failed to call hook 'OnLootEntityEnd' on plugin 'Logger v2.0.4' (FormatException: Input string was not in a correct format.)
      at System.String.ParseFormatSpecifier (System.String str, System.Int32& ptr, System.Int32& n, System.Int32& width, System.Boolean& left_align, System.String& format) [0x00000] in <filename unknown>:0
      at System.String.FormatHelper (System.Text.StringBuilder result, IFormatProvider provider, System.String format, System.Object[] args) [0x00000] in <filename unknown>:0
      at System.String.Format (IFormatProvider provider, System.String format, System.Object[] args) [0x00000] in <filename unknown>:0
      at System.String.Format (System.String format, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.Logger.Lang (System.String key, System.String id, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.Logger.OnLootEntityEnd (.BasePlayer player, .BaseEntity entity) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.Logger.DirectCallHook (System.String name, System.Object& ret, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Plugins.CSharpPlugin.InvokeMethod (HookMethod method, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.CSPlugin.OnCallHook (System.String name, System.Object[] args) [0x00000] in <filename unknown>:0
      at Oxide.Core.Plugins.Plugin.CallHook (System.String hook, System.Object[] args) [0x00000] in <filename unknown>:0 
    Now this does not happen to every single player, in fact only to one specific player. Every time this said player is involved and some sort of entity need's to be called, it ends in a similar error. I have even put in null checkers, but still gives errors.

    Though i have managed to find out that the "entity" part in the logger string, is causing it. So it is when it calls for the entity. I have even done if statements, but it still ends in this error. I have tried everything i could think of, but in vain.

    I'd appreciate any help i get.
     
  2. Wulf

    Wulf Community Admin

    They isn’t a hook error, it is with your message that you are trying to format. My guess is your attempt at making the entire entity object a string.
     
  3. Alright, but how come it only happens to a specific player? And how can i prevent it from happening?
     
    Last edited by a moderator: Sep 23, 2017
  4. Does that specific player have certain special characters in his or her name? It is possible that the special characters are breaking the formatting causing that FormatException.
     
  5. His name is "{MDA} Trippin". I tried out to join with "{}" in my name, but it did not cause the same issue. But perhaps it hadn't updated yet...
     
  6. Wulf

    Wulf Community Admin

    You'd need to strip those, escape them, or not use string formatting with that. Oxide does have a string.Sanitize method for this purpose.
     
  7. Alright, i'll check it out, thanks!