Player Owned and Operated Stores (Updated)

Player Owned and Operated Stores (Updated)

Tebex Link : Mack-Scripts · Player Owned and Operated Stores

In-Game Description of the Store System for Players

The Store System in this game allows players to interact with, manage, and own virtual stores (such as saloons, blacksmiths, or general stores) within a dynamic open-world environment, likely inspired by a Western setting. Players can purchase items from stores, own and manage their own stores, restock inventory, withdraw earnings, and even engage in risky activities like robbing stores. The system is designed to enhance roleplay by providing an immersive economic experience where players can act as shopkeepers, customers, or outlaws.

c39c7978e8b334738fc0f91f729354d9f0fa88b4.pngHere’s a breakdown of what players can do and how the interface works:


What Players Can Do

  1. Visit Stores as Customers:
  • Players can approach any store (e.g., Valentine Saloon, St. Denis Blacksmith) marked by blips on the map and interact with an NPC vendor.
  • They can browse and purchase items (weapons or general items) from the store’s inventory, provided they have enough in-game cash.
  • Stores display item names, prices, and stock levels, allowing players to make informed purchases.
  1. Purchase and Own a Store:
  • Players can buy unowned stores for a set price (e.g., $10,000 for a saloon or $1,000 for a smaller store).
  • Once purchased, players become the store owner, granting them access to additional management options.
  1. Manage a Store (Owner Features):
  • Restock Inventory: Owners can add items from their personal inventory to the store’s stock, setting prices for each item.
  • Check Earnings: Owners can view and withdraw money earned from customer purchases.
  • Rename the Store: Owners can customize the store’s display name for a personalized touch.
  • Transfer Ownership: Owners can transfer the store to another player by entering their citizen ID.
  • Open the Store: Owners can access the store’s inventory to sell items to customers, similar to how customers interact with the store.
  1. Rob a Store:
  • Players can attempt to rob a store if they are armed, but this comes with risks:
    • A chance of failure (configurable, default 50%) may result in the NPC vendor fighting back.
    • Successful robberies allow players to steal a percentage of the store’s earnings (default 50%).
    • Robbed stores cannot be robbed again until a reset occurs (handled automatically when the resource starts).
  • A progress bar (default 7 seconds) appears during the robbery, requiring the player to stay in place.
  1. Interact with NPCs and Blips:
  • Stores are marked by blips on the map, with customizable names displayed based on the store’s configuration or owner-set names.
  • NPCs at each store location provide the interaction point for accessing the store menu.

How the Interface Works

The store system uses a combination of in-game prompts, a graphical user interface (GUI), and contextual menus to provide a seamless experience. Here’s how players interact with the system:

  1. Accessing the Store:
  • Players approach a store’s coordinates (listed in config.lua, e.g., Tumbleweed Saloon at -5517.45, -2907.88, -1.75) and see a prompt (e.g., “Interact with Store”).
  • Pressing the prompt key (default: J) opens the store menu if the player is within 4 units of the store’s NPC and not in a vehicle.
  1. Store Menu (Contextual Options):
  • The menu adapts based on the player’s role (customer, owner, or potential buyer):
    • Non-Owned Store (Customer): Options include:
      • Buy Store: Purchase the store for the listed price (e.g., $10,000 for Valentine Saloon).
    • Owned Store (Non-Owner): Options include:
      • Open Store: Browse and buy items.
      • Rob: Attempt to rob the store (requires a weapon).
    • Owned Store (Owner): Options include:
      • Open Store: View and sell items.
      • Restock: Add items from personal inventory to the store.
      • Check Money: View and withdraw earnings.
      • Manage: Rename the store or transfer ownership.
  • Menus are displayed using a context menu system (lib.registerContext) with clear titles, descriptions, and icons for each option.
  1. Store Inventory Interface (GUI):
  • When selecting “Open Store,” the interface opens a full-screen GUI (index.html, styled by style.css, controlled by script.js).
  • The GUI is divided into three sections:
    • Categories (Left Panel): Displays item categories (e.g., Weapons, General). Clicking a category filters the items shown.
    • Items (Center Panel): Shows a grid of items with their images, names, prices, and stock levels. Clicking an item highlights it and shows details.
    • Item Details (Right Panel): Displays the selected item’s image, name, price, stock, and a quantity input field with a “Buy” button.
  • Players can input the desired quantity (limited to available stock) and confirm purchases, which deducts cash and adds items to their inventory.
  • A “Close” button (×) or pressing the Escape key closes the GUI.
  1. Restocking and Management Inputs:
  • For restocking, owners select an item from their inventory, then input the quantity and price per item via a dialog box (lib.inputDialog).
  • For withdrawing money, owners input the amount to withdraw (up to the store’s earnings).
  • For renaming or transferring ownership, owners input a new name or citizen ID through dialog boxes.
  1. Visual and Interactive Elements:
  • The GUI features a Western-themed background image and a dark, semi-transparent design with red accents (style.css).
  • Scrollable panels ensure players can browse large inventories.
  • Item images are loaded dynamically from the rsg-inventory resource, with a fallback image if unavailable.
  • Notifications (RSGCore:Notify) inform players of successful actions (e.g., “You bought 2x Bread”) or errors (e.g., “Not enough money”).
  1. Robbery Mechanics:
  • When robbing, players must be armed and within 4 units of the NPC with a clear line of sight.
  • A progress bar appears during the robbery, and the NPC may either surrender (playing a “hands up” animation) or fight back if the robbery fails.
  • Success or failure is determined by a random chance (default 50% success rate).

Key Features for Immersion

  • Dynamic Ownership: Stores can be bought, sold, or transferred, creating a player-driven economy.
  • Customizable Stores: Owners can set item prices and names, tailoring their shops to the roleplay environment.
  • Risk vs. Reward: Robbing stores offers quick cash but risks combat with NPCs.
  • Persistent Data: The system uses a MySQL database (store_owner and store_items tables) to track ownership, money, and inventory, ensuring persistence across server restarts.
  • NPC Interaction: Stores are staffed by NPCs (e.g., bartenders, shopkeepers) that enhance the roleplay atmosphere.

Example Player Experience

  1. A player approaches the Valentine Saloon, sees a blip labeled “Valentine Saloon” on the map, and presses J near the NPC.
  2. If the store is unowned, they can buy it for $10,000. If owned, they can browse items or attempt a robbery.
  3. As a customer, they open the store GUI, select the “General” category, click on “Bread” ($5, 10 in stock), input a quantity of 2, and buy it, deducting $10 from their cash.
  4. As an owner, they restock the store with 5 apples from their inventory, set the price to $3 each, and later withdraw $50 of the store’s earnings.
  5. If they attempt to rob the store, they face a 50% chance of success. If successful, they earn half the store’s money; if not, the NPC fights back.

This system creates a rich, interactive economy where players can engage in commerce, management, or crime, all within an intuitive and visually appealing interface.

|-------------------------------------|----------------------------|
| Code is accessible | No |
| Subscription-based | No |
| Lines (approximately) | 1200 |
| Requirements | RSG/ox_lib |
| Support | Yes |