# CodeRanch - Notice System

**Advanced Notice Board System for RedM**

This script provides a modern and user-friendly notice board system for RedM servers. Players can create posts in different categories, administrators can manage posts, and the system is supported with Discord integration.

## 🚀 Features

* **Multi-Framework Support**: VORP, RedEM, QBR and Standalone
* **Categorized Posts**: Jobs, Wanted, Events, Property, General
* **Image Support**: Add images to posts with modal viewing
* **Admin Management**: Delete posts, pin/unpin posts
* **Discord Integration**: Automatic Discord notifications
* **Payment System**: Create posts with money or items
* **Auto Cleanup**: Automatically delete expired posts
* **Responsive Design**: Mobile-friendly interface

## 📋 Requirements

* **RedM Server** (Beta 1491+)
* **oxmysql** (For database connection)
* **Supported Frameworks**: VORP, RedEM, QBR or Standalone

## 🛠️ Installation

{% stepper %}
{% step %}

### Download Files

Copy the resource folder to your server's resources folder:

```bash
# Copy to your server's resources folder
resources/[coderanch]/coderanch-notice/
```

{% endstep %}

{% step %}

### Database Setup

Run the SQL install script in your MySQL database:

```sql
-- Run in your MySQL database
source sql/install.sql
```

{% endstep %}

{% step %}

### Server.cfg Settings

Add required framework dependencies (only add the ones you use) and the notice script:

```cfg
# Framework dependencies (only add the ones you use)
ensure oxmysql

# If using VORP
ensure vorp_core
ensure vorp_inventory

# If using RedEM
ensure redem_roleplay

# If using QBR
ensure qbr-core

# Notice Board Script
ensure coderanch-notice
```

{% endstep %}

{% step %}

### Configuration

Edit `shared/config.lua` file according to your server's needs.
{% endstep %}
{% endstepper %}

## ⚙️ Configuration

### Framework Settings

```lua
Config.Framework = "auto" -- "auto", "vorp", "redem", "qbr", "standalone"
```

### Post Settings

```lua
Config.PostCost = {
    enabled = true,        -- Is post cost enabled?
    amount = 5,           -- Cost amount
    useItem = false,      -- Use item instead of money
    itemName = "paper"    -- Item name
}

Config.MaxPostsPerPlayer = 5  -- Maximum posts per player
Config.PostLifetime = 72      -- Post lifetime (hours)
Config.EnableImages = true    -- Image support
```

### Admin Settings

```lua
Config.Admins = {
    "steam:110000xxxxxxxx",    -- Steam ID
    "license:xxxxxxxxxxxxxxxx", -- License
    -- Add more admins
}
```

### Board Locations

```lua
Config.BoardLocations = {
    {
        name = "Valentine",
        coords = vector3(-276.16, 805.27, 118.80),
        interactionDistance = 2.0,
        blip = {
            enabled = true,
            sprite = -1031367698,
            scale = 0.2
        }
    },
    -- Add more locations
}
```

### Discord Webhook

```lua
Config.DiscordWebhook = {
    enabled = true,
    url = "https://discord.com/api/webhooks/YOUR_WEBHOOK_URL",
    botName = "Notice Board",
    embedColor = 15158332,
    sendOnNewPost = true,
    categories = {
        ["Jobs"] = true,
        ["Wanted"] = true,
        ["Events"] = true,
        ["Property"] = false,
        ["General"] = false
    }
}
```

### UI Settings

```lua
Config.UI = {
    theme = "dark",           -- "dark" or "light"
    titleMaxLength = 50,      -- Maximum title length
    contentMaxLength = 1000,   -- Maximum content length
    categories = {
        "All",
        "Jobs", 
        "Wanted",
        "Events",
        "Property",
        "General"
    }
}
```

## 🎮 Usage

### For Players

{% stepper %}
{% step %}

### Approach Notice Board

Shown on map with 📌 icon.
{% endstep %}

{% step %}

### Open the Notice Board

Press E key to open the notice board.
{% endstep %}

{% step %}

### Create Post

Click the "Create Post" button.
{% endstep %}

{% step %}

### Fill Information

* Title (maximum 50 characters)
* Select category
* Write content (maximum 1000 characters)
* Image URL (optional)
  {% endstep %}

{% step %}

### Submit

Submit the form — your post is published.
{% endstep %}
{% endstepper %}

### For Admins

* **Delete Post**: "🗑️ Delete" button in post details
* **Pin/Unpin Post**: "📌 Pin/Unpin" button in post details
* **View All Posts**: Can view posts in all categories

### Image Feature

* You can add image URLs to posts
* Click on images to view them in full size
* Modal window for full-screen viewing

## 🔧 Advanced Settings

### Adding New Board Location

```lua
{
    name = "New City",
    coords = vector3(x, y, z),
    interactionDistance = 2.0,
    blip = {
        enabled = true,
        sprite = -1031367698,
        scale = 0.2
    }
}
```

### Adding New Category

```lua
Config.UI.categories = {
    "All",
    "Jobs",
    "Wanted", 
    "Events",
    "Property",
    "General",
    "New Category"  -- Add new category
}
```

### Language Settings

```lua
Config.Lang = {
    openBoard = "Press [~e~E~q~] to open Notice Board",
    notEnoughMoney = "You don't have enough money to post ($%s required)",
    notEnoughItem = "You need %s to create a post",
    postCreated = "Post created successfully",
    postDeleted = "Post deleted",
    postPinned = "Post pinned",
    postUnpinned = "Post unpinned",
    maxPostsReached = "You have reached the maximum number of active posts (%s)",
    noPermission = "You don't have permission to do that"
}
```

## 🐛 Troubleshooting

<details>

<summary>Framework Not Detected</summary>

* Set `Config.Framework` manually instead of "auto"
* Make sure your framework is properly loaded

</details>

<details>

<summary>Database Connection Error</summary>

* Ensure oxmysql is properly installed
* Check your database credentials

</details>

<details>

<summary>Admin Permissions Not Working</summary>

* Add correct identifiers to `Config.Admins` list
* Check Steam ID or License format

</details>

<details>

<summary>Discord Webhook Not Working</summary>

* Make sure webhook URL is correct
* Check webhook permissions in your Discord server

</details>

## 📊 Database Structure

```sql
CREATE TABLE `notice_board_posts` (
    `id` INT(11) NOT NULL AUTO_INCREMENT,
    `author_identifier` VARCHAR(100) NOT NULL,
    `author_name` VARCHAR(100) NOT NULL,
    `title` VARCHAR(100) NOT NULL,
    `content` LONGTEXT NOT NULL,
    `category` VARCHAR(50) NOT NULL,
    `image_url` TEXT DEFAULT NULL,
    `pinned` TINYINT(1) DEFAULT 0,
    `town` VARCHAR(50) NOT NULL,
    `timestamp` DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP,
    `expires_at` DATETIME DEFAULT NULL,
    PRIMARY KEY (`id`)
);
```

## 🔄 Updates

### v1.0.0

* Initial release
* Basic post system
* Framework support
* Discord integration
* Image support
* Admin management

## 📄 License

This script is developed by CodeRanch. Commercial use requires permission.

***

**Note**: This script is developed for RedM Beta version. Incompatibilities may occur in RedM's official release.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://coderanch-redm-store.gitbook.io/coderanch-redm-store-docs/coderanch-notice-system.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
