SFSharp is a C# plugin library and loader for SAMPFUNCS, another library/loader that provides C++ bindings for GTA San Andreas and SAMP.
- Download and copy
SFSharpLoader.sf
from the Releases page to theSAMPFUNCS
folder in your GTA SA installation directory. - Create a folder named
SFSharp
in your GTA SA installation directory. - Copy
.dll
plugins that you were supplied to theSFSharp
folder.
- Download and copy
SFSharpLoader.sf
from the Releases page to theSAMPFUNCS
folder in the game directory. - Create a folder named
SFSharp
in the game directory. - Create a new .NET 9+ C# class library project with NativeAOT support.
- Add a reference to the SFSharp NuGet package.
- Add the following code:
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using SFSharp;
public static class Program
{
[UnmanagedCallersOnly(EntryPoint = "SFSharpMain", CallConvs = [typeof(CallConvStdcall)])]
public static unsafe int SFSharpMain(CSharpExports* exports) => SFCore.Init(exports, Main);
public static async void Main()
{
}
}
- Go to town. Run a loop, use the
SFSharp.SF
class to do stuff, andawait Task.Yield()
/await Task.Delay(...)
to keep the game responsive. - When you're done, publish your project as a
win-x86
NativeAOT library, to theSFSharp
folder in the game directory.
- Build
SFSharpLoader
and copy the output to theSAMPFUNCS
folder in the game directory. - Create a new .NET 9+ C# class library project with NativeAOT support in the same solution.
- Add a reference to the
SFSharp
project in the solution. - Continue from step 5 in the previous section.