# Pet System

## Introduction

HATE-Pets is a comprehensive pet system for FiveM servers allowing players to purchase, spawn, and interact with various pets. The system features multiple pet breeds with unique abilities, commands, and animations. Players can manage their pets' health, hunger, and happiness, creating an engaging roleplay experience.

## Features

* Multiple pet types (dogs and cats) with unique animations and abilities
* Pet status system (health, hunger, happiness) that persists in database
* Special commands: Follow, Stay, Attack, Search, Track
* Interactive animations
* Job-locked pets for police/emergency services
* Vehicle integration - pets enter vehicles with players automatically
* Target system integration (ox\_target, qb-target)
* Pet Shop with configurable NPC
* Multi-language support (English, Turkish, German)

## Installation

### Requirements

* ESX or QBCore Framework
* ox\_lib
* ox\_target or qb-target
* MySQL-Async

### Setup Steps

1. Place the resource in your server resources folder
2. Import the SQL file to your database (automatically creates required tables)
3. Configure the `config.lua` file to match your server's needs
4. Add `ensure hate-pets` to your server.cfg
5. Restart your server

### Configuration

The main configuration file (`config.lua`) allows you to customize:

* Framework selection (ESX/QBCore)
* Language preference (English, Turkish, German)
* Target system preference (ox\_target/qb-target)
* Pet shop location and NPC details
* Pet types, models, prices and abilities
* Status decay rates and thresholds
* Inventory item IDs

## Usage

### Player Commands

* `/pets` - Opens the pet management UI

### Pet Commands

Once a pet is spawned, players can use the following commands:

* Follow - Pet will follow the player
* Stay - Pet will remain in place
* Pet - Player will pet their animal, increasing happiness
* Feed - Requires appropriate food item in inventory
* Attack - Set pet to attack a target (specific pet breeds only)
* Search - Have pet search players or vehicles (specific pet breeds only)
* Track - Have pet track a player (specific pet breeds only)

### Animations

Various animations are available depending on pet type:

* Sit
* Lay down
* Paw
* Beg
* Play dead
* Roll
* Bark/Meow
* Howl
* Spin

## Vehicle Integration

Pets will automatically:

* Enter vehicles when their owner gets in (sitting in empty passenger seats)
* Exit vehicles when their owner gets out
* Return to following the player after exiting a vehicle

## Configuration Examples

### Adding a New Pet

To add a new pet to the system, add a new entry in the `Config.Pets` table:

```lua
Config.Pets = {
    // ...existing code...
    
    k9_shepherd = {
        name = "Police K9 Shepherd",
        model = "a_c_shepherd",
        petType = "dog",
        price = 35000,
        description = "A highly trained police dog for law enforcement.",
        preview_image = "URL_TO_IMAGE",
        requiredJob = {"police", "sheriff"},
        allowedCommands = {
            "follow", "stay", "pet", "feed",
            "attack", "search", "track", "guard"
        },
        animations = {
            sit = {dict = "creatures@rottweiler@amb@world_dog_sitting@base", anim = "base", duration = -1},
            // Additional animations...
        }
    }
}
```

### Customizing Pet Shop

```lua
Config.PetShop = {
    npc = {
        model = "a_f_y_hipster_01",
        coords = vector4(-758.2, -1047.1, 12.5, 110.5),
        scenario = "WORLD_HUMAN_STAND_MOBILE"
    },
    blip = {
        sprite = 442,
        color = 3,
        scale = 0.7,
        label = "Pet Shop"
    }
}
```

## Database Structure

The script automatically creates and manages the following database table:

**player\_pets**

* `id` - Auto increment primary key
* `owner` - Player identifier
* `pet_id` - Pet identifier from config
* `name` - Custom pet name
* `health` - Current pet health (0-100)
* `hunger` - Current pet hunger level (0-100)
* `happiness` - Current pet happiness level (0-100)
* `purchased_at` - Timestamp of purchase
* `last_updated` - Timestamp of last status update

## Required Items

The script requires certain items to be added to your inventory system:

```lua
Config.Items = {
    dogFood = "dog_food",  // Item ID for dog food
    catFood = "cat_food",  // Item ID for cat food
    petToy = "pet_toy",    // Item ID for pet toy
    medkit = "pet_medkit"  // Item ID for pet healing
}
```

Make sure to add these items to your inventory system for full functionality.

## For Developers

The config.lua and language.lua files are not protected by escrow, allowing for customization. Note that the core client and server scripts are protected, limiting extensive modification.

## Translations

The script comes with built-in support for English, Turkish, and German languages. You can select your preferred language in the config:

```lua
Config.Language = "en"  // Available options: "en", "tr", "de"
```

To add additional languages, you can extend the `Lang` table in the language.lua file with the appropriate translations.

## Support

For additional support, contact the script author through the official distribution channel.

## Security Notice

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


---

# 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://hate-development.gitbook.io/hate-development-docs/pet-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.
