A modified version of vcmp-dotnet to support Windows and with some fixes and improvements.
vcmp-dotnet is a collection of softwares that allow you to script Vice City: Multiplayer servers in any language that supports targeting CoreCLR (C#, F# and VB.Net for example).
This readme file is currently oriented towards the native API binding and may be updated when the wrapper module is released.
- Fix
GetPlayerName
,GetPlayerIP
,GetPlayerUid
methods - Fix incorrect CoreClr path for windows version of .NET Core
- Implementing a full API wrapper
- Implementing crash handler system
- Visual Studio 2019
- .NET Core 2.0 (Runtime and SDK) or newer
- .NET Stantard 2.0 (Runtime and SDK) or newer
Project | Solutions/Projects location |
---|---|
Host plugin | /loader/build/dotnet-vcmp.sln |
Native bindings interoperability library | /interop/Fleka.DotnetVcmp.Interop.csproj |
small WIP API wrapper library | /wrapper/Fleka.DotnetVcmp.csproj |
You need to have a file called dotnet.json
in your server's root.
This is a list of keys the file must contain:
Key | Description |
---|---|
clr.runtime-directory |
The directory that contains libcoreclr.so/coreclr.dll. |
clr.server-executable |
The path to the server binary. |
clr.assemblies-directory |
The path to your .NET managed assemblies. |
clr.native-image-assemblies-directory |
Same as the above but for native image assemblies. |
clr.native-dll-search-directories |
The directory to search for dynamic libraries. |
app-domain.friendly-name |
The friendly name of the default AppDomain. |
Here is an example dotnet.json
file:
{
"clr": {
"runtime-directory": "C:/Program Files/dotnet/shared/Microsoft.NETCore.App/3.0.0",
"server-executable": "./server64.exe",
"assemblies-directory": "./dotnet-assemblies",
"native-image-assemblies-directory": "",
"native-dll-search-directories": ["C:/libs"]
},
"app-domain": {
"friendly-name": "Example dotnet-vcmp configuration"
}
}
You need to place Fleka.DotnetVcmp.Interop.dll
in your assemblies directory. Add Fleka.DotnetVcmp.Interop
library to your project.
The interoperability DLL executes an entry point with the following signature:
void EntryPointDelegate(PluginFunctions pluginFunctions, ref PluginCallbacks pluginCallbacks)
To designate a function as the entry point, add [Fleka.DotnetVcmp.Interop.EntryPoint]
before its definition.
IMPORTANT
Assigning a function to
pluginCallbacks
will not increase its reference count. If you are passing a collectable function (such as a lambda), you must keep a reference to it elsewhere as well.
Compile this C# code into a .NET managed DLL (with Fleka.DotnetVcmp.Interop
as a dependency) and place both of them in your assemblies directory.
public static class MyTestApp {
private static Fleka.DotnetVcmp.Interop.PluginFunctions _pluginFunctions;
[Fleka.DotnetVcmp.Interop.EntryPoint]
public static void MyEntryPoint(Fleka.DotnetVcmp.Interop.PluginFunctions pluginFunctions, ref Fleka.DotnetVcmp.Interop.PluginCallbacks pluginCallbacks) {
_pluginFunctions = pluginFunctions;
pluginCallbacks.OnServerInitialize = OnServerInitialize;
}
internal static byte OnServerInitialize() {
_pluginFunctions.LogMessage("%s", "Hello world");
return 1;
}
}