# Shop System

## Introduction

Hate Shop is a comprehensive and highly configurable shopping system designed for FiveM servers. The script provides a seamless shopping experience with features like categorized items, payment options, job-specific shops, item licensing requirements, and detailed logging.

### Key Features

* **Multiple Shop Types**: Configure various shop types like 24/7, Gas Stations, Ammu-Nation, Police Equipment, etc.
* **Job Requirements**: Restrict certain shops to specific jobs and ranks
* **Licensing System**: Weapon license checks for restricted items
* **Payment Options**: Support for both cash and bank card payments
* **Customizable UI**: Clean and responsive interface with search functionality
* **Multi-Language Support**: Built-in support for English and Turkish, easily extendable
* **Detailed Logging**: Discord webhook integration for purchase logging
* **Framework Support**: Compatible with both ESX and QBCore frameworks

## Installation

1. **Download the Resource**
   * Download the Hate Shop resource
2. **Place in Resources Folder**
   * Extract the files to your server's resources folder
   * Recommended path: `resources/[licensed]/[hate]/hate-shop/`
3. **Configure the Script**
   * Edit the `config.lua` file to match your server's requirements
   * Set your preferred framework (`"esx"` or `"qbcore"`)
   * Configure shop locations, item categories, and prices
   * Set your Discord webhook URL for logging if desired
4. **Update Server Config**

   * Add the following line to your `server.cfg`:

   ```
   ensure hate-shop
   ```
5. **Item Images**
   * Ensure your inventory system has images for the items
   * The script uses the path specified in `Config.UISettings.imagePath`
   * Default fallback image can be configured in `Config.UISettings.defaultImagePath`

## Configuration

### Framework Configuration

In `config.lua`, set your preferred framework:

```lua
-- Framework selection: "esx" or "qbcore"
Config.Framework = "qbcore"

-- Language setting: "en" for English, "tr" for Turkish
Config.Language = "en"
```

### Shop Types

Configure different types of shops with specific categories and job requirements:

```lua
Config.MarketTypes = {
    ["24/7"] = {
        title = "24/7 Store",
        categories = {"food", "drinks", "snacks", "alcohol", "misc", "farming"}
    },
    ["PoliceShop"] = {
        title = "Police Equipment Store",
        categories = {"police_equipment", "police_weapons", "police_ammo"},
        jobRequired = "police",
        minGrade = 0
    },
    -- Add more market types as needed
}
```

### Categories and Items

Define categories and their items with prices and special requirements:

```lua
Config.Categories = {
    {
        id = "weapons",
        name = "Weapons",
        items = {
            {id = "weapon_glock17", price = 15000.00, license = true},
            {id = "weapon_m9", price = 17500.00, license = true},
            -- Add more weapons
        }
    },
    {
        id = "police_weapons",
        name = "Police Weapons",
        items = {
            {id = "weapon_stungun", name = "Taser", price = 1500.00},
            {id = "weapon_carbinerifle", name = "Police Rifle", price = 8000.00, minGrade = 3},
            -- Add more police weapons
        }
    },
    -- Add more categories
}
```

### Market Locations

Set up shop locations around the map:

```lua
Config.MarketLocations = {
    {coords = vector3(25.7, -1347.3, 29.49), name = "24/7 Store", type = "24/7", blip = true},
    {coords = vector3(452.47, -980.03, 30.69), name = "LSPD Equipment Store", type = "PoliceShop", blip = false},
    -- Add more locations
}
```

### Discord Logging

Configure Discord webhook for purchase logging:

```lua
Config.Logging = {
    enabled = true,
    webhookURL = "YOUR_DISCORD_WEBHOOK_URL",
    botName = "Market System",
    botImage = "https://i.imgur.com/tgwQJTX.png",
    color = 3447003,
    footerText = "Market System - Sales Logs",
    footerIcon = "https://i.imgur.com/tgwQJTX.png"
}
```

## Usage

### Player Commands

* `/market [type]` - Opens a specific market type (Admin/debug command)

### Opening Shops

Players can interact with shop locations by approaching them and pressing the E key (default interaction key).

### Shop Interface

1. **Browsing Items**:
   * Items are organized by categories
   * Use the search bar to find specific items
   * Click on a category to expand/collapse it
2. **Adding to Cart**:
   * Left-click on an item to add it to the cart
   * Right-click on an item to view detailed information
   * Control quantities from the cart panel
3. **Checkout**:
   * Click "Pay" to proceed to checkout
   * Select payment method (Cash or Card)
   * Confirm the purchase

## Adding Custom Languages

To add a new language, edit the `languages.lua` file and add your translation:

```lua
Languages["your_language_code"] = {
    ui = {
        title = "Your translation for Shop",
        cart = "Your translation for Cart",
        -- Add more UI translations
    },
    notifications = {
        -- Add notification translations
    },
    -- Add more translation categories
}
```

Then update the language setting in `config.lua`:

```lua
Config.Language = "your_language_code"
```

## Technical Information

### Dependencies

* ESX or QBCore framework
* Inventory system that provides item images

### Resource Usage

* CPU: Low to Medium
* Memory: Low

## Troubleshooting

### Common Issues

1. **Items not displaying properly**
   * Ensure your item IDs match those in your inventory system
   * Check that the image path in config is correctly set
2. **Payment not working**
   * Verify that the framework setting matches your server (ESX or QBCore)
   * Check server console for any error messages
3. **Job restrictions not working**
   * Ensure job names in config match exactly with your jobs system

### Support

For additional support, please contact through the official support channels provided with your purchase.

## Security Notice

This script is protected by FiveM's escrow system. The client and server-side code is encrypted and cannot be modified.
