Can you introduce me? Node.js developer here!

Hi ! I’m Vari, I’m a Node.js programmer and I’m 24 years old.

I worked with SA:MP about ten years ago (2010-12) but now I want to join FiveM. Thanks to SA:MP, I work as a programmer right now. I had a very complex roleplay server in that times (ZoneRol), so I know how to program, but…

Can you introduce me to the develop of a server in FiveM, with Node.js? I follow the tutorial of How to set up a server, how to create the /car command or put a ui page, I read about resources and manifest files, and so on.

But, the documentation is very poor… where to put the things? How to install things with npm? Where to put a gamemode or how to create unified resources? How to connect a Mongo or SQL db? Where is the native callbacks in the documentation? I need a lot of information to start develop my own server…

I want to create something like PUBG, because I think that game have an horrible performance / optimization.

If anyone is interested in help me, please answer this topic.

If the topic isn’t goes here, can an administrator move to the correct section? Thanks.

Bye!

2 Likes

Hello. I am just getting started making JavaScript server resources too, so forgive me I might not be very helpful. Actually I’m hoping answering your question frees someone up to answer one of mine…

So, you are running a FiveM server?
And you are able to access and play inside that server via the Localhost option in FiveM?
You are able to play on your own custom server, right?

If that is the case, I can explain how to add your own Node.JS based resources and run them on your server. This would enable your battle royale style game mode.

The scripting itself is quite easy once you get started, however as a fellow Node.js developer I would slow down on getting ahead of yourself with aspects such as NPM/mongo integration. In fact, once you have a server running one of your resources at the beginning and test that it loads, you will be 90% done with knowing how to make your game mode.

Good luck!

2 Likes

Hi there!

Thanks for the answer, it’s useful. Yeah, I’m running and playing in my own custom server.
I know how to put a JS resource and run it, but I did it inside a [local] folder, not inside [gamemodes].

Apart from that, what’s the difference between Client and Server scripts? Back in my times, we have only one file called gamemode.pwn (Pawn extension) and gamemode.amx (AMX, to run it).
Today these doesn’t exists any more.

For example, back in my times I had callbacks, for example OnPlayerConnect (when a player connect to the server), OnPlayerPickUpPickup (when a player pickup a pickup icon), OnPlayerEnterVehicle and so on… but these callbacks doesn’t exists in FiveM.

I’m a little bit confused, but I think I’m going to improve my understanding of the FiveM ecosystem…

2 Likes

Okay great! I can help clarify, hopefully…

When you run a FiveM server, your resources/extensions get loaded by two things:

  1. Clients/players, who connect to the server, recieve Client scripts.
  2. The server, which people are connecting to, runs the Server script.

The ‘Client’ file has access to the game engine, so you can run these commands which are specific to FiveM, and also run ‘Client Native Commands’ from the game. The list is here. Native functions give you access to virtually every piece of functionality coded into GTAV - you will not struggle to find functonality here…

All of your players are running your Client script when they connect, so you can use Native Commands to see when players have picked things up or gotten into cars…

OnPlayerConnect, OnPlayerPickUpPickup and OnPlayerEnterVehicle callbacks aren’t availiable in FiveM as you mentioned, but you can make your own implementations very easily using native commands and client scripts. (Actually to be fair I think detecting players joining/leaving is a Server script thing…)

I’ll be back later if you need specific help on managing detecting players joining/leaving or entering vehicles/collecting things etc… but please do have another go at the documentation and some implementations yourself before I start pasting code here for you to struggle with. If I start pasting code, it is pointless unless you understand it anyway.

Good luck! Hopefully that was somewhat useful!

2 Likes

You are awesome! Thanks for the info. I will be trying some things this week, and I will be sharing with you my research / results. See you then!

:slight_smile:

3 Likes

Glad I could help! Keep us posted, and welcome to the CFX/FiveM community!

2 Likes