Racing scripts for racing fans

Hey man. im using your fantastic script for a private server to do some racing with friends. we are also using moded cars. is there a way I can add the moded cars so they are recognised by your script. currently any moded car that is used just shows up as NULL in the records and stuff and im assuming they also will not get used for the random races. do you know how i would add these in to be used properly?
any help would be appreciated. i have very little experience with coding and such. I did try a few different things to add them in but no luck and dont think i can figure this out myself.

Thatā€™s because you need to define the Car name in a script within the folder your cars are in.

I havenā€™t used add-on vehicles with the scripts. I donā€™t have any experience with add-on vehicles, but, Iā€™ll try to figure out how you can use them with my scripts. You will eventually add the name of the add-on vehicle to the vehicles.txt file which is used as the source of any vehicles you can spawn.

Iā€™ve been working on the scripts and have changed quite a bit of it. There shouldnā€™t be any significant functional changes to the commands. Iā€™ve changed the vehicles.txt file into a .json file as an example of what Iā€™ve changed. Iā€™ve also renamed the raceData.json file to trackData.json. Iā€™ve also found and fixed a bunch of bugs that I didnā€™t notice before. Iā€™m also working on how-to videos for the scripts which helped me find most of the bugs. After Iā€™m satisfied with my changes, Iā€™ll upload them to github. I donā€™t know when that will happen, but it shouldnā€™t be too long.

I just figured out how to spawn add-on vehicles. The vehicleā€™s model name is in the vechicles.meta file between the <modelName> tags.

For example, the model name for my add-on vehicle in the vehicles.meta file is:

<modelName>gemera</modelName>

I can spawn the vehicle with '/races spawn gemera'. Unfortunately, its name shows up as NULL like you posted. Iā€™ve found one way to fix that.

In your fxmanifest.lua or __resource.lua file for the add-on vehicle, add the following:

client_script {
	'vehicle_names.lua'
}

In the same directory as the fxmanifest.lua or __resource.lua file of your add-on vehicle, create a file named 'vehicle_names.lua'

Add the following to the 'vehicle_names.lua' file:

Citizen.CreateThread(function()
	AddTextEntry('gemera', 'Koenigsegg Gemera')
end)

'gemera' is the model name and 'Koenigsegg Gemera' is the name displayed when you spawn the vehicle. You will need to do this for each add-on vehicle.

Thereā€™s probably a more elegant solution to this. Itā€™s one solution I found that seems to work.

Add the model name of your add-on vehicles to the 'vehicles.txt' file and you should be able to use them in the drop-down lists in the panels. You should be able to use them in random vehicle races as well.

that is amazing thank you and worked that out so fast as well. i will update my server later and test this myself make sure i dont get any issues but you have explained it very clearly.
would i also add the model name to the vehicle class texts such as the 00 to 21 depending on what class i would want to put them in?
i also do have some vehicle packs that have more than one car, for those would i just add in a line to the same Vehicle_names.lua such as:

Citizen.CreateThread(function()
AddTextEntry(ā€˜gemeraā€™, ā€˜Koenigsegg Gemeraā€™),
AddTextEntry(ā€˜S98ā€™, ā€˜Karin S98Kā€™)
end)

I believe the vehicle class is set in the vehicles.meta file between the <vehicleClass> tags. The vehicle class text files are not used for anything anymore. They were a convenience for a past version of the scripts that used text files as vehicle lists. Iā€™m going to remove them since they arenā€™t used anymore.

You are correct about adding a line to the Citizen.CreateThread function for each car in the multi-car add-on pack. Iā€™ve tested this on a multi-car add-on pack and it works.

I did some testing with it last night and have the ones i tested and working with your script which is great. I havent had a chance to test the random races but by the looks of it i would agree and looks like it would work. though it is a little harder to test haha.

Thank you for your help and how quickly you got back to me with this.

@GamyTaziT So whatā€™s the fix?

Most recent changes to the scripts:

-Removed player permissions code. Was way more complicated than what it was worth. It is possible for the same player to join a server using different names. It is also possible for different players to join a server using the same name.
-Removed updateRaceData and updateTrack functions
-Renamed raceData.json to trackData.json
-Modified aiGroupData.json: changed field ā€˜vehicleHashā€™ to ā€˜modelā€™ in saveGrp and overwriteGrp functions
-Converted vehicles.txt to json file and saved as vehicles.json
-Removed vehicles/ directory and contents.

races_client:
-Fixed bug not being able to load AI group
-Fixed bug not being able to spawn AI in race using custom class
-Fixed bug where gamer tags would sometimes dissappear when spawning ai group
-Fixed bug where best lap vehicle name for AI driver was not updated in random vehicle races
-Fixed bug where player registered race, joined race, left race, started race and was told that start event was ignored because player was idle
-Fixed bug where player registered race, joined race, left race, started editing, started race and was told that start event was ignored because player was editing
-Fixed bug where AI DNF timeout never starts when human/AI finishes race if race owner does not join
-Probably fixed bug where camera transitions would break after around 10 race starts by using DestroyAllCams
-Added call-back function argument to RegisterNUICallback function and called it to get rid of warnings
-Added setBlipCheckpointColor function to simplify editWaypoints function
-Added respawn indicator inspired by RustyTheDalek
-When AI or player respawns in a race, use primary, secondary, pearlescent and wheel colors of previous vehicle with newly spawned vehicle
-Added primary, secondary, pearlescent and wheel color arguments to putPedInVehicle and switchVehicle functions
-When adding waypoint through waypoint map, put waypoint 1.0 higher than ground level instead of at ground level
-Added ability to change vehicle of spawned AI driver using ai spawn command
-Added ability to change vehicle that player is driving by using spawn command
-Only allow saving or overwriting AI groups when race is registered, not after race has started
-Disabled spawn command when player is joining a race or player is in a race
-Allow registering a race if editing a track
-Renamed ā€˜Editā€™ panel to ā€˜Trackā€™ panel
-Changed ā€˜/races panelā€™ command to use ā€˜trackā€™ instead of ā€˜editā€™
-Added panel names to top of each panel
-Changed blip name in waypoint map of racers who join race to ā€˜Racerā€™ instead of default ā€˜Destinationā€™
-Update cash HUD when funds transactions occur

races_server:
-Fixed bug where players not given back buyin if joined to a race where AI are not allowed and then race is unregistered
-Fixed bug where players not given back buyin when player who registered race drops from server
-Fixed bug where players not given back buyin if prize distribution is invalid
-Fixed bug where players not given winnings after finishing race where AI are not allowed
-Fixed bug where player finishes race and races:delRacer event would be triggered for AI as well as humans instead of just for humans
-Fixed bug where races:finish event not sent to race owner(who did not join race) for AI finishers
-Removed winningsRL variable from races:finish event handler because it was redundant
-Used file names with LoadResourceFile and SaveResourceFile instead of file paths with native lua IO functions
-Load vehicles.json to create all vehicle list at server startup instead of loading vehicles.txt every time player joins

index.html:
-Renamed a lot of elements

index.css:
-Renamed a lot of elements

index.js:
-Renamed a lot of elements

Latest version of scripts at:

MAKE SURE TO READ ABOUT RECENT CHANGES THAT AFFECT THE PREVIOUS VERSION IN THE README.MD

1 Like

May go back and test this out on my local server, but specifically for The AI racingā€¦

Looks like you have been busyā€¦

Excellent

1 Like

It was a bunch of bug fixes and some command changes. Nothing new about the AI driving ability. If you find anything that seems broken, let me know please.

Nope,
I didnt mention there was anything new I was just saying, you have been busy & I was just making a statement, and was interested only in the Ai part ( Purely to make video footage) (I mean I never really tested it out before, anyway).

Still having fun with this script set. GF bought a new system for her house that I could use, started a new local server, added races, and fun against the AI. Iā€™m still terrible, but have fun making tracks and occasionally streaming them.

2 Likes

Iā€™m glad youā€™re enjoying the scripts. Someone requested a feature for random races where the same model vehicle does not appear again in later laps. Iā€™m probably going to implement this as an option for random races, but it will be a while before I work on it. They also requested random upgrades which Iā€™ll look into later on.

This race system would be sick as hell, if it integrated in this Racing Framework (GTA Online style)

Hardly call that a race system!

The OP here, his system is unique, the script you linked to is just basic coding, why would it have to be intergrated, when this script here is far more superia with so many featuresā€¦?

1 Like

I mean the start Custscene

Look forward to this, if your still working on this script.

Anyway you can add in transform option, you know like the ever popular change car at a transform checkpoint?

Iā€™ve been playing against AI racers again, and I changed driveMode: via Driving Style Calculator - GTA V from 787004 default to 262716 which does not have the old Reckless tag and they no longer run into the back of trucks, trailers, and other large vehicles, at least not today. Still playing with all the settings. Thank you again for this wonderful script. Helicopter Frogger races are always a blast.

Nice, I might have to try this.