ev_garbagesave

EV_GARBAGESAVE is a custom made ressource. Completely edited and changed to work properly and optimized.

EV Garbage System

The EV Garbage System introduces interactive dumpsters into your FiveM server, allowing players to throw away or retrieve items. This system uses ox_target, ox_inventory, and integrates with a database to manage unique stashes for each dumpster.


Configuration

The configuration defines the dumpster models, inventory attributes, and other parameters.

Dumpster Models

Defines the dumpster models that players can interact with.

Dumpster Attributes

Defines inventory settings for dumpsters.


Client-Side Functionality

ox_target Integration

The system uses ox_target to allow interaction with dumpsters.

This allows players to interact with dumpsters and opens the relevant stash inventory.


Client Events

Open Dumpster Stash

Triggered by the server when a stash is found or registered.


Server-Side Functionality

Registering a Stash

Registers a unique stash for a dumpster.


Database Management

Database Initialization

Creates a database table to track dumpsters.


Handle Stash Opening

Checks if a dumpster has an existing stash or creates a new one.


Lazy Register Stash

Registers a stash on-the-fly if it doesn’t already exist.


Usage Guide

Player Interaction

  1. Approach a dumpster that is part of the Config.DumpsterModels list.

  2. Use the ox_target interaction labeled "Throw something away."

  3. The system will:

    • Check if a stash already exists for the selected dumpster.

    • Open the relevant stash inventory for interaction.


Developer Notes

  1. Database Integration: Ensure your database is properly configured to support the garbage_bins table.

  2. Stash Management: All stashes are uniquely linked to dumpster coordinates, ensuring persistent storage.

  3. Custom Models: Add additional dumpster models to Config.DumpsterModels as needed.

  4. Inventory: Ensure ox_inventory is properly installed and configured.


Example Scenarios

Scenario 1: Existing Dumpster

  • A player interacts with a dumpster that already has a stash.

  • The system retrieves the stash from the database and opens it.

Scenario 2: New Dumpster

  • A player interacts with a dumpster that doesn’t have a stash.

  • The system registers a new stash, saves it in the database, and opens it for the player.


Last updated