Skip to main content

Entity::setVariables

Server-side function

Set multiple custom data variables to an entity.

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​