Jump to content
RAGE Multiplayer Community

[Part 2] Coding a simple resource [NodeJS/VSC]


Recommended Posts

Disclaimer: If you dont know where to start, please go to: 

So, you got NodeJS and Visual Studio Code running? Good, let's start coding!

Step 1: Files

RESOURENAME is a placeholder. Name id how you want your Resource should be called, like Roleplay-Gamemode.

Open Visual Studio Code in the C:/RAGEMP/server-files/packages folder. Then, create a folder named RESOURENAME (Change that). In that folder, we create a file called index.js.  At that point, Visual Studio Code should look like this:


Step 2: Making a base

In RESOURENAME  create a file called commands.js 

Now head to index.js and type in following:


With that statement, we tell our resource that it should load the file called commands.js. You can to that even for folders, like:


 Step 3: Lets code!

Javascript is a script language. That means, we don't need much constructers. Lets use that!:

We want to make the simplest and most helpfull command: A /vehicle command! How we do that? Well, if you got into javascript, its not complicated.

With the power of autocomplete, try to achieve following:

mp.events.addCommand("vehicle", (player, vehicle) => {


So, mp is a const. That means, its a variable that we cant change. events is a property of mp. And addCommand is a method. addCommand has the following usage:

mp.events.addCommand(commandName, (player, args) => {


commandName is self-explaining, player too. But whats  args?

args are our aguments. That means, we can add howmany we want. Our command above will be executed like this:


/vehicle Alpha

So, got that? Lets move on!

Now we want that a vehicle spawns if we use that command, todo so:

mp.events.addCommand("vehicle", (player, vehicle) => {
    mp.vehicles.new(mp.joaat(vehicle), player.position);

So, like before,  mp is our constvehicles is a property of mp. And new is a method. same for mp.joaat().  mp is our const, and joaat is a method that returns a number.

player is a variable, and position a property. position is from type mp.Vector3. Vectors are positions in RAGEMP, and our function mp.vehicles.new has the following usage:

mp.vehicles.new(model, position, options?);

Whats options? ? If a variable has a ? behind, that means its optional. So you dont need to set that.

Lets safe everything, and it should work!

If you got questions, look at the Wiki! (https://wiki.rage.mp/index.php?title=Main_Page)

Here are some usefull Wiki pages:




Stay tuned for Part 3!

  • Like 5
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...