@haworth/menu-store
v0.0.9
Published
A visual store and cart system for samp-node servers.
Maintainers
Readme
@haworth/menu-store
A wrapper of the popular SA-MP MenuStore library for samp-node-
Getting started
pnpm add @infernus/core @haworth/menu-storeExample
import { type Player, PlayerEvent } from "@infernus/core";
import {
MenuStore_InitializeGameMode,
MenuStore_InitializePlayerEvents,
MenuStore_InitializePlayer,
MenuStore_AddItem,
MenuStore_Open,
MenuStore_Close,
MenuStore_IsOpen,
MenuStore_CleanupPlayer
} from "@haworth/menu-store";
// Initialize once on server start
GameMode.onInit(({ next }) => {
MenuStore_InitializeGameMode();
MenuStore_InitializePlayerEvents();
return next();
});
// When a player connects
PlayerEvent.onConnect(({ player }) => {
MenuStore_InitializePlayer(player);
});
// Example command to open the store
PlayerEvent.onCommandText("weaponshop", ({ player, subcommand, next }) => {
// Add items to the store for this player
MenuStore_AddItem(player, 1, 371, "Parachute", 500, "A parachute for jumping", 7.5, true, 1);
MenuStore_AddItem(player, 2, 355, "AK-47", 2500, "Automatic rifle", 7.5, true, 1);
// Open the store
MenuStore_Open(
player,
"gun_store",
"Weapon Shop",
(player, purchased, itemID, model, totalPrice, amount, itemName) => {
if (purchased) {
player.sendClientMessage(0x00FF00FF, `You bought ${amount}x ${itemName} for $${totalPrice}!`);
// Give the item to the player here
}
},
"$", // currency sign
"BUY" // confirm button text
);
});API
MenuStore_InitializeGameMode()
Initializes global store elements. Call once on server start.
MenuStore_InitializePlayerEvents()
Registers TextDraw events for all players. Call once on server start.
MenuStore_InitializePlayer(player)
Prepares the store system for a specific player. Call when a player connects.
MenuStore_AddItem(player, itemID, modelID, name, price, description?, descriptionSize?, descriptionLineJump?, stack?, rotX?, rotY?, rotZ?, zoom?)
Adds an item to the player's store inventory.
MenuStore_Open(player, storeID, storeName, callback, moneySign?, buttonConfirm?)
Opens the store for the player.
MenuStore_Close(player)
Closes the store for the player.
MenuStore_IsOpen(player)
Returns whether the store is open for the player.
MenuStore_CleanupPlayer(player)
Cleans up all store data for a player.
