Pet & Companion Script [QB + ESX] - Complete Pet System with AI Behavior
https://www.youtube.com/watch?v=5medm-C7KTI
Bring your FiveM server to life with the Pet & Companion Script, a fully-featured pet system that lets players purchase, customize, and interact with AI-controlled animal companions. This script goes beyond basic pet following by introducing feeding systems, hydration tracking, interactive commands (sit, attack, bark), vehicle transport, and realistic pet behaviors. Whether you're running a casual roleplay server or a complex life simulation, this pet system adds personality and immersion that players love.
What's Included
You'll get a complete pet ownership system with purchase interfaces at configurable pet shop locations, extensive customization options for pet appearance and names, AI behavior systems for following and pathfinding, needs management (hunger/thirst), interactive command menus, vehicle integration for bringing pets in cars, and multi-language support. The script seamlessly integrates with both QBCore and ESX frameworks without requiring additional dependencies beyond optional target scripts for enhanced interactions.
Key Features
- Multiple Pet Types - Choose from dogs, cats, and other animal models. Each pet type can have different breeds, sizes, and customization options configured to match your server's theme.
- Purchase & Shop System - Players visit pet shops at configured map locations to browse available pets, preview models, customize appearance, and complete purchases using server currency. Supports one-time fees or recurring adoption costs.
- AI Follow Behavior - Pets use advanced pathfinding to follow players realistically. They navigate around obstacles, wait when players enter buildings, and return when called. Adjustable follow distance and speed settings ensure pets don't get lost or obstruct gameplay.
- Feeding & Hydration System - Pets require food and water to stay healthy. Players use consumable items (pet food, water bowls) to maintain their companion's needs. Neglected pets may become sad, slow down, or eventually run away if not cared for.
- Interactive Commands - Access a radial menu or command list to control pet behavior. Make them sit, lie down, stay in place, bark/meow for attention, or attack on command for guard dog scenarios. Each command includes animations and sound effects.
- Attack Command - Guard dogs or protective companions can be commanded to attack nearby threats. Useful for property defense roleplay, personal security, or criminal scenarios. Includes combat animations and configurable damage.
- Vehicle Integration - Bring pets into vehicles as passengers. They sit in available seats or cargo areas, travel with the player, and exit when the vehicle stops. Perfect for road trips, moving to new properties, or visits to the vet.
- Pet Customization - Name your pet, choose collar colors, select from available breeds, and adjust size/appearance. Customization saves with the pet so it looks the same every time it's spawned.
- Framework Integration - Seamlessly works with QBCore and ESX without requiring framework-specific configuration. The script detects your framework automatically and adjusts database calls, money handling, and job checks accordingly.
- Standalone Operation - No mandatory external dependencies. Works out of the box, though target scripts (ox_target, qb-target) are recommended for better shop interactions.
- Multi-Language Support - Includes English, German, Turkish, Spanish, French, and Italian translations. Easy to add custom languages through the config file for international communities.
- Performance Optimized - Efficient entity streaming and behavior loops ensure pets don't impact server performance even with many active companions across the server.
Perfect For
- Roleplay servers wanting to add casual life simulation elements
- Pet shop businesses and animal adoption center roleplay
- Property owners who want guard dogs or house pets
- Gang servers using attack dogs for territory defense
- Homeless/civilian characters needing companion animals
- Veterinary clinic roleplay with pet health systems
- Casual servers adding fun social features beyond crime/jobs
How It Works
Players visit a pet shop location marked on the map (or discovered through target zones). They open the shop UI to browse available pet types and breeds. After selecting a pet, they customize its name, appearance, and any available cosmetic options. Upon purchase, the pet is added to their inventory or database record. Players can spawn their pet using an item, command, or menu, which creates an AI-controlled ped that follows them.
The pet automatically follows using pathfinding AI, maintaining configurable distance and avoiding obstacles. Players access a command menu (radial or keybind-based) to issue commands like sit, stay, attack, or bark. When hunger or thirst levels drop, notification prompts remind players to feed their pet using consumable items from their inventory. To transport pets, players enter a vehicle and use a command to bring the pet inside, where it occupies a seat until manually dismissed or the vehicle is exited.
Pet data (name, appearance, hunger, thirst, last spawn time) persists in the database so companions remain consistent across sessions. Owners can dismiss pets when not needed and resummon them later with all customization intact.
Technical Details
- Performance: Optimized entity streaming with configurable spawn limits and behavior tick rates
- Compatibility: QBCore, ESX, QBOX - Auto-detects framework and adjusts accordingly
- Dependencies: None required (optional: ox_target or qb-target for enhanced interactions)
- Database: Stores pet ownership, customization data, needs levels, and purchase history
- AI System: Uses native GTA pathfinding with custom behavior states (follow, sit, stay, attack)
- Customization: Config file for pet types, shop locations, prices, needs decay rates, command permissions
Installation
- Extract the pet companion script to your resources folder
- Import the SQL file to create pet ownership and data tables
- Configure framework detection (auto-detects ESX/QBCore/QBOX)
- Set up pet shop locations in config.lua with coordinates and available pets
- Configure pet types, breeds, prices, and customization options
- Adjust hunger/thirst decay rates and need requirements
- Add pet food and water items to your items configuration
- Optional: Configure ox_target or qb-target zones for shop interactions
- Add 'ensure pet-companion-script' to server.cfg
- Restart server and visit pet shop locations to test purchasing and commands
Framework Compatibility
- ✅ ESX - Full integration with ESX player data, money system, and inventory
- ✅ QBCore - Native QB player functions, cash handling, and item system
- ✅ QBOX - Compatible with QBOX framework architecture
- ✅ Standalone - Can operate without framework using configuration-based settings
Available Commands
- Spawn Pet - Summon your owned pet to your location from inventory or menu
- Dismiss Pet - Send pet away and save its current state to database
- Sit/Lie Down - Make pet sit or lie down at current location with animation
- Stay - Command pet to remain at specific location until recalled
- Follow - Resume following behavior after stay or sit commands
- Bark/Meow - Trigger pet vocalization sounds for attention or roleplay
- Attack - Command guard dogs to engage nearby threats (requires guard dog type)
- Enter Vehicle - Bring pet into your vehicle as a passenger
- Feed - Use pet food item to restore hunger level
- Give Water - Use water bowl or bottle to restore hydration level
- Pet Info - View current hunger, thirst, and pet statistics
What Makes It Stand Out
Most pet scripts are simple follow systems with minimal interaction. This script adds depth through the feeding/hydration system that creates ongoing care responsibilities, making pet ownership feel meaningful rather than just cosmetic. The attack command opens up guard dog roleplay that most systems don't support. Vehicle integration solves the common problem of leaving pets behind during travel. Multi-language support out of the box means international servers don't need to translate everything themselves. The framework-agnostic design with auto-detection makes installation simple regardless of your server's base. Combined with extensive customization options and performance optimization, this delivers the most complete pet companion experience available for FiveM.
Roleplay Scenarios & Uses
- Pet Shop Business - Players operate pet stores, manage inventory, set prices, and process adoptions
- Guard Dogs - Property owners deploy attack dogs to defend homes, businesses, or gang territory
- Companionship - Homeless characters, civilians, or lonely players gain AI companions for immersion
- Veterinary Clinic - Vets treat sick pets, provide checkups, and manage pet health systems
- K9 Units - Police use trained dogs for drug searches, suspect tracking, or patrol companionship
- Farming/Ranch - Rural players keep working dogs for livestock herding or property management
- Criminal Use - Gang members use attack dogs for intimidation, guarding illegal operations, or combat
- Social Events - Host dog shows, pet meetups, or adoption events for community engagement
Customization Options
- Pet Models - Add unlimited custom animal peds (dogs, cats, exotic animals)
- Breed Variations - Configure multiple breeds per species with different sizes and appearances
- Shop Locations - Set up pet stores anywhere on the map with custom ped models and zones
- Pricing - Individual prices per pet type, adoption fees, or subscription costs
- Needs Decay - Adjust how fast hunger/thirst decrease (realistic vs. casual)
- Follow Distance - Set how close pets stay to players (personal space vs. tight follow)
- Command Restrictions - Limit attack commands to specific pet types or job permissions
- Ownership Limits - Control how many pets players can own simultaneously
- Language Files - Add translations for your server's primary language
Related FiveM Police Scripts