Entity::setVariables

From RAGE Multiplayer Wiki
Jump to navigation Jump to search

Server-Side
Function

Js.png JavaScript



Set multiple custom data variables to an entity.

JavaScript Syntax
Jslogo.png

Syntax

entity.setVariables({'variable1': value1, 'variable2': value2});

Example

This creates a vehicle and sets multiple variables upon creation

Server-Side
mp.events.addCommand('car', (player) => {
    mp.vehicles.new(mp.joaat('turismor'), player.position);
});

mp.events.add("entityCreated", (entity) => {
    if(entity.type === "vehicle"){
        entity.setVariables({
            "miles": 0,
            "fuel": 100
        });
    }
});


See More