This guide expects that the reader already knows how to work with Visual Studio and how to set up and distribute FiveM resources.
- Create the solution and projects
- CLI, automatic:
* Higher Framework versions are possible, but Visual Studio may complain on some systems.
dotnet new sln -o MySolution chdir MySolution dotnet new classlib --target-framework-override net452 -o Client dotnet new classlib --target-framework-override net452 -o Server dotnet sln add Client Server xcopy %localappdata%\FiveM\FiveM.app\citizen\clr2\lib\mono\4.5\v2\Native\CitizenFX.FiveM.Native.dll Client\bin\ /Y /I :: for RedM: remove or comment out the above line and uncomment (remove ::) from below line ::xcopy %localappdata%\FiveM\FiveM.app\citizen\clr2\lib\mono\4.5\v2\Native\CitizenFX.RedM.Native.dll Client\bin\ /Y /I pause
- Manual:
Create a new C# Class Library (.NET Framework) and add another project in the solution for the missing server or client, also copy Native/CitizenFX.FiveM.Native.dll with your client project.
- CLI, automatic:
- Go into your <MySolution> directory and open the solution
- In Visual Studio you right click the project and Add -> Add Assembly Reference...
- Client FiveM:
CitizenFX.FiveM.dll and CitizenFX.Core.dll from
%localappdata%\FiveM\FiveM.app\citizen\clr2\lib\mono\4.5\v2\
, CitizenFX.FiveM.Native.dll frombin\
or where your copied it to. - Client RedM:
CitizenFX.RedM.dll and CitizenFX.Core.dll from
%localappdata%\RedM\RedM.app\citizen\clr2\lib\mono\4.5\v2\
, CitizenFX.RedM.Native.dll frombin\
or where your copied it to. - Server:
CitizenFX.Server.dll and CitizenFX.Core.dll from your server files<your server files>\citizen\clr2\lib\mono\4.5\v2\
.
- Client FiveM:
CitizenFX.FiveM.dll and CitizenFX.Core.dll from
- Replace the contents of both Class.cs files and preferably rename them as well
using CitizenFX.Core; //using CitizenFX.FiveM; // FiveM game related types (client only) //using CitizenFX.FiveM.Native; // FiveM natives (client only) //using CitizenFX.RedM; // RedM game related types (client only) //using CitizenFX.RedM.Native; // RedM natives (client only) //using CitizenFX.Server.Native; // Server natives (server only) //using CitizenFX.Shared.Native; // Shared natives (there for shared libraries) namespace MyLibrary.Client // probably update your default namespace as well { public class Class1 : BaseScript { } }
- Now you should have a solution with 2 projects, targeting .NET Framework 4.5.2 (or higher), and have all references correctly set up.
- Edit your fxmanifest.lua file and add the following to it:
mono_rt2 'Prerelease expiring 2023-06-30. See https://aka.cfx.re/mono-rt2-preview for info.'
* rt2 stands for runtime 2, as to not confuse it with a potential v2 of mono itself. * this flag is considered temporary and will be removed at some point. - Add your copy of CitizenFX.FiveM.Native.dll or CitizenFX.RedM.Native.dll (depending on your game) to the resource and also add it in your fxmanifest.lua as well, just like any other dll dependency