[Request]How to create a c# script for fivem, how to imports the libraries

I want to create a private server (just for fun) and all the scripts in c# because I saw that c# is supported in fivem, but I don’t know where to start.
If i want to create a c# script, is it possible? The script is just a .cs file, or there is something else?
Are there any libraries to import in my .cs file?
All the scripts I saw (not many) are written in lua.
If the script can be written only in lua, what can i use c# for?

Sorry if there are any mistakes because I’m not english.

Thank you for your answers.

A bit outdated but it showed me the way so you should figure it out as well:
Thersy’s guide

Thanks, I could not find that anyware.

Well first off, I dont know your experiance but I will go over a few things basic things first, you will need to get used to (nativeDB / fivem references), you will use these to know what functions/hashes to use I prefer to use the fivem version since it shows everything very nicely edited.

NativeDB:
http://www.dev-c.com/nativedb/

FiveM Native Referance:
https://runtime.fivem.net/doc/reference.html

Now comes server editing and client editing, so basically as you can reference the citizenFX lib found in your fivem install directory at
FiveM Application Data > citizen > clr2 > lib > mono > 4.5 > CitizenFX.core.dll
Now you can use the namespaces
citizenFX.Core;
citizenFX.Core.native;
citizenFX.Core.UI;
citizenFX.Core.NaturalMotion;

This gives you access to client side scripting and all its goodies, however, for the server side you will need to download the new FXserver (only the fx server supports c# server scripting) from https://runtime.fivem.net/artifacts/fivem
you can then extract it and set a reference at
FXserver > citizen > clr2 > lib > mono > 4.5 > citizenFX.core.dll
Now you can use the namespaces
citizenFX.Core;
citizenFX.Core.native;

This gives you access to server scripts for registering commands or telling clients to do something etc…

Now when you build your scripts you need to build them as a dll and when you save them you must make sure they are saved with .net in them like so: scriptname.net.dll. @mraes link shows you how to do it automatically. There isnt alot of c# guides out there but other useful links I tend to use include:

Animation name lists:
http://docs.ragepluginhook.net/html/62951c37-a440-478c-b389-c471230ddfc5.htm

ScriptHookDotNet wiki: (basic tips on c# modding)

And of course the fivem wiki:
https://wiki.fivem.net/wiki/Main_Page

2 Likes

Thank you very much.
I alredy use fxserver and the correct link to download is this: /artifacts/fivem/ / FiveM Artifacts
But I have a problem.
I have imported the citizen.FX.core.dll but i can use only this 2 options
citizenFX.Core;
citizenFX.Core.native;
and not
citizenFX.Core.UI;
citizenFX.Core.NaturalMotion;
Do you now why?<img

Does anyone have the citizenFX.core.dll file in which you are sure that there are citizenFX.Core.UI and citizenFX.Core.NaturalMotion?

That’s for server only, the lib in the fx server is for server scripting only so you don’t have access to client things. You must use the other lib I listed to make client scripts.

Found it.
Thanks.
I didn’t read that it was under fivem application data.

No problem, good luck with your scripts!

Thanks and thank you for your support

1 Like