FiveM Map Collision Finder
Overview
The FiveM Map Collision Finder is a Python script originally created by puttydotexe to scan a specified directory for potential map file conflicts in FiveM. It identifies duplicate file names across multiple locations and outputs the results, including the file path, size, and last modified date.
This is a slight update to Puttydotexe’s fivem-map-collison-finder code found on his github.
Adjusted the output to provide file size and last modified date.
This is used when you are dealing with multiple MLO/Maps in your server and you can’t seem to find which files are duplicated. The script, written in python, simply scans the directory you point it at and then provides an output of all duplicate files names. It shows the directory where the file is and again, the size and last modified date.
This was important to me as I noticed many map devs seem to use a lot of vanilla ymaps to add some basic props or occlusions to their project. When I would add the map, I had a difficult time tracking all of my similar vs exactly the same map files.
So, with this simple tool, you can have a visual printout (output document) that you can see if the files are the same size, or are they different. To some this may seem pointless, however, I found great value in locating lodlights that I couldn’t get rid of and some other random map conflicts a lot easier.
Features
- Scans a directory for duplicate map-related files
- Supports ignoring specific file types
- Outputs results to a text file, including:
- File name
- Full file path
- File size (in bytes)
- Last modified date
- Works with various FiveM map file types (
.ytd
,.ymt
,.ydr
,.ydd
,.ytyp
,.ybn
,.ycd
,.ymap
,.ynv
,.ypt
)
Please Note that you will need to use a terminal window or command prompt to perform this. Simply, open command prompt, navigate to the directory/folder where you stored this resource, and then follow the instructions below. Again, this is all done in command prompt, so if you are not familiar with that, I would suggest you hold off on using this script and google yourself some knowledge on the topic!
You can get this at my github.
Installation
1. Clone the Repository
To download the script, use the following command:
git clone https://github.com/JimmySackss/fivem-map-collision-finder.git
Then ‘cd fivem-map-collision-finder’
2. Install Python (If Not Installed)
This script requires Python 3.6 or later. You can check your version with:
python --version
If you don’t have Python installed, download it from: Python Official Site
3. Install Dependencies
No additional dependencies are required; the script utilizes Python’s built-in libraries.
Usage
Run the script with the following command:
python checker.py <directory_to_scan> --ignore <ignored_file_patterns> --output <output_file>
Example Command
python checker.py "C:\FiveMServer\resources" --ignore "*.ydd" --output "C:\Users\Desktop\collision_results.txt"
Explanation:
C:\FiveMServer\resources → The directory where FiveM map files are stored
--ignore "*.ydd" → Ignores .ydd files from the scan
--output "C:\Users\Desktop\collision_results.txt" → Saves the results to a text file
Output Format
If any collisions are found, the script will generate an output similar to this:
Possible collisions: lr_sc1_1_strm.ymap
- C:\FiveMServer\resources\map1\stream\lr_sc1_1_strm.ymap | Size: 2,345,678 bytes | Last Modified: 2025-02-12 14:30:22
- C:\FiveMServer\resources\map2\stream\lr_sc1_1_strm.ymap | Size: 2,345,678 bytes | Last Modified: 2025-02-11 09:12:45
- C:\FiveMServer\resources\backup\old_maps\lr_sc1_1_strm.ymap | Size: 2,345,678 bytes | Last Modified: 2025-01-15 18:45:10
Total collisions found: 1
If no collisions are found, the script will output:
No collisions found.
Troubleshooting
Output File Not Generating?
Ensure you are using --output <filepath> correctly.
Use a full path instead of just a filename.
Run the script as administrator if needed.
Check if the script prints Writing output to: before writing the file.
Need Help?
If you encounter any issues or have feature requests, feel free to open an issue on GitHub.
Again, thanks for Puttydotexe for all of their contributions!
** Please note**
Im no master coder, but I’ve been working on my ability to write in lua and python and when I found resource, and decided that I could give back a little to the fivem community with this.
Here is the python code preview:
import os
import argparse
from collections import defaultdict
import fnmatch
import datetime
MAP_RELATED_FILES = ["*.ytd", "*.ymt", "*.ydr", "*.ydd", "*.ytyp", "*.ybn", "*.ycd", "*.ymap", "*.ynv", "*.ytyp", "*.ypt"]
def find_collisions(directory, ignored_files=None, output_file=None):
file_dict = defaultdict(list)
collisions = 0
for foldername, _, filenames in os.walk(directory):
for filename in filenames:
file_path = os.path.normpath(os.path.join(foldername, filename))
if not any(fnmatch.fnmatch(filename.lower(), pattern.lower()) for pattern in MAP_RELATED_FILES):
continue
if ignored_files and any(fnmatch.fnmatch(filename.lower(), pattern.lower()) for pattern in ignored_files):
continue
file_key = filename.lower()
file_dict[file_key].append(file_path)
if output_file:
with open(output_file, 'w') as f:
for filename, paths in file_dict.items():
if len(paths) > 1:
f.write(f'Possible collisions: {filename}\n')
for path in paths:
try:
if os.path.isfile(path): # Ensure it's a file
size = os.path.getsize(path)
mod_time = os.path.getmtime(path)
formatted_mod_time = datetime.datetime.fromtimestamp(mod_time).strftime('%Y-%m-%d %H:%M:%S')
f.write(f' - {path} | Size: {size} bytes | Last Modified: {formatted_mod_time}\n')
else:
f.write(f' - {path} | [Error: Not a valid file]\n')
except (FileNotFoundError, PermissionError, OSError) as e:
f.write(f' - {path} | [Error: {str(e)}]\n')
f.write('\n')
collisions += 1
f.write(f"Total collisions found: {collisions}\n")
print(f"All collisions written to '{output_file}'.")
else:
for filename, paths in file_dict.items():
if len(paths) > 1:
print(f'Possible collisions: {filename}')
for path in paths:
try:
if os.path.isfile(path): # Ensure it's a file
size = os.path.getsize(path)
mod_time = os.path.getmtime(path)
formatted_mod_time = datetime.datetime.fromtimestamp(mod_time).strftime('%Y-%m-%d %H:%M:%S')
print(f' - {path} | Size: {size} bytes | Last Modified: {formatted_mod_time}')
else:
print(f' - {path} | [Error: Not a valid file]')
except (FileNotFoundError, PermissionError, OSError) as e:
print(f' - {path} | [Error: {str(e)}]')
print()
collisions += 1
print(f"Total collisions found: {collisions}")
if __name__ == "__main__":
parser = argparse.ArgumentParser(description="Find map collisions in a directory.")
parser.add_argument("directory", help="The directory to scan for map collisions.")
parser.add_argument("--ignore", nargs="+", default=[], help="List of file patterns to ignore.")
parser.add_argument("--output", help="Output file to write the list of collisions to.")
args = parser.parse_args()
find_collisions(args.directory, ignored_files=args.ignore, output_file=args.output)
Code is accessible | Yes |
Subscription-based | No |
Lines (approximately) | 94 |
Requirements | Python 3.6 or greater |
Support | Yes |