This resource allows entity variable data handling between entities only forwarded within dimension or stream range. It's currently functional on the following entities:
- player
- ped
- vehicle
This resource is created and maintained by the Project Unknown team and requires RAGE Multiplayer v1.1.
NOTE: This resource requires dependency Base in-order to process console logs (which might be removed in the near future). Otherwise remove any trace of mp.log
in this resource.
Check also the Base component module loader out which allows you to add multiple resources directly from git repositories as a submodule to your server project`s main git which helps you to expose parts of your server project to co devs without granting full repository access!
Entity variable data handling between entities and clients only forwarded within dimension or stream range. Useful to reduce the load and have better network optimization on other clients out of stream range.
Set a variable serverside which will only streamed to other players that are actually streaming the entity.
player.setVariableStreamed("test", 123);
Works for local and remote players on own client. If variable is not set it will return undefined
.
let result = player.getVariableStreamed("test");
Works for local and remote players on own client. If variable is not set it will await until it is not undefined anymore! If there is no interval waitTime specified it will be a 10ms interval.
let result = await player.getVariableStreamedAsync("test");
Works like the regular variable dataHandler except it will only announce updated streamed variables
mp.events.addDataHandlerStreamed("test", (entity, value) => {
mp.gui.chat.push("entity type: " + entity.type + " id: " + entity.remoteId + " changed its value: " + value);
});
NOTE: You can only add one streamed dataHandler per key for now.
Removes a previously created dataHandler for the case the same key is used in different situations.
mp.events.removeDataHandlerStreamed("test", (entity, value) => {
mp.gui.chat.push("entity type: " + entity.type + " id: " + entity.remoteId + " changed its value: " + value);
});
Globally synced variable data from entity to all clients in dimension. Usable to lower the load and have better network optimization for clients in other dimensions.
NOTE: This resourece only operates properly when using entity.setDimension(dim);
instead of entity.dimension = dim;
until RAGE Multiplayer implements an event that can detect dimension change.
(And when you are on it George: PLEASE add entityStreamIn => (entity, forPlayer)
and entityStreamOut => (entity, forPlayer)
server events triggering for player, peds and vehicles similar to the non working playerStreamIn
events serverside. Thanks! That would simplify this resource alot already!😏)
Sets entity dimension accoordingly.
Sets a dimension variable in the current entity's dimension. (presistant helps maintain the dimension variable across multiple dimension. When you change the dimension, the variable data will remain.)
player.setVariableDimension("giga", "chad");
Gets a dimension variable data of the entity.
player.getVariableDimension("giga"); // chad
Gets a dimension variable data of the entity.
mp.players.local.getVariableDimension("giga"); // chad
Async version of entity.getVariableDimension("key");
(async () => {
let data = await mp.players.local.getVariableDimensionAsync("giga");
})();
Works like the regular variable datahandler except it will only announce updated dimension variables
mp.events.addDataHandlerDimension("giga", (entity, value) => {
mp.gui.chat.push("entity type: " + entity.type + " id: " + entity.remoteId + " at dimension: " + entity.dimension + "changed its value: " + value);
});
Removes dimension dataHandler by key & function scope. If function scope wasn't specified, it'll delete all dataHandler functions related to the key.
const customCrap = (entity, value) => {
mp.gui.chat.push("entity type: " + entity.type + " id: " + entity.remoteId + " at dimension: " + entity.dimension + "changed its value: " + value);
};
mp.events.addDataHandlerDimension("krustyCrap", customCrap);
// mp.events.removeDataHandlerDimension("krustyCrap");
mp.events.removeDataHandlerDimension("krustyCrap", customCrap);