Fivem Map File Collision Finder (Dev resource)

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

:page_facing_up: 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.

:exclamation: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
13 Likes

I’ve always had a question about this. I know that conflicts between ytmp and ybn are quite obvious in-game, but what other specific issues can these conflicts cause? Sometimes, after adding a certain MLO, a specific area tends to crash more frequently. Does this mean that if I use a tool to identify and fix ytmp (or is there anything else I should be concerned about?), the crashes should theoretically be significantly reduced?

Not trying to cut you off, amazing job offcourse what you made and for free.
But this is online and free also.

https://fivem.prompt-mods.com/compatibility-tool

1 Like

No worries.

I use prompts compatibility tool as well, however, it doesn’t tell me file size and last modified… Which was the purpose of my addition to this code.

1 Like

After using his tool to find them and you fix them 100%, you should resolve the issue. coll, ymap, occ can cause crashes, parts of the map to disappear, floating objects, texture changes when moving, and more. Fixing collisions on your server is important, But it could also just be a bad MLO, like one that isn’t done correctly, has oversized textures, etc you just need to find the problem and fix or remove it.

2 Likes

puttydotexe/fivem-map-collision-finder: A tool designed to assist map developers and server owners with finding map collisions in their servers and projects.

this literally already existed for years. You literally copy pasted the code lol

Yeah, like i stated above. I just added expanded on the file output process, which didnt seem to work with putty’s version. Then I added to the output function to include more metadata (file size and last modified date). The purpose of this was to just update the original work of Puttydotexe, which to clarify - I note clearly that this was his work and I was just adding to it as it helped me.

Your message reads as if you are trying to put down the post or dismiss the work done as nothing or a “copy/paste” job. That is incorrect and not how it was presented when posted.

1 Like

I see, totally understand it now :slight_smile: thanks for clarifying it :slight_smile:

Just clarifying you are meaning “YMAP” files correct?

Just reminding, I am NOT a map developer nor do I have the absolute resolution for your situation.

From my experience, duplicated ymaps that haven’t been adjusted in code walker, can cause issues from double props spawning in an area, to missing things such as a road, to even crashing. Just depends on what each ymap has it in and how its conflicting , I guess is the best answer.

I would join the codewalker discord, get on youtube and do some searching… Not formally recommending this person, but the map developer TheKongOT I think his name is on youtube, has helped with his recent “How to merge maps using codewalker” video. While I would recommend learning more about map files first, before you mess with them… This will hopefully help you understand a little.

1 Like

I see. I’m currently using that tool to troubleshoot potential issues, having reduced the number of conflicts from 180 down to 80. For the file extension filter, I’m only keeping ymap and ybn, and filtering out everything else. I’m not entirely sure if my reasoning is correct, but theoretically, if a duplicate ymap doesn’t load, then the ydd or ytyp it references also won’t load, so there shouldn’t be a need to deal with them.

I’m hoping this will effectively resolve the issues. The main problem is that I’m not aware of any diagnostic tool that can verify map loading or resource usage within the game, so I’ll just have to leave the rest up to luck.

From my experience, ymaps are almost always the cause of flickering. Where you have two different Occlusion points overlapping. This is what I just worked on as I was trying to combined a newly released map that replaces forum drive. That area and its lodlights and occl’s is crazy!

Please follow up, im interested to see how your work goes.