# Crowe Newspaper

A comprehensive, immersive newspaper system for RedM servers, featuring dynamic content, interactive stands, and deep integration with VORP inventory. **Now with unified permission system, complete society framework integration, and enterprise-grade transaction system.**

For a complete list of changes and updates, see CHANGELOG.md.

## Features

### 🏪 **Multiple Newspaper Stands**

* Unique stands in Saint Denis, Valentine, and Blackwater
* Dynamic NPC stand hours with realistic opening/closing animations
* Always-on blips with dynamic submission locations for eligible jobs

### ⚡ **Unified Permission System (v2.0.0 NEW!)**

* **Real-Time UI Updates**: Frontend dynamically shows/hides features based on user permissions
* **Visual Permission Indicators**: Color-coded badges (🟢 Journalist, 🔵 Editor) show user roles
* **Server-Side Authorization**: All permissions calculated securely on server
* **Two-Tier System**: Journalists (can edit) and Editors (can publish/manage)
* **Granular Control**: Five permission levels for precise access control

### 👥 **Dual Job System (v2.0.0 NEW!)**

* **Traditional Mode**: Separate editor/journalist jobs (existing setup)
* **Society Mode**: Single job per publisher with grade-based permissions
* Automatic detection and configuration
* Full backward compatibility

### 🏢 **Complete Society Framework Integration (v2.0.0 NEW!)**

* **Auto-Detection**: Automatically detects your society framework
* **Supported Frameworks**: Crowe Society, Brew Society, Syn Society, Mega Companies, DL Society, Custom
* **Enterprise Transaction System**: Retry logic, fallback mechanisms, comprehensive logging
* **Revenue Integration**: Newspaper sales automatically go to society accounts

### 📰 **Dynamic Content System**

* Articles and ads loaded from MySQL database
* Multiple categories, quotes, images, gifs, and custom fonts
* Town-based content with unique publishers per location
* Template content for easy onboarding

### 🎨 **Modern, Responsive UI**

* Beautiful, period-appropriate design with custom fonts
* Editor panel for journalists/editors with edition management
* Strict editorial workflow with server-side validation
* Page flip animations and responsive design

### 🌍 **Multi-Language Support**

* 14 languages included by default
* Fully translatable via locale files
* Easy to extend for additional languages

### ⚙️ **Easy Configuration**

* Clean, organized config file
* Flexible job mapping system
* Configurable stand locations, NPCs, and objects
* Performance optimized with proximity-based spawning

## Dependencies

* vorp\_core
* vorp\_inventory
* oxmysql

## Installation

1. **Install Dependencies**: Ensure you have vorp\_core, vorp\_inventory, and oxmysql
2. **Add Resource**: Place `crowe_newspaper` folder in your resources directory
3. **Start Resource**: Add `ensure crowe_newspaper` to your server.cfg
4. **Add Item**: Add the newspaper item to your VORP inventory items database/config
5. **Import Database**: Run `new_newspaper.sql` in your database
6. **Configure**: Edit `config.lua` to your preferences (see configuration section)
7. **Optional**: Run `transaction_history.sql` for transaction logging (v2.0.0 feature)
8. **Restart Server**

## v2.0.0 Society Integration Setup

### Option 1: Keep Current Setup (No Changes Needed)

Your existing configuration will continue to work exactly as before.

### Option 2: Enable Society Integration (Truly Unified Configuration)

```lua
-- Enable society integration mode
Config.SingleJobMode.enabled = true
Config.Society = 'auto'  -- Auto-detects your society framework

-- Configure job permissions (example for St Denis)
Config.SingleJobMode.jobs = {
    [1] = {
        jobName = "stdenisnews",            -- Job name in your society system
        editorGrade = 3,                    -- Grade 3+ = Editor permissions
        journalistGrade = 0                 -- Grade 0+ = Journalist permissions
    }
}

-- Configure revenue destinations (works for both traditional and society modes)
Config.PublisherSocieties = {
    [1] = "stdenissociety",                 -- Publisher 1 revenue goes here
    [2] = "valentinesociety",               -- Publisher 2 revenue goes here
    [3] = "blackwatersociety"               -- Publisher 3 revenue goes here
}
```

### Supported Society Frameworks

* **Crowe Society**: Uses society + rank system with duty management
* **Brew Society**: Uses job + grade system
* **Syn Society**: Uses job + grade system
* **Mega Companies**: Uses company + rank system
* **DL Society**: Uses job + grade system
* **Custom**: Modify `HandleCustomTransaction()` function in server/main.lua

## Crowe Society Integration

This script now includes full support for the Crowe Society Management System. See CROWE\_SOCIETY\_INTEGRATION.md for complete setup instructions.

### Quick Setup for Crowe Society

```lua
-- Enable Crowe Society integration
Config.Society = 'crowe_society'
Config.SingleJobMode.enabled = true

-- Configure society names (must match exactly)
Config.SingleJobMode.jobs = {
    [1] = { jobName = "stdenisnews", editorGrade = 3, journalistGrade = 0 },
    [2] = { jobName = "valentinenews", editorGrade = 3, journalistGrade = 0 },
    [3] = { jobName = "blackwaternews", editorGrade = 3, journalistGrade = 0 }
}

Config.PublisherSocieties = {
    [1] = "stdenisnews",     -- Must match jobName exactly
    [2] = "valentinenews",   -- Must match jobName exactly
    [3] = "blackwaternews"   -- Must match jobName exactly
}
```

### Key Features for Crowe Society

* **Duty-Based Access**: Players must clock in to use newspaper functions
* **Rank-Based Permissions**: Society rank determines newspaper permissions
* **Revenue Integration**: Sales automatically go to society funds
* **Transaction Logging**: All transactions logged in society history
* **Activity Tracking**: Newspaper activity tracked in society logs

## Configuration

All configuration is handled in `config.lua`. The file is now clean and organized into logical sections.

### Basic Settings

```lua
Config.InteractionKey = 0x760A9C6F -- G key
Config.InteractionDistance = 3.0
Config.NewspaperItem = 'folder_newspaper_scraps'
Config.NewspaperYear = 1901
Config.DefaultLanguage = 'en'
```

### Traditional Job Mode (Default)

```lua
Config.Jobs = {
    stdenis_journalist = "stdenisjournalist",
    stdenis_editor = "stdeniseditor",
    valentine_journalist = "valentinejournalist",
    valentine_editor = "valentineeditor",
    blackwater_journalist = "blackwaterjournalist",
    blackwater_editor = "blackwatereditor"
}
```

### Society Integration Mode (v2.0.0) - Job Permissions Only

```lua
Config.SingleJobMode = {
    enabled = false,  -- Set to true to enable
    jobs = {
        [1] = {  -- St Denis - Job and permission configuration
            jobName = "stdenisnews",
            editorGrade = 3,
            journalistGrade = 0
        }
        -- Add more publishers...
    }
}
```

### Unified Society Revenue Configuration (Works for Both Modes)

```lua
Config.PublisherSocieties = {
    [1] = "stdenissociety",      -- Publisher 1 revenue destination
    [2] = "valentinesociety",    -- Publisher 2 revenue destination  
    [3] = "blackwatersociety"    -- Publisher 3 revenue destination
}
```

### Transaction System

```lua
Config.TransactionSystem = {
    enabled = true,
    enableLogging = true,
    enableFallback = true,
    retryAttempts = 3,
    retryDelay = 1000,
    enableTransactionHistory = true
}
```


---

# 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://crowescripts.gitbook.io/documentation/about-our-scripts/redm-script-documentation/crowe-newspaper.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.
