Jump to content

Question about server commands

Pending 1.3.0

PhoenixAphaAlex

Posted

Hello,

I noticed that if the chinook is disabled during a tier, then the PowerPlantEvent plugin which uses the chinook during the event does not work
and returns a NullReferenceException when the chinook is supposed to appear.

To solve this problem, I tried to add a command to disable the plugin on tier where the chinook is disabled, and add the load of the plugin from the tier where it is enabled.

But it would seem that at the time when the command must be executed, it does not work.

In the console I get :
Command 'c.unload PowerPlantEvent' not found

The commands used are those of Carbon:

"Server Commands": [
          "c.unload PowerPlantEvent"
        ]

 

"Server Commands": [
          "c.load PowerPlantEvent"
        ]


How to solve this problem?
Thank you in advance ! 🙂

ninco90

Posted

Hi! If events are disabled, or for example, an item is locked, it cannot be used by any plugin on the server because the entity is deleted. This can cause other event plugins to not work properly if the event itself contains a locked item.

I don't have an easy way to make this possible, and I don't want to make the code too complex.

PhoenixAphaAlex

Posted

Actually, as I explained, the idea is to be able to use the "Server Commands" section to unload plugins that do not work well during periods when events are disabled, but obviously the commands are not recognized (Command 'c.unload PowerPlantEvent' not found in console).
Is there no way to solve just this problem?

ninco90

Posted

carbon or oxide?

c.unload for carbon

o.unload for oxide

PhoenixAphaAlex

Posted

Yes, Carbon

"Server Commands": [
          "c.unload PowerPlantEvent"
        ]

And when the command is triggered by the plugin, in the console :

Command 'c.unload PowerPlantEvent' not found

ninco90

Posted

That's strange, could you try carbon.unload? Other users also use carbon and haven't reported anything like this to me.

PhoenixAphaAlex

Posted

Hi,
I just tried again by changing the command, and unfortunately it still does not work... 🥲
The same message appears in the console when I reload TiersMode and it executes the commands for the current tier :

Command 'carbon.unload PowerPlantEvent' not found

My new config :
 

"Server Commands": [
          "carbon.unload PowerPlantEvent"
        ]

And yet, if I manually run the command from the console, it works very well.
I don't understand why...

PhoenixAphaAlex

Posted

I managed to solve the problem by modifying the ExecuteCommands function with a proposal made by GPT.
It is certainly far from being "clean" but it works for my case.

Replace (line 1146-1154) :
 

        private void ExecuteCommands(){
            foreach (var cmd in listCommand){
            	var command = cmd;
                #if CARBON
                	command = command.Replace("o.", "c.").Replace("oxide.", "c.");
                #endif
                Server.Command(command);
            }
        }


By :
 

        private void ExecuteCommands()
        {
            foreach (var cmd in listCommand){
                var command = cmd;
                Puts("Executing command: " + command); // Log the command being executed
                
                #if CARBON
                    // If the command does not start with "carbon.", replace "o." and "oxide." with "c."
                    if (!command.StartsWith("carbon.")) {
                        command = command.Replace("o.", "c.").Replace("oxide.", "c.");
                    }
                #endif
                
                try {
                    // Check if the command is a plugin command
                    if (command.StartsWith("carbon.unload")) {
                        string pluginName = command.Replace("carbon.unload ", "");
                        Puts("Attempting to unload plugin: " + pluginName);
                        Interface.Oxide.UnloadPlugin(pluginName);
                    } 
                    else if (command.StartsWith("carbon.load")) {
                        string pluginName = command.Replace("carbon.load ", "");
                        Puts("Attempting to load plugin: " + pluginName);
                        Interface.Oxide.LoadPlugin(pluginName);
                    } 
                    else if (command.StartsWith("carbon.reload")) {
                        string pluginName = command.Replace("carbon.reload ", "");
                        Puts("Attempting to reload plugin: " + pluginName);
                        Interface.Oxide.ReloadPlugin(pluginName);
                    }
                    else {
                        Puts("Running command via ConsoleSystem: " + command);
                        ConsoleSystem.Run(ConsoleSystem.Option.Server, command);
                    }
                }
                catch (Exception ex) {
                    Puts("Error executing command: " + ex.Message);
                }
            }
        }


It would appear that the use of:

Interface.Oxide.UnloadPlugin(pluginName);

Instead of :

Server.Command (command);

Be sufficient for the load, unload and reload commands to work.

 

ninco90

Posted

Quite interesting, because I actually had to modify this to make it compatible with Carbon a while ago. I'm in touch with the Carbon developer to find out the best way to proceed for Carbon.

Thanks for sharing this information.

  • Like 1
1.8m

Downloads

Total number of downloads.

8.2k

Customers

Total customers served.

123.5k

Files Sold

Total number of files sold.

2.5m

Payments Processed

Total payments processed.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.