Play Golf in FiveM at the golf course! All 9 holes are playable, with the ability to create parties and invite your friends to join you in the fun.
This script is performance-friendly, idling at 0.00ms when not playing Golf and idling at 0.03ms when playing Golf.
It is written in Lua, with the UI being written in TypeScript using React.
To start playing golf, you open the tablet, create a party or join a party and you’re ready to go. Walk up to the tee and press E to place your golf ball and press E to move to your golf ball. From there you can swing your club. The club controls are changeable in the settings of FiveM / GTA V.
Features
The following are features that you can expect:
Place golf balls and swing your club to hit them, with a power meter.
All 9 holes are playable, with hole detection.
Switch between a driver club, an iron club, a wedge club and a putter.
Togglable putting grid to aid in terrain elevation so that you can get the golf ball into the hole more easily.
Out-of-bounds detection for when the golf ball leaves the current playing hole.
Realistic golf ball physics, where the golf ball will not bounce if landing in a bunker.
Have your score tracked every time you hit the golf ball, with the ability to achieve a hole-in-one and display fireworks for everyone at the golf course to celebrate.
Tablet UI to create parties and invite your friends to partake in your golf game.
Ability to view past golf games and scores.
Equipped with sound effects and particle effects for a more immersive experience.
Support for QBCore, ESX, custom frameworks and standalone usage.
Configurations for your liking.
Documentation is available.
Code is accessible : No, but configuration and framework-specific files are available. Subscription-based : No. Lines (approximately) : 2000. Requirements : None. Support : Yes.
At the moment, there isn’t support for ox_lib’s version of PolyZone.
Didn’t know it had its own module for that. But it isn’t a train smash, I’ll go ahead and add support for this.
You’ll be able to change between PolyZone and ox_lib’s module via config in an update.
I’ll get to work on that
The tablet freezing when joining a lobby / party, I’ve already fixed a bug where if you had inputted an invalid password or lobby / party code, it’d freeze. Among other conditions. So this should be resolved.
In terms of it breaking with an index nil error when finishing hole one, can you please post a screenshot of the error in F8? Would help try to locate where the issue is. I’ve tested it with two players so far and seems to work, are you having more than two players in the lobby?
Pushed an update:
#] Fixed an issue where the tablet would “freeze” when entering an invalid party code or password, amongst other conditions.
#] Added an indication on what button to press to place down your gold ball and start playing golf.
In works:
#] Support for PolyZone via ox_lib module.
How does one start the golf games now? Is there an event for it that could be toggled off so we can trigger the even from somewhere else if there is like a ped or some other condition that needs to be met before golfing can begin?
You open the tablet, create a party or join a party and you’re ready to go. Walk up to the tee and press E to place your golf ball and press E to move to your golf ball. From there you can swing your club. The club controls are changeable in the settings of FiveM / GTA V.
At the moment, no there’s no way to call when to start golf. It begins by creating a party at the moment. You can however disable the tablet from being opened via keybind and rather open it via an export. This may aid you alternatively.
If you want to read the documentation for the script, I recommend checking out the Discord server. You can find more info on the webstore.
Pushed an update:
#] Fixed script warnings regarding “could not find client script x (defined in fxmanifest)”.
#] Fixed being able to cancel club swing whilst the golf ball is moving / in the air.
#] Improved out of bounds detection, hopefully resolving a “stuck” state.
#] Added more config options for customizability (located in _configs/sh_cfg_clubs.lua):
Option to do the approach animation when pressing E to begin shooting the golf ball.
Option to set the normal and fast shuffle speed.
Option to set the golf ball direction marker color and size.
Option to enable random heading to the golf ball direction marker, with the ability to set the minimum and maximum random.
Option to set the power increment when holding E to shoot the golf ball.
Option to set the initial speed multiplier, height velocity multiplier, whether or not the golf ball must bounce and the roll time per club.
#] Removed the need for PolyZone dependency.
#] Added a “How to Play” menu to the tablet, describing how to play golf and the keybinds (keybinds are fetched from _configs/sh_cfg_keybinds.lua).
#] Added new config option for parties (located in _configs/sh_cfg_party.lua):
Option to enable or disable password requirements to create or join a party. If disabled, players only need the party code to join a party.
#] Fixed an issue with trying to leave a joined party.
#] Added a blip for the tee to find your way to it.
Pushed an update:
#] Fixed a few typo’s.
#] Fixed a bug with out of bounds detection not detecting if the golf ball landed in water correctly.
#] Added a new hud element to display your current club.