[FREE][STANDALONE][TEST] Public Transport AI

NEW VERSION HERE

Old Post Hi everyone, I've been working on this resource for a while now and I need testers to test it.

WHAT IT DOES
NO ESX : it requires only the default resource of Fivem
It makes public transport aviable and fully configurable all managed by the game AI

LINK TO GITHUB
NEW VERSION AVAILABLE :arrow_forward: Click here

Here’s a preview


You can configure custom routes

    -- Route path: First spawn point - Vechileshop - Central Garage
	{ 	
		info = { 
			color = 84, -- Blip color
			hash = "bus", -- Vehicle hash
			busNum = 4, -- Num of buses for this route ( >= 1 ) 
			timeBetweenBus = 40, -- Time in second between buses if busNum > 1
            startHeading = 68.031  -- Bus heading when spawned
		},
        busStops = {
        -- position, heading and a boolean: if true the bus will stop, if false the bus 
        -- won't stop but will pass the waypoint
		    { pos = vector3(234.9626, -829.2527, 29.98755), stop = true },
		    { pos = vector3(-232.1934, -983.7758, 28.60583), stop = true },
		    { pos = vector3(-68.75604, -1078.668, 26.97144), stop = true },
		    { pos = vector3(176.8747, -1030.365, 29.3136), stop = false },
		    { pos = vector3(270.3956, -848.2022, 29.33044),  stop = false },
        }
	},
    -- You can add more routes
    {
         -- ...
    },

WARNING
This resource has a lot of problems so it need to be tested and fixed, especially the online part that I couldn’t test as much as I wanted.
So please open issues on github

Other resources

[ESX] Hitman (PvP)
[PAID][ESX] Pet Store

30 Likes

Looks like a nice script, just a little tip you can use vector4(x,y,z,w) w being heading so you don’t need to define it as a seperate value

1 Like

Hey!

Looks like a cool resource!
If I may suggest trying to improve AI Driving (following traffic laws) due to other npc’s/players;

Pretty sure that’s the way to improve it, nice job again!

1 Like

Great script I’ll be looking at it tomorrow and test it, I got some ideas I could add to this to make it even more fun to use the bus.

2 Likes

To go alongside Newtonzz suggestion. this is a handy tool for generating the driving style ID.

https://vespura.com/fivem/drivingstyle/

Nice script though!

3 Likes

is an excellent resource, use this from lines 75 to 89 of the client to solve the aggressive handling and respect the traffic laws

local task = OpenSequenceTask()
	for i=1, #path do
		TaskVehicleDriveToCoordLongrange(0, bus, path[i].pos, 50.0, 525187, 40.0) -- speed 20.0
		
		if path[i].stop == true then
			TaskVehicleDriveToCoordLongrange(0, bus, path[i].pos, 9.0, 60, 6.0)
			TaskPause(0, Config.WaitTimeAtBusStop*1000)
		elseif path[i].stop == false then
			TaskVehicleDriveToCoordLongrange(0, bus, path[i].pos, 50.0, 525187, 15.0)
			TaskPause(0, 1)
		end
	end
	SetSequenceToRepeat(task, true)
	CloseSequenceTask(task)
	TaskPerformSequence(busDriver, task)

This is pretty cool, actually. How do you ride the bus?

I can see great potential for this, maybe set up Dashound buses to run up to Paleto Bay and Sandy Shores.

1 Like

Thank you for the tip :slight_smile:

First of all thank you :smiley:

I choosed an ‘aggressive’ driving style to solve some problems.

  • In the decompiled scripts I found a driving style used for bus driving (1076369724) with some unknown flags I guess made for buses. Using a value like 525187 will make the bus take the curves wrong (like destroying traffic lights) and sometimes the bus won’t follow the navmesh
  • Another reason is that if the bus stops at every vehicle or ped if there are more than 1 bus per route they will end up crashing one into the other. Using 1076369724 as driving style help the buses have an equal distance (more or less)

About ‘Stop at traffic lights’ flag maybe it can be added in the config file as a boolean.

1 Like

Thank you. You can set up every route you want in the config file. There is an example and the instructions on how to do that inside the config.lua

1 Like

you could add a 3d text where busstops saying the time left to bus to reach to destination, if interested in creating an extended version of this contact me

1 Like

But can you board the bus and ride as a passenger? I must have missed it in the configuration.

That’s what the resrouce does. An AI ped drives the bus along the route setted in the config file and every player can board the bus as passenger

I wonder if it would work if I put for example 200 transport with spawn from different beginning which would all make the same circuit. :rofl:

2 Likes

This is SO awesome! Wish there was a information screen on, what next stop is and maybe a stop button?

Hello, first of all I have to say the script is very great!

I only have one problem because I use a Carlock which locks NPC cars, we can’t get on the bus, would you have a solution for us? : /

filter the bus hash in the carlock
so if it bus dont lock

If i try to change location bus not spawn, any advice to fix this?

how do you mean with the filter out?

I use an extra key script not the esx_carlock

I have tested the script and I have seen that it could not be restarted because it has functions with the playerDropped and PlayerJoined, I am looking on my own to do something but at the moment I have nothing.

I don’t know if you were referring to this problem.