TavstalDev / TShop2

SQL based async item and vehicle shop plugin for Unturned 3
GNU General Public License v3.0
3 stars 0 forks source link

Uconomy Hook can't load with NGE_UconomyUI if Uconomy.dll is loaded before #4

Closed CatzMR closed 3 months ago

CatzMR commented 3 months ago

3 This problem has not been solved, and there seem to be more errors.

[TShop] [ERROR] > 1
[TShop] [ERROR] > 2
[TShop] [ERROR] > 2.1
[TShop] [ERROR] > 2.2 -> True, True
[TShop] [ERROR] > 2.3
[TShop] [ERROR] > 3
[TShop] [EXCEPTION] > Error in UEventHandler -> OnButtonClick(bt_tshop_basket#buy):
[TShop] [ERROR] > System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NotSupportedException: This function should only be called from the game thread. (e.g. from Unity's Update)
  at SDG.Unturned.ThreadUtil.assertIsGameThread () [0x0000c] in <f83070eac5d54878b08d445935d1639c>:0
  at SDG.Unturned.EffectManager.sendUIEffectText (System.Int16 key, SDG.NetTransport.ITransportConnection transportConnection, System.Boolean reliable, System.String childNameOrPath, System.String text) [0x00000] in <f83070eac5d54878b08d445935d1639c>:0
  at NGE_UconomyUI.NGE_UconomyUI.Instance_OnBalanceUpdate (Rocket.Unturned.Player.UnturnedPlayer player, System.Decimal amt) [0x00065] in <13773788ef014c1399f6ab653b9ecc2f>:0
  at fr34kyn01535.Uconomy.Uconomy.BalanceUpdated (System.String steamId, System.Decimal amt) [0x0001a] in <b4f0e80158ea4fe58a0911908e295254>:0
  at fr34kyn01535.Uconomy.DatabaseManager.IncreaseBalance (System.String id, System.Decimal increaseBy) [0x000a4] in <b4f0e80158ea4fe58a0911908e295254>:0
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <47fc8c70fa834cbf8141d7c1a7589125>:0
   --- End of inner exception stack trace ---
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00083] in <47fc8c70fa834cbf8141d7c1a7589125>:0
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <47fc8c70fa834cbf8141d7c1a7589125>:0
  at Tavstal.TShop.Compability.Hooks.UconomyHook+<>c__DisplayClass18_0.<WithdrawAsync>b__0 () [0x0003f] in <59b70cfb438f408c9b92fd38e534c34c>:0
--- End of stack trace from previous location where exception was thrown ---

  at Tavstal.TShop.Compability.Hooks.UconomyHook.WithdrawAsync (Steamworks.CSteamID player, System.Decimal amount, Tavstal.TLibrary.Compatibility.Economy.EPaymentMethod method) [0x0013d] in <59b70cfb438f408c9b92fd38e534c34c>:0
  at Tavstal.TShop.Handlers.UnturnedEventHandler.Event_OnButtonClick (SDG.Unturned.Player player, System.String button) [0x00f56] in <59b70cfb438f408c9b92fd38e534c34c>:0
TavstalDev commented 3 months ago

@CatzMR which Uconomy plugin do you use? Also what version of TLibrary do you have ? I could not reproduce the error. Ignore this:

[TShop] [ERROR] > 1
[TShop] [ERROR] > 2
[TShop] [ERROR] > 2.1
[TShop] [ERROR] > 2.2 -> True, True
[TShop] [ERROR] > 2.3
[TShop] [ERROR] > 3
CatzMR commented 3 months ago

I tried to update to the latest version of TSHOP, and the current errors are the following two. This is a console error when using the UI to perform purchase operations.

[TShop] [EXCEPTION] > Error in UEventHandler -> OnButtonClick(bt_tshop_basket#buy):
[TShop] [ERROR] > System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NotSupportedException: This function should only be called from the game thread. (e.g. from Unity's Update)
  at SDG.Unturned.ThreadUtil.assertIsGameThread () [0x0000c] in <f83070eac5d54878b08d445935d1639c>:0
  at SDG.Unturned.EffectManager.sendUIEffectText (System.Int16 key, SDG.NetTransport.ITransportConnection transportConnection, System.Boolean reliable, System.String childNameOrPath, System.String text) [0x00000] in <f83070eac5d54878b08d445935d1639c>:0
  at NGE_UconomyUI.NGE_UconomyUI.Instance_OnBalanceUpdate (Rocket.Unturned.Player.UnturnedPlayer player, System.Decimal amt) [0x00065] in <13773788ef014c1399f6ab653b9ecc2f>:0
  at fr34kyn01535.Uconomy.Uconomy.BalanceUpdated (System.String steamId, System.Decimal amt) [0x0001a] in <b4f0e80158ea4fe58a0911908e295254>:0
  at fr34kyn01535.Uconomy.DatabaseManager.IncreaseBalance (System.String id, System.Decimal increaseBy) [0x000a4] in <b4f0e80158ea4fe58a0911908e295254>:0
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <47fc8c70fa834cbf8141d7c1a7589125>:0
   --- End of inner exception stack trace ---
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00083] in <47fc8c70fa834cbf8141d7c1a7589125>:0
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <47fc8c70fa834cbf8141d7c1a7589125>:0
  at Tavstal.TShop.Compability.Hooks.UconomyHook+<>c__DisplayClass18_0.<WithdrawAsync>b__0 () [0x0003f] in <df1252318c234c54af8c9f53d7010294>:0
--- End of stack trace from previous location where exception was thrown ---

  at Tavstal.TShop.Compability.Hooks.UconomyHook.WithdrawAsync (Steamworks.CSteamID player, System.Decimal amount, Tavstal.TLibrary.Compatibility.Economy.EPaymentMethod method) [0x0013d] in <df1252318c234c54af8c9f53d7010294>:0
  at Tavstal.TShop.Handlers.UnturnedEventHandler.Event_OnButtonClick (SDG.Unturned.Player player, System.String button) [0x012d0] in <df1252318c234c54af8c9f53d7010294>:0

This is a console error when using the /buy command to perform a purchase operation.

NotSupportedException: This function should only be called from the game thread. (e.g. from Unity's Update)
  at SDG.Unturned.ThreadUtil.assertIsGameThread () [0x0000c] in <f83070eac5d54878b08d445935d1639c>:0
  at SDG.Unturned.EffectManager.sendUIEffectText (System.Int16 key, SDG.NetTransport.ITransportConnection transportConnection, System.Boolean reliable, System.String childNameOrPath, System.String text) [0x00000] in <f83070eac5d54878b08d445935d1639c>:0
  at NGE_UconomyUI.NGE_UconomyUI.Instance_OnBalanceUpdate (Rocket.Unturned.Player.UnturnedPlayer player, System.Decimal amt) [0x00065] in <13773788ef014c1399f6ab653b9ecc2f>:0
  at fr34kyn01535.Uconomy.Uconomy.BalanceUpdated (System.String steamId, System.Decimal amt) [0x0001a] in <b4f0e80158ea4fe58a0911908e295254>:0
  at fr34kyn01535.Uconomy.DatabaseManager.IncreaseBalance (System.String id, System.Decimal increaseBy) [0x000a4] in <b4f0e80158ea4fe58a0911908e295254>:0
  at (wrapper managed-to-native) System.Reflection.RuntimeMethodInfo.InternalInvoke(System.Reflection.RuntimeMethodInfo,object,object[],System.Exception&)
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x0006a] in <47fc8c70fa834cbf8141d7c1a7589125>:0
Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
  at System.Reflection.RuntimeMethodInfo.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00083] in <47fc8c70fa834cbf8141d7c1a7589125>:0
  at System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] in <47fc8c70fa834cbf8141d7c1a7589125>:0
  at Tavstal.TShop.Compability.Hooks.UconomyHook+<>c__DisplayClass18_0.<WithdrawAsync>b__0 () [0x0003f] in <df1252318c234c54af8c9f53d7010294>:0
--- End of stack trace from previous location where exception was thrown ---

  at Tavstal.TShop.Compability.Hooks.UconomyHook.WithdrawAsync (Steamworks.CSteamID player, System.Decimal amount, Tavstal.TLibrary.Compatibility.Economy.EPaymentMethod method) [0x0013d] in <df1252318c234c54af8c9f53d7010294>:0
  at Tavstal.TShop.CommandBuyItem.Execute (Rocket.API.IRocketPlayer caller, System.String[] args) [0x00397] in <df1252318c234c54af8c9f53d7010294>:0
  at System.Runtime.CompilerServices.AsyncMethodBuilderCore+<>c.<ThrowAsync>b__7_0 (System.Object state) [0x00000] in <47fc8c70fa834cbf8141d7c1a7589125>:0
  at UnityEngine.UnitySynchronizationContext+WorkRequest.Invoke () [0x00002] in <fcaf289839f24125a059795f150fce14>:0
  at UnityEngine.UnitySynchronizationContext.Exec () [0x00056] in <fcaf289839f24125a059795f150fce14>:0
  at UnityEngine.UnitySynchronizationContext.ExecuteTasks () [0x00014] in <fcaf289839f24125a059795f150fce14>:0
TavstalDev commented 3 months ago

@CatzMR What is NGE_UconomyUI.NGE_UconomyUI ? What Uconomy plugin do you use ? Because I only use TShop and the basic Uconomy plugin without any changes and I have zero buy or sell related errors.

CatzMR commented 3 months ago

plugin.zip NGE_UconomyUI.dll is the amount UI plugin.

TavstalDev commented 3 months ago

plugin.zip NGE_UconomyUI.dll is the amount UI plugin.

Tested TShop with both dlls, still no error. Could you send me the full log file instead of just a part of it ?

CatzMR commented 3 months ago

Server_WLHJ1F.log I'm currently testing the latest released version and this problem still exists.

TavstalDev commented 3 months ago

@CatzMR I checked the logs. TShop's init message is missing. Is this server based on RocketMod or OpenMod ?

CatzMR commented 3 months ago

RocketMod

CatzMR commented 3 months ago

Nothing is lost, just not printed to the log.

CatzMR commented 3 months ago

Rocket.log That one is Unturned's log, and this one is Rocketmod's log.

TavstalDev commented 3 months ago

@CatzMR Could you send me your libraries ? I would like to test the plugins with those.

CatzMR commented 3 months ago

Libraries.zip

TavstalDev commented 3 months ago

I still could not reproduce the errors on multiple computers.

CatzMR commented 3 months ago

I still could not reproduce the errors on multiple computers.

You can add the letter a before Uconomy.dll and rename it to aUconomy.dll. This will load the Uconomy plugin in advance. Only when Uconomy loads the NGE_UconomyUI plugin in advance will it have its effect. This may trigger the error on my server console.

TavstalDev commented 3 months ago

@CatzMR I could reproduce the error with renamed Uconomy.dll and NGE_UconomyUI, but It works fine with renamed Uconomy and without NGE_UconomyUI. So the problem is not with my plugin.

I checked NGE_UconomyUI's code and it should use hooks instead of just adding the Uconomy.dll to the references and calling its functions like that.