Skip to content

playerStartInteractionRequest

Asks your gamemode when a player presses Enter at a vending machine, a food cart or hotdog van, a gym machine, or one of your own objects created with interactive: true. Allow it and the game’s own activity runs; refuse it and nothing happens. Refuse it and run your own activity instead with the player functions (money, health, animations).

Renamed in 0.28 from interactionRequest; see renamed names.

server.on("playerStartInteractionRequest", ({ player, interactionKind, objectId, defaultMoneyCost, defaultHealthGain }) =>
boolean | void | Promise<boolean | void>)
Name Type Description
id string The use’s ID, a decimal string. It becomes the Interaction’s ID when allowed.
interactionKind "vending" | "food-cart" | "hotdog-truck" | "gym-bench" | "gym-bike" | "gym-dumbbells" | "gym-treadmill" | "script-object" What the player wants to use.
objectId number Which one: the machine or cart’s number in the game, the hotdog van’s network ID, or your object’s ID. Unique together with interactionKind.
player PlayerSnapshot The player, as they were when they asked.
playerId number The player’s ID.
model number The object’s GTA:SA model.
interior number Its interior, 0 outside.
position Vector3 Where it stands.
scriptObject ScriptObject or absent Your object, for script-object.
gymIntensity 0 | 1 | 2 The gym machine’s intensity; 0 for everything else.
defaultMoneyCost number What the game charges: $1 for vending and street food, $0 for the gym and your objects.
defaultHealthGain number The health the game gives: +30 for vending (when the drink is finished), +50 for street food, 0 for the gym.

false refuses the use. true, or nothing, allows it. The first false stops the handlers after it. See how decisions work.

What an allowed use does:

  • Vending machine: $1 off the player’s HUD money and +30 health when the drink is finished.
  • Street food: $1 and +50 health at once.
  • Gym: no money or health. With the stats rule on, a finished session of ten seconds or more adds muscle or stamina and takes off fat.
  • Your object: nothing; the use ends straight away. Run your own effect in interactionStarted.

Turn off some vending machines.

gamemodes/my-mode.ts
import { server } from "nativemp";
const brokenMachines = new Set([0, 3]);
server.on("playerStartInteractionRequest", ({ interactionKind, objectId }) =>
!(interactionKind === "vending" && brokenMachines.has(objectId)));