Cops & Robbers is an open-source gamemode for FiveM, designed to provide an immersive GTA V roleplay experience focused on the thrilling interaction between law enforcement and criminal elements. This project invites community contributions, encouraging developers to collaborate on creating dynamic gameplay with high-stakes chases, heists, and investigations.
- Dynamic Role Selection: Players can choose their role as Cop or Robber upon joining, enhancing engagement and player agency.
- Role-Specific Abilities:
- Cops: Access to advanced equipment, vehicles, and backup options.
- Robbers: Utilize heist tools, getaway vehicles, and strategies to evade law enforcement.
- Progression: Earn experience points (XP) through in-game actions like arrests, heists, and completing objectives.
- Leveling Up: Accumulate XP to level up and unlock new abilities, items, or cash rewards.
- Role-Specific Rewards: Unlock advanced gear and perks unique to your chosen role.
- Dynamic Wanted Levels: Robbers accumulate wanted levels based on their actions, affecting NPC and player responses.
- Escalating Challenges: Higher wanted levels result in more aggressive law enforcement tactics.
- Strategic Gameplay: Manage your wanted level to balance risk and reward.
- Arrest Mechanics: Cops can arrest robbers, sending them to jail for a set duration.
- Jail Time Restrictions: Limited capabilities while jailed, with a countdown until release.
- Reintegration: Released robbers have their wanted levels reset and can rejoin the action.
- NUI-Based Menus: Interactive role selection menu and heist timers for an immersive experience.
- HUD Elements: Displays vital information such as heist details, wanted levels, and notifications.
- Visual Feedback: On-screen messages for level-ups, arrests, and other significant events.
- Variety of Heist Targets: Multiple bank locations across the map offer diverse opportunities.
- Variable Difficulty: Different banks present unique challenges and rewards.
- Expanded Admin Commands: Comprehensive commands for server management, including player moderation and resource control.
- Real-Time Monitoring: Spectate players, freeze/unfreeze actions, and teleport as needed.
- Player Management: Adjust player roles, cash balances, inventories, and more.
- Modify Game Elements: Tailor vehicles, weapons, uniforms, and abilities to fit your community's vision.
- Seamless Integration: Compatible with other popular FiveM mods and plugins for a versatile roleplay experience.
-
Clone or Download the Repository:
git clone https://github.com/Indom-hub/Cops-and-Robbers.git
-
Add the Resource to Your Server:
- Copy the
Cops-and-Robbersfolder to your server’sresourcesdirectory.
- Copy the
-
Update the
server.cfg:-
Add the following line to your
server.cfgfile:start Cops-and-Robbers
-
-
Install Dependencies:
- Ensure all necessary dependencies are installed (e.g., a database if required).
-
Restart the Server:
- Restart or launch your server to initialize the resource.
Customize the gameplay experience by editing the configuration options in config.lua.
- Max Players: Set the maximum number of players (
Config.MaxPlayers). - Heist Cooldown: Adjust the cooldown time between heists (
Config.HeistCooldown). - Spawn Locations: Define spawn points for cops and robbers (
Config.CopSpawn,Config.RobberSpawn).
- Heist Locations: Configure multiple bank locations with coordinates, names, and IDs (
Config.BankVaults). - Difficulty and Rewards: Adjust security levels and rewards for each bank.
- XP Requirements: Define experience points needed for each level (
Config.Experience.Levels). - Rewards: Customize rewards for leveling up for both cops and robbers (
Config.Experience.Rewards).
- Thresholds and Descriptions: Set wanted level stages and their effects (
Config.WantedLevels). - Action Impact: Control how player actions influence their wanted level.
- Police Vehicles: List available vehicles for cops (
Config.PoliceVehicles). - Civilian Vehicles: List available vehicles for robbers (
Config.CivilianVehicles).
We use a structured branching strategy to keep the project organized and maintain quality across all stages of development:
- Main: Stable, production-ready code.
- Development: Staging area for new features and fixes.
- Feature: Specific new features, e.g.,
feature/experience-system. - Bugfix: Targeted bug fixes, e.g.,
bugfix/wanted-level-error. - Hotfix: Urgent fixes for critical issues, merged directly into Main.
- Release: Preparation for a new version release.
- Experimental: Trial features and concepts under development.
All developers, designers, and testers are welcome! Here's how you can contribute:
-
Fork the Repository:
- Click the Fork button on the top right corner of the repository page.
-
Create a New Branch:
git checkout -b feature/your-feature-name
-
Make Your Changes:
- Implement your feature or bug fix.
-
Commit and Push:
git commit -am "Description of your changes" git push origin feature/your-feature-name -
Submit a Pull Request:
- Go to your forked repository on GitHub.
- Click on Compare & pull request.
- Provide a clear and detailed description of your changes.
- Submit the pull request for review.
This project is licensed under the GNU General Public License v3.0. See the LICENSE file for details.
Let the chase begin!
- Wiki Documentation: Detailed guides and information.
- Issue Tracker: Report bugs or suggest features.
- Discord Community: Join our community for support and discussion.
Date: November 12th, 2024
Updates:
-
Implemented Persistent Player Data Storage:
- Introduced server-side storage of player data using JSON files.
- Created
player_datadirectory to store individual player data files. - Player data includes money, inventory, and weapons.
- Data persists across sessions and server restarts.
-
Player Data Management System:
- Developed custom Lua functions to manage player money, inventory, and weapons.
- Functions include adding/removing money, adding/removing items, and checking ownership.
- Data is stored in the
playerDatatable on the server side.
-
Data Loading and Saving:
- Implemented
loadPlayerData(source)to load data when a player connects. - Implemented
savePlayerData(source)to save data when a player disconnects or after significant changes. - Ensured data integrity by validating loaded data.
- Implemented
-
Client-Server Data Synchronization:
- Clients request their data upon spawning using
cops_and_robbers:requestPlayerData. - Server sends player data back using
cops_and_robbers:receivePlayerData. - Clients restore weapons and inventory based on received data.
- Clients request their data upon spawning using
-
Purchase and Sell Event Handlers Updated:
- Modified
purchaseItemandsellItemevent handlers to use the new data management system. - Included data saving after transactions to ensure persistence.
- Added server-side validations for item existence, quantity, and player funds.
- Modified
-
Directory and File Handling Enhancements:
- Implemented
ensurePlayerDataDirectory()to createplayer_datadirectory if it doesn't exist. - Added cross-platform support for directory creation (Windows and Linux/macOS).
- Utilized
GetResourcePathfor accurate directory paths.
- Implemented
-
Security Improvements:
- Enhanced server-side checks to prevent exploits.
- Validated item IDs, quantities, and player identifiers.
- Ensured that only legitimate transactions are processed.
-
Code Refactoring and Optimization:
- Organized code into logical sections with clear comments.
- Improved readability and maintainability.
- Removed redundant code and optimized functions.
-
Updated
fxmanifest.lua:- Removed unnecessary dependencies.
- Included
player_data/*in thefilessection to ensure player data is packaged with the resource.
-
Documentation and Comments:
- Added detailed comments explaining new functions and logic.
- Provided explanations for key sections of the code.
- Clarified the purpose of new features and changes.
Thank you for using Cops & Robbers! For questions or support, open an issue on GitHub or join our Discord community.
Happy gaming!