I am thinking of starting a project for fivem in C#, I want to know the opinion of you who develop the most time, I started now in fivem, but I am already programmer to eight years
I want to know if it is possible for me to “connect” two dlls from C# even though they are in separate folders(if someone has an example I would be grateful)
and I want to know if C # has any problem / constraint
The only downside is that due to AppDomain (at least suspected), C# resources run at ~0.3ms idle.
But honestly, this doesn’t impact performance. I keep everything in one resource/solution, with a server,client and shared project.
Using exports to call functions in another resource (thus DLL).
Using Trigger x Event, which both works over net and locally. Prefer exports when you don’t have to send it over the network. Since exports use TriggerEvent under the hood.
Using some shared DLL which you can reference to is also an option. Not that the shared DLL is not a resource, just a normal DLL that has (preferably) no knowledge about the CitizenFX.* namespace.
Example from my code base:
//_awareness resource exposes the "GetPickpocketTarget" export/function.
public class AwarenessClient : BaseScript
{
PedIterator pedIterator = new PedIterator();
public AwarenessClient()
{
//Returns a handle (int) of the selected ped that is most suited to be pickpocketed.
Exports.Add("GetPickpocketTarget", new Func<int>(() => {
return pedIterator.GetPickpocketTarget();
}));
}
}
public class PopInteractionClient : BaseScript
{
private Ped pickPocketTarget;
public PopInteractionClient()
{
Tick += OnTick;
}
private async Task OnTick()
{
await Delay(250);
//Call the _awareness resource and invoke the "GetPickpocketTarget" function.
int pedHandle = Exports["_awareness"].GetPickpocketTarget();
pickPocketTarget = pedHandle > 0 ? new Ped(pedHandle) ? Game.PlayerPed;
}
}
This is also indeed a possibility but you cannot share living objects. A shared DLL is mainly used for things like common models, enums and helper classes