BTPlugins / BTSignRestriction

Prevent players from editing signs they dont own and MUCH more!
0 stars 0 forks source link

Console error #1

Open CatzMR opened 3 weeks ago

CatzMR commented 3 weeks ago

The error on the console, I can't find what caused it

Exception invoking SDG.Unturned.InteractableSign.ReceiveChangeTextRequest from client steamid:76561199578771838:
Value cannot be null.
Parameter name: format
  at System.String.FormatHelper (System.IFormatProvider provider, System.String format, System.ParamsArray args) [0x0000
3] in <47fc8c70fa834cbf8141d7c1a7589125>:0
  at System.String.Format (System.String format, System.Object[] args) [0x00020] in <47fc8c70fa834cbf8141d7c1a7589125>:0

  at BTSignRestriction.Helpers.BaseHelpers.TranslationHelper.GetTranslation (System.String key, System.Object[] placehol
der) [0x0000c] in <4530e19f0afb44bb94b31ebbeaf146fb>:0
  at BTSignRestriction.Helpers.BaseHelpers.TranslationHelper.SendMessageTranslation (Steamworks.CSteamID playerId, Syste
m.String translationKey, System.Object[] placeholder) [0x00063] in <4530e19f0afb44bb94b31ebbeaf146fb>:0
  at BTSignRestriction.BTSignRestriction.onModifySignRequested (Steamworks.CSteamID instigator, SDG.Unturned.Interactabl
eSign sign, System.String& text, System.Boolean& shouldAllow) [0x00123] in <4530e19f0afb44bb94b31ebbeaf146fb>:0
  at (wrapper delegate-invoke) <Module>.invoke_void_CSteamID_InteractableSign_string&_bool&(Steamworks.CSteamID,SDG.Untu
rned.InteractableSign,string&,bool&)
  at (wrapper dynamic-method) SDG.Unturned.InteractableSign.SDG.Unturned.InteractableSign.ReceiveChangeTextRequest_Patch
2(SDG.Unturned.InteractableSign,SDG.Unturned.ServerInvocationContext&,string)
  at SDG.Unturned.InteractableSign_NetMethods.ReceiveChangeTextRequest_Read (SDG.Unturned.ServerInvocationContext& conte
xt) [0x00039] in <6b1f72456e95430bacde60da03e38772>:0
  at SDG.Unturned.ServerMessageHandler_InvokeMethod.ReadMessage (SDG.NetTransport.ITransportConnection transportConnecti
on, SDG.NetPak.NetPakReader reader) [0x00132] in <6b1f72456e95430bacde60da03e38772>:0

This is ChatGPT’s explanation:The error you're encountering occurs because a null value is being passed to the System.String.Format method as the format argument. The issue seems to originate from the BTSignRestriction plugin, specifically in the ReceiveChangeTextRequest function, when a player attempts to modify the text on a sign.

Key points:

  1. TranslationHelper.GetTranslation likely returns a null or invalid format string, which leads to the exception when it's passed to String.Format.
  2. The SendMessageTranslation function might not be handling cases where the key or placeholder values are missing or improperly formatted.
  3. The error occurs because String.Format requires a non-null format string.

Potential Fixes:

  1. Ensure that GetTranslation handles null or empty key and placeholder values correctly, returning a valid string at all times.

  2. Add a check before calling String.Format to ensure that the format string is not null:

    if (string.IsNullOrEmpty(format))
    {
       // Log the error or provide a default message
       format = "Default message";
    }
  3. If the plugin relies on configuration files, verify that all translation strings are correctly defined in the config, and there are no missing or malformed entries.

blazethrower320 commented 3 weeks ago

It looks like you made some changes to the TranslationsFile. Delete it and let it regenerate to see if it fixes the issue.