Any tips for contributing to FiveM source code?

Hello, first of all sorry if this is the wrong place in the forum, but not sure where else to put this. All things seem server related.

Basically I would like to contribute to the FiveM source code. I have already forked the repository and set everything up on my end by following the directions given in the repository. For now I am most interested in making more functionality for server-side entity stuff on One-Sync. I am going to list out the things of my concern, but any tips would be helpful as there does not seem to be much info on this stuff and code is also not much documented? So here I go:

  1. Once I set up the whole fork on my PC and followed all the steps. I opened up CitizenMP.sln, but in here a project seems missing called: “citizen-server-impl” and so it seems like I cannot build that specific project? It kind of sucks right now, because I have to manually open “citizen-server-impl” folder in “Components” folder. Since I want to contribute here, I have to keep shooting in the dark when I want to compile, by pushing to GitHub and having a pull request. One of the tests that are performed on GitHub I see does perform compilation on “ServerGameState_Scripting.cpp” and this is the file I want to contribute to. There has to be a better way to do this?

  2. Is there a way to test my code in game? Or is this something only staff have access to? Maybe there is a way to fire up a server from this?

Any tips, info would be greatly appreciated about working on the source code. I have yet to work on something of this scale and complexity, but I am willing to learn and put the time and effort into this just need a jump start.

Also if anyone is willing to have a conversation with me in private on Discord just to answer more questions if they come up or explain workflow in more detail, let me know.

1 Like

Make sure you ran premake with --game=server you should be able to compile it and run the server (make sure to copy components.json and remove svadhesive)

3 Likes

Oh wow well that was stupid of me haha Now it makes more sense I opened Visual Studio and now I can see the proper project. Thank you for letting me know about the --game=server I will try this out and come back if I have any issues. Thanks again!

So seems like the building part is taken care of and I can successfully start the server. Took a little bit of messing around. But now I am running into more specific coding issue… I am currently making a function in: ServerGameState_Scripting.cpp and using the RegisterNativeHandler:

fx::ScriptEngine::RegisterNativeHandler("GET_VEHICLE_PED_IS_IN", makeEntityFunction([](fx::ScriptContext& context, const std::shared_ptr<fx::sync::SyncEntityState>& entity)

So all good is here, now I read that in order to test this on my end I need to call it like this:

Function.Call<int>(Hash.GET_VEHICLE_PED_IS_IN, playerPed);

This is where I have an issue, it seems that I need a hash for this, because the compiler is giving me an error. I found the hashes to other natives in CitizendFX.Core.cs file in the public enum Hash : ulong

But how do I come up with a hash for my own function that I have just made?? Otherwise it seems that I cannot test this. Am I missing something? If someone can explain this to me Barney style would be great! Thank you.

(Hash)GetHashKey(...) or such until you have your native appear in citizenfx/natives (from a PR or manually building it).

2 Likes

Ok thank you!

Sweet so I actually got some code to run and test, awesome! Now what if I want to dive deeper and try to figure out how some natives in GTA are built and disassemble them. Can anyone give me some tips for it? What files need to be disassembled, can all of them be found in my installation folder? Any useful videos/threads to watch/read? I have downloaded the free version of IDA, will this work or a paid one is needed?

I found some video disassembling a file on youtube called default.xex to prove that a “jetpack” was supposed to come out back in like 2014, but that is not in my installation folder.

Here is a git for some decompiled scripts:

1 Like

Damn that is pretty sweet, thanks a lot!

If anyone has some info about the disassembly part, that would be also cool.

Yea unfortunately, I don’t know much about doing that yet.

But here is a decompiler:

But as far as identifying what functions do what, you’ll have to search if anyone has documented it anywhere and if not, it’s part of the puzzle still that needs to be solved and contributed to the cfx project.

Hope this helps you with your journeys and I cannot wait to see what you come up with :+1:

1 Like

This stuff that you are giving me is great, seems like a lot of great stuff in the decompiled script git repository. Definitely will help me with creating some of the scripts for my own server!

Thanks for sharing all of this with me, I am excited myself. I was used to making SAMP servers and that was closed source, but this being open source is just great. Instead of complaining about something, I can actually go ahead and try getting hands dirty myself :ok_hand:

1 Like

I still need some help to figure out how to use the IDA, to decompile the DataNode’s. I am trying to make server-side getters from both the PlayerAppearance node (Pichot gave me decompiled script for this, so that helps a lot) and CPlayerWantedAndLOSDataNode, to get information about players wanted level etc. Its a real pain in the ass to just have the NetObjViewer in the client to work with, as I cannot see how many bits is each specific value, so I have to keep guessing and checking. I have put the GTAV.exe into the decompiler. I am at this part right now:
image

If I I double click any of these and press f5 to get pseudo code, it yells at me that it’s not within a function. Can anybody guide me a little?

Ok so here I am like half a year later, trying to get the source code to compile on my new PC. No luck. Tried re-reading the steps 4 times, while re-cloning repository and following all the steps (for the server-side). These are the errors I get when trying to compile:

Anybody know what the culprit could be? Or point me to which step I could of done wrong? These are also my environment variables PATH system variable:


And the BOOST_ROOT system variable: