Skip to content

Progress bar was not syncing with actual game loading event #1

@Soul-H4cker

Description

@Soul-H4cker

Issue: The progress bar was not syncing with actual game events. It appeared to increment artificially rather than reflecting FiveM’s loadProgress updates.

Cause: The React component was only using a setTimeout loop to increase progress, so it wasn’t tied to FiveM’s event system.

Fix: Added a listener for the loadProgress event:

useEffect(() => {
  const handleMessage = (event) => {
    if (event.data.eventName === "loadProgress") {
      setProgress(event.data.loadFraction * 100);
    }
  };
  window.addEventListener("message", handleMessage);
  return () => window.removeEventListener("message", handleMessage);
}, []);

Result: The progress bar now syncs correctly with game loading event in real time.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions