Rage.mp Programming - 02 - Variable Data with Commands

What is Rage Multiplayer?

Rage Multiplayer is a multiplayer client for Grand Theft Auto V. Rage multiplayer uses various native functions to create a seamless multiplayer experience for Grand Theft Auto V. Although it is not endorsed by Rockstar games in any way, you still must buy the game in order to play Rage Multiplayer.

Getting Started

To setup a project visit the Rage Wiki and setup for C#. These tutorials will be primarily focusing on the C# aspect of the server. You can visit the wiki here.


In the last post we learned about writing a simple command using a built in C# Attribute for Commands. The basic idea of a command:

public class MyCustomResource : Script
    public void CmdSetHealth(Client client, int amount) 
        client.Health = amount;

Now in the API for Rage's C# side you're able to use a getData and setData property with any entity. An entity is defined as a client, object, vehicle, weapon, etc.

If we have a command for the client entity type that adjusts the client's money we can do the following:

public class MyCustomResource : Script
    public void CmdSetMoney(Client client, int amount) 
        client.setData("Money", amount);

This basic command will let us add a temporary 'money' variable that is attached to the player.

We can check the balance of the player by doing:

var money = client.getData("Money");

Generally you should cast the type if we know what it's going to be.

int money = Convert.ToInt32(client.getData("Money"));

So what else can we use this getData and setData for?

Well we can create temporary personalized vehicles with a command.

So here's a basic framework for spawning a vehicle and attaching it to the player.

This script essentially allows the player to only have one vehicle spawned at a time.

public class MyCustomResource : Script
    public void CmdCreateVehicle(Client client, string vehicleType) 
          // Cast the string to a uint type for the built in vehicle hash key finder.
          uint vehicleCode = NAPI.Util.GetHashKey(vehicleType);
          // VehicleCode, Position, Rotation, Color, Color2 
          Vehicle newVehicle = NAPI.Vehicle.CreateVehicle(vehicleCode, client.Position.Around(5), 0, 45, 45);
          // Check if the player has a data variable for Vehicle and if they do delete the old vehicle. If not assign a new vehicle.
          if (client.hasData("Vehicle"))
               Vehicle oldVehicle = client.getData("Vehicle") as Vehicle;
               if (oldVehicle.exists)
          client.setData("Vehicle", newVehicle);

That's the brief summary of using getData, setData, hasData and attaching them to entities.

Go Back


Made by Stuyk