leet.features

A script can switch client features on and off, change their settings and run one-shot actions, the same ones you find in the menu. The set is fixed: scripts can use only the names in the tables below.

Whatever a script changes changes as it would in the menu and can end up in the player's saved config. So remember the previous values and put them back in leet.events.onUnload.

Names

  • A feature has a name such as "player.godmode". It is either enabled (true) or disabled (false).
  • A setting belongs to a feature and is named "<feature>.<setting>", for example "player.godmode.bullet". Its value is a boolean or a number, depending on the setting.
  • An action is a one-shot command such as "vehicle.repair". It has no state; you run it with trigger.
  • Names are case-insensitive: "Player.GodMode" and "player.godmode" are the same feature.
  • Only the names listed below are available to scripts.

Changes behave like menu changes. Enabling a feature or changing a setting from a script is the same as doing it in the menu: the menu shows the new state at once, and if the player later saves their config, the change is saved too. A script that changes features should remember the previous values and restore them in leet.events.onUnload.

Available features

Toggles

Use get / set with a boolean.

FeatureDescription
player.anti_afkAnti-AFK.
player.godmodePlayer godmode. Its settings choose which damage types are blocked.
player.no_ragdollThe player does not ragdoll.
player.restore_healthKeeps the player's health topped up to the target value.
player.unlimited_staminaUnlimited stamina.
vehicle.godmodeVehicle godmode. Its settings choose which kinds of damage are blocked.
vehicle.autopilotAutopilot: drives the current vehicle to the map waypoint, or to the point given to leet.vehicle.driveTo.
remote_calls.event_logThe event logger: records the client's remote calls from the moment it is on (the menu's Development tab shows the log). Turn it off when you are done.

Settings

SettingTypeRangeDescription
player.godmode.bulletbooleanBlock bullet damage.
player.godmode.firebooleanBlock fire damage.
player.godmode.explosionbooleanBlock explosion damage.
player.godmode.collisionbooleanBlock collision damage.
player.godmode.meleebooleanBlock melee damage.
player.godmode.steambooleanBlock steam damage.
player.godmode.smokebooleanBlock smoke damage.
player.godmode.drownbooleanBlock drowning.
player.godmode.electricbooleanBlock the stun gun reaction.
player.restore_health.valuenumber101 to 200Target health. A player's health runs from 100 (dead) to 200.
vehicle.godmode.healthbooleanProtect vehicle health.
vehicle.godmode.bodybooleanProtect the body.
vehicle.godmode.enginebooleanProtect the engine.
vehicle.godmode.tyresbooleanProtect the tyres.
vehicle.godmode.wheelsbooleanProtect the wheels.
vehicle.godmode.lightsbooleanProtect the lights.
vehicle.godmode.doorsbooleanProtect the doors.
vehicle.godmode.glassbooleanProtect the windows.
vehicle.autopilot.speednumber0.1 to 500Autopilot speed, in m/s.
vehicle.autopilot.stop_rangenumber1 to 50Distance from the waypoint at which the autopilot stops, in meters.

Actions

Use trigger.

ActionDescription
player.clear_tasksClears the player's current tasks and animations (for example, to get unstuck).
vehicle.repairRepairs the current vehicle.
vehicle.flipPuts the current vehicle back on its wheels.

leet.features.get

TypeScript
leet.features.get(name: string): boolean | number | undefined

Reads a feature's state or a setting's value. For a feature it returns true (enabled) or false (disabled), for a setting its value (a boolean or a number). Never throws.

JavaScript
const parts = ['bullet', 'fire', 'explosion', 'collision', 'melee', 'steam', 'smoke', 'drown', 'electric']
    .filter((t) => leet.features.get(`player.godmode.${t}`));

mp.console.logInfo(
    `godmode: ${leet.features.get('player.godmode') ? 'on' : 'off'}, blocks: ${parts.join(', ') || 'nothing'}`
);

Parameters

  • name (string): a feature or setting name, case-insensitive.

Keep in mind

  • For an action, an unknown name, a name not available to scripts, or a name that is not a string, you get undefined.

leet.features.set

TypeScript
leet.features.set(name: string, value: boolean | number): undefined

Enables or disables a feature, or changes a setting. Returns nothing. The change behaves like one made in the menu, see Changes behave like menu changes.

JavaScript
leet.features.set('player.godmode', true);
leet.features.set('player.restore_health.value', 180);

Parameters

  • name (string): a feature or setting name, case-insensitive. Actions are not accepted.
  • value (boolean | number): for a feature, true enables it and false disables it. For a setting, a boolean or a number, as the setting's type in Settings requires. Numbers must be within the listed range.
ErrorWhen
leet: unknown featurename is unknown, not available to scripts, an action, or not a string.
leet: wrong value typevalue has the wrong type: for example a number for a boolean feature or setting, a boolean for a number setting, a string, or undefined.
leet: value out of rangevalue is a number outside the setting's range, or NaN / Infinity.

leet.features.trigger

TypeScript
leet.features.trigger(name: string): undefined

Runs a one-shot action, the same as pressing its button in the menu. Returns nothing.

JavaScript
leet.features.trigger('vehicle.repair');

Parameters

  • name (string): an action name from Actions, case-insensitive.

Errors: leet: unknown action (name is unknown, not an action, or not a string).

Recipes

Turn on protection while farming and restore everything on Stop

The script enables Anti-AFK, godmode and health restore while it runs, and puts every value back the way it was when the player presses Stop.

JavaScript
const wanted = {
    'player.anti_afk': true,
    'player.godmode': true,
    'player.godmode.bullet': true,
    'player.godmode.melee': true,
    'player.restore_health': true,
    'player.restore_health.value': 200,
};

// Remember the current values first.
const previous = {};
for (const name of Object.keys(wanted)) {
    previous[name] = leet.features.get(name);
}

for (const [name, value] of Object.entries(wanted)) {
    leet.features.set(name, value);
}
mp.console.logInfo('[farm] protections enabled');

leet.events.onUnload(() => {
    for (const [name, value] of Object.entries(previous)) {
        if (value !== undefined) leet.features.set(name, value);
    }
    mp.console.logInfo('[farm] previous settings restored');
});

The previous values are read before the first set, or there would be nothing to restore. The undefined check is there because get returns it for an unavailable name, and set with undefined throws leet: wrong value type.

Find out why set failed

JavaScript
function trySet(name, value) {
    try {
        leet.features.set(name, value);
        mp.console.logInfo(`set ${name} = ${value}`);
    } catch (e) {
        mp.console.logError(`set ${name} = ${value} failed: ${e.message}`);
    }
}

trySet('player.no_ragdoll', true);              // ok
trySet('player.flying_cars', true);             // leet: unknown feature
trySet('vehicle.repair', true);                 // leet: unknown feature (it is an action)
trySet('player.godmode.fire', 1);               // leet: wrong value type
trySet('player.restore_health.value', '150');   // leet: wrong value type
trySet('player.restore_health.value', 500);     // leet: value out of range
trySet('vehicle.autopilot.speed', NaN);         // leet: value out of range

Each line shows which error its case gives. The error text is in e.message.

Read and change the autopilot speed

JavaScript
const speed = leet.features.get('vehicle.autopilot.speed');
mp.console.logInfo(`autopilot speed: ${speed} m/s (${(speed * 3.6).toFixed(0)} km/h)`);

// 90 km/h, stop 10 m from the waypoint
leet.features.set('vehicle.autopilot.speed', 90 / 3.6);
leet.features.set('vehicle.autopilot.stop_range', 10);

leet.events.onUnload(() => {
    if (speed !== undefined) leet.features.set('vehicle.autopilot.speed', speed);
});

The speed is in m/s, so km/h is divided by 3.6. On Stop the script puts the previous speed back.

Repair the vehicle with a key

Pressing F6 in a vehicle repairs it.

JavaScript
const KEY_F6 = 0x75;

const onKey = () => {
    if (mp.gui.cursor.visible) return; // chat or a menu is open
    if (!mp.players.local.vehicle) {
        leet.ui.notify('You are not in a vehicle', 'warning');
        return;
    }
    leet.features.trigger('vehicle.repair');
    leet.ui.notify('Vehicle repaired', 'success');
};

mp.keys.bind(KEY_F6, true, onKey);

leet.events.onUnload(() => {
    mp.keys.unbind(KEY_F6, true, onKey);
});

The cursor check keeps the repair from firing while the player types in chat. The key is unbound in onUnload with the same function it was bound with.


Next: UI