Jump to content

Shared World Data 1.1.0

   (3 reviews)

About This File

If you ever used GTA Network's setWorldSyncedData/SetWorldSharedData, you probably have an idea of what this resource does. If you haven't used those, this resource lets you set variables that will be synced to all clients.



  • Put the files you downloaded in their respective places
  • Add require('worlddata') to client_packages/index.js, preferably as the first module you require
  • All done



There isn't much to it, you can do one of these to set shared data:

mp.world.data.myDataKey = myValue;
mp.world.data["myDataKey"] = myValue;

you can do one of these to get shared data:


and you can do one of these to remove shared data:

delete mp.world.data.myDataKey;
delete mp.world.data["myDataKey"];

(1.1) now you can do this to set multiple shared data at once, thanks to @kemperrr:

mp.world.setData(updatedObject); // see examples

You can use setting/deleting code on clientside as well but it won't affect the data on serverside. If anything your changes will get overriden when myDataKey is updated, so there's no point in using setting/deleting code on clientside.


Events (Clientside)

// worldDataReady is called when the player receives all shared data.
mp.events.add("worldDataReady", () => {
    // Example, print all data keys to chat
    mp.gui.chat.push(`World data ready! ${Object.keys(mp.world.data).join(",")}`);

// worldDataChanged is called when shared data changes.
mp.events.add("worldDataChanged", (key, oldValue, newValue) => {
    // Example, show which data key changed with its old and new value
    mp.gui.chat.push(`World data changed: ${key} | old: ${oldValue} | new: ${newValue}`);

// worldDataRemoved is called when shared data is removed.
mp.events.add("worldDataRemoved", (key) => {
    // Example, show which data key got removed
    mp.gui.chat.push(`World data removed: ${key}`);


Example (Serverside)

let gameSeconds = 0;

// Increase gameSeconds every second and update the world data every 5 seconds, for no reason...
setInterval(() => {

    if (gameSeconds % 5 === 0) {
        // You can use mp.world.data["exampleVariable"] as well
        mp.world.data.exampleVariable = gameSeconds;
        console.log(`exampleVariable is now ${mp.world.data.exampleVariable}`);
}, 1000);
// Will update serverUpdated, serverName, serverWebsite shared data.
    "serverUpdated": Date.now(),
    "serverName": "RAGE Multiplayer Server #545"
    "serverWebsite": "https://rage.mp/"

Source code is available on GitHub in case you don't want to download: https://github.com/root-cause/ragemp-world-data

What's New in Version 1.1.0   See changelog


This feature was contributed by @kemperrr.

- Added mp.world.setData(updatedObject) which provides a nice & efficent way to update multiple shared data.

// Example: Will update serverUpdated, serverName, serverWebsite shared data.
    "serverUpdated": Date.now(),
    "serverName": "RAGE Multiplayer Server #545"
    "serverWebsite": "https://rage.mp/"


  • Like 2

User Feedback

Create an account or sign in to leave a review

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

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

  • Create New...