Thanks to visit codestin.com
Credit goes to github.com

Skip to content

atsi2004/haxballF1

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 

Repository files navigation

Haxball Racing Room Script


What is Haxball and This Racing Script?

Haxball is a popular browser-based multiplayer physics game combining soccer and simple top-down gameplay. Players control discs to compete in custom rooms and maps.

This project is a custom Haxball room script designed for F1-style racing on circular "circuit" maps. Unlike traditional parkour or survival maps, these circuits allow players to practice time trials and improve their racing skills.


Features

  • Lap Time Tracking: Displays each player’s lap times and current lap count during races.
  • Fastest Lap Announcement: Announces the fastest lap time and player after each race.
  • Dynamic Lap Count: Admins can set the number of laps per race with !setlaps <number>.
  • Player Speed Toggle: Players can enable/disable speed tracking mode.
  • AFK Mode: Players can toggle AFK mode, moving them to Spectators and back.
  • Admin Commands:
    • Toggle admin rights (!admin)
    • Load custom circuits by ID (!circuit <ID>)
    • Show map info (!info)
    • Show fastest lap in session (!purple)
    • List available maps (!maps)
    • Clear bans (!clearbans)
    • Kick self (!bb)
    • Toggle auto-rotate (!auto)
  • Automatic Team Assignment: On stadium/map change or player join, players are assigned to the appropriate team.
  • Event Logging: Logs player joins, leaves, kicks, admin changes, game stops, and unpauses.
  • Anti-troll & Race Session Management: Placeholders for custom race logic and player behavior checks.

How It Works

When players join the room, the script tracks their position, speed, and lap progress. It updates lap counts as players complete each circuit lap and calculates their lap times. After finishing the race, players are moved to Spectators automatically.

Admins can load different circuits by ID, set the number of laps, and manage players via commands.


Installation & Usage

  1. Open https://www.haxball.com/headless and open dev tools by doing Ctrl+Shift+I and click console
  2. Paste the full script into the console.
  3. Change admin code to whatever you want to use (default is !bronjame)
  4. Click enter and open the link generated in a new tab to start the game and share the room link with other players!
  5. Use chat commands to manage laps, maps, and game settings

Commands

Player Commands

Command Description
!admin Toggles your admin status (if allowed)
!help Show available commands
!speed Toggle speed display on/off
!afk Toggle AFK mode (move to Spectators/back)
!map or !info Show current circuit info: name, best lap, player
!purple Show fastest lap of current session
!maps Show list of available maps and their IDs
!bb Kick yourself from the room

Admin Commands

Command Description
!circuit [ID] Load a circuit/map by its ID
!setlaps [num] Set number of laps required to finish a race
!clearbans Clear all banned players
!auto Toggle auto-rotate mode

Data Structures

  • playerList — Tracks per-player info such as lap times, current lap, speed mode, and presence.
  • _Circuit — Current circuit/map data including best times, lap direction, and teams.
  • _Circuits — Array of all available circuits/maps.

Events Handled

  • onGameStop — Resets lap data and announces fastest lap.
  • onGameTick — Handles periodic checks (laps, trolling, session ending).
  • onGameUnpaused — Logs when the game is unpaused.
  • onKickRateLimitSet — Logs kick rate limit changes.
  • onPlayerAdminChange — Logs admin status changes.
  • onPlayerChat — Parses commands and executes relevant actions.
  • onPlayerKicked — Logs player kicks.
  • onPlayerJoin — Initializes player data and assigns teams.
  • onPlayerLeave — Resets player lap info and stops game if empty.
  • onPlayerTeamChange — Resets lap data on team change.
  • onPositionsReset — Resets lap data for all players.
  • onRoomLink — Logs room link when set.
  • onStadiumChange — Loads new circuit/map and assigns teams.

Customization

  • Modify the _Circuits array to add or remove maps.
  • Customize lap counts and other constants as needed.
  • Extend checkIfTrolling(), checkPlayerLaps(), endRaceSession(), and logPlayerSpeed() with your own game logic.
  • Adjust colors, fonts, and sounds for announcements by changing the colors, fonts, and sounds objects.

Notes

This bot focuses on lap timing and speed display for F1-style racing in Haxball. It does not currently include advanced features like grid positions or anti-AFK detection but can be extended as needed.


Credits

This project is built upon and inspired by the HaxBall Simple F1 Racing Bot by thenorthstar. Many features and ideas, including lap timing and troll detection, are adapted from their original work. Big thanks for their open-source contribution!


License

MIT License — see LICENSE for details.


Releases

No releases published

Packages

No packages published