[Tutorial] Creating a C# Script / Resource

Below is a video I recently made to help C# developers get started with their FiveM scripting journey. I decided to make this video because I would like to see more people taking advantage of the amazing C# programming language within FiveM scripting and I also made this video because, in some regards, the FiveM documentation is still lacking some of the fundamentals. Though the FiveM documentation has come a long way, I still feel a video like I have created could be beneficial to some people, especially those who benefit from visual learning. All constructive feedback is encouraged and appreciated, thank you and I hope this can be of use to some people.

https://youtu.be/HDHyqvUibIM

11 Likes

Noice work.

1 Like

Looks good.

1 Like

C# love over here! Nice one

2 Likes

niice

1 Like

You mention that the docs for the chatMessage event are wrong. But they’re not wrong at all. The arguments for a chat message object are string author, object color, string message (for example: "Vespura", {255, 255, 255}, "This is my message")

The event contains <client id>, <author>, <color>, <message>.

Also, the string splitting for making a command is a really old way of doing things. I suggest you use RegisterCommand at all times. There are a number of advantages to using RegisterCommand over the chatMessage event.

2 Likes

Thank you. I will have to look into using RegisterCommand, for some reason I thought that was deprecated or no longer functioning.

1 Like

RegisterCommand may not work with custom chat resources, but since the new chat templates system was introduced there’s no need for a custom chat resource anyway. And you can easily add support for RegisterCommand in any old custom chat resource if you absolutely have to use that specific resource.

1 Like

Hello i have problem with TriggerEvent "‘Player’ does not contain a definition for ‘TriggerEvent’ and no accessible extension method ‘TriggerEvent’ accepting a first argument of type ‘Player’ could be found (are you missing a using directive or an assembly reference?)"
Thank you

Did you perhaps reference the wrong library?

From what you’re saying, it sounds like you meant to add the serverside CitizenFX .dll file instead of the clientside one. You need to specify references for each project separately =)