Add C# Server Side Documentation
I saw C# only had client-side Documentation, so I decided to spend a few hours documenting what I felt was the most important and useful for FiveM developers in C#.
This covers;
- Setting up the environment (using NuGet)
- Hooking events and using [FromSource]
- Server Callbacks
- MySQL
I think I explained everything in good detail, though this doc assumes the user read the client-side documentation first.
While we appreciate the effort, this seems to be having quite a bit of outdated/weird/wrong information. (for one, you should not. ever. use. the 'network callback' stuff. it's inherently broken and relies on a memory leak to work, which means you will experience lots of weird issues with it)
The C# docs already mention setting up a server script because the template does so already.
(I am currently not able to provide more detailed comments as I'm on my phone, just remarking to other project members that this should not be merged without a lot of rewriting!)
Hi,
I was 100% confused on whether to use NetworkCallbackDelegate or not, I saw a lot of people saying it didn't work, and a few others saying that CFX confirmed it working. I went with it because I have had no issues using it, but if there is an issue with it I understand.
Could you elaborate on anything else I may have confused so it can be corrected?
As an extra to the rewriting: don't use dynamic types unless you really need to make use of the dynamic-ness it offers.
dynamic is compiled to type object with a lot of extra IL code to make sure it can do all the stuff you do with it. This also makes JITting the code slower (I've seen freezes up to several seconds with some specific code). Better to use var (or the type) for local variable declarations and the exact type as parameters. Also, although small, object also has a (hidden) runtime pack/unpack cost. Better not teaching new programmers bad habits ;)
As an extra to the rewriting: don't use
dynamictypes unless you really need to make use of the dynamic-ness it offers.
dynamicis compiled to typeobjectwith a lot of extra IL code to make sure it can do all the stuff you do with it. This also makes JITting the code slower (I've seen freezes up to several seconds with some specific code). Better to usevar(or the type) for local variable declarations and the exact type as parameters. Also, although small,objectalso has a (hidden) runtimepack/unpackcost. Better not teaching new programmers bad habits ;)
Hi thorium,
The reason for using dynamic was that was how it is done in the playerConnecting event within the scripting reference. Though I did assume setKickReason could've been a string, I just didn't test it to confirm. I'll edit that shortly.
I completely agree it would be bad to teach bad habits!
The reason for using dynamic was that was how it is done in the playerConnecting event within the scripting reference. Though I did assume setKickReason could've been a string, I just didn't test it to confirm. I'll edit that shortly.
I see :thinking:
From looking into the source it looks like that parameter will be of type CallbackDelegate (CitizenFX.Core.CallbackDelegate to be precise). The deferrals on the other hand might just be better of as a dynamic, looks like that would be an ExpandoObject which is related to them.
Hello, I am just reading through this post. Since I am also interested in improving the docs.
Only unfortunately I notice that it is always mentioned how some elements like "NetworkCallBackDelegate" are deprecated, but no working alternative is mentioned.
Is there any update?
Going to close this, C# documentation will be improved later.