roflmuffin / CounterStrikeSharp

CounterStrikeSharp allows you to write server plugins in C# for Counter-Strike 2/Source2/CS2
https://docs.cssharp.dev
Other
757 stars 115 forks source link

[docs][bug]Selectively loading plugins #155

Open yannickvr opened 9 months ago

yannickvr commented 9 months ago

I'm looking to selectively load plugins, using the css_plugins load command. A few issues:

css_plugins load plugins/disabled/WhatsUp gives the following error:

[Client] Could not load plugin "/home/steam/cs2-dedicated/game/csgo/addons/counterstrikesharp/plugins/plugins/disabled/WhatsUp/plugins/disabled/WhatsUp.dll"

css_plugins load plugins/disabled/WhatsUp/WhatsUp.dll works fine.

yannickvr commented 9 months ago

Suspect that the dll issue is somewhere around line 159 in Application.cs

mrc4tt commented 9 months ago

I agree with this, I have the same problem.

yannickvr commented 9 months ago

Reviewed the code, seems like expected behavior, though i think there's a case to be made that css can resolve the path with a little bit of extra code, might be worth it.

This is a snippet taken from application.cs

                    var path = info.GetArg(2);
                    if (!path.EndsWith(".dll"))
                    {
                        path = Path.Combine(_scriptHostConfiguration.RootPath, $"plugins/{path}/{path}.dll");
                    }
                    else
                    {
                        path = Path.Combine(_scriptHostConfiguration.RootPath, path);
                    }

path is normally the name of the plugin, so if you use css_plugins load MyPlugin it will try to load plugins/MyPlugin/MyPlugin.dll If a full path is given like css_plugins load plugins/disabled/WhatsUp/WhatsUp.dll only the root path is added.

Without the documentation or reviewing the code, I expected "css_plugins load disabled/MyPlugin" to work, but the current logic scrambles this because it thinks it should be searched in the default path.