Continuation of the conversation from this ticket: https://codefling.com/files/support/18497-quarry-limit/
When I enter the console command "gq [steamID]" in the F1 console, the command works and a quarry is delivered.
When I enter the same command in the RCON console or when a player purchases an quarry from my shop, the command throws the following error message in console and does not give a quarry:
Failed executing console command 'gq' in 'Quarry Computer v1.4.1 by Marte6' [callback] (Object reference not set to an instance of an object)
at void Oxide.Plugins.QuarryComputer.GiveQuarryCommandCmd(Arg arg) in /home/container/carbon/plugins/QuarryComputer.cs:line 1277
at object System.Reflection.RuntimeMethodInfo.Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
After discussing this with the ShoppyStock developer, he has recommended a change to your code. You are checking for a null player, which doesn't work when the command is sent through the shop or RCON.
For example, In 1277 of your code, you are searching for Player() and in a console command the player is null and that is what is throwing the error.
[ConsoleCommand("gq")]
private void GiveQuarryCommandCmd(ConsoleSystem.Arg arg) => GiveQuarryCommand(arg.Player().IPlayer, "gq", arg.Args);
He suggests changing it to the following method instead:
[ConsoleCommand("gq")]
private void GiveQuarryCommandCmd(ConsoleSystem.Arg arg) => GiveQuarryCommand(arg.Player()?.IPlayer ?? null, "gq", arg.Args);
There are several areas in your code where this would need to be updated. I do not want to share the code with anyone to get it updated and I am not a developer myself. .Would you please review and make the corrections so that this can be used with different shop plugins and consoles?