[RELEASE] FiveM-Trains : Complete standalone AI trains system and enterable trains

I tried only a few seconds and the trains left in 2802 but in no time they disappear the 2431 works well.

Although I am still the same with the textures of some machines, I cannot buy the ticket

I really like the script! It’s great. I just had to do a little work with the ESX and the SMS messages + I added the aboveground ticket machines via coords.

The only big problem that I have is: The train despawn just like arcticx2’s

Juste use build 2431.

Can you show me how you did the coordinates with the machines

Sure just a moment

I got it to work by removing freight. The freight train had a few bugs with spawning.

But now I got this to work I get a crash notification sometimes: https://media.discordapp.net/attachments/723912246098657280/743781476453056512/Screenshot_3.png

I cant seem to buy tickets at the ticket booth. HELP?

1 Like

These machine doesn’t have a real “object”. there are simple texture.

I need to map the machine there.

Are you reffering to my issue above?

He is

Using such a old build… esp on linux… is not a option for some of us. are u working on a way to get it working without going back too a old build?

1 Like

There is a problem the blips of the trains are only seen by the first one who enters the server with id 1, the rest cannot see them

Yup I got the same problem

just use the spawn event and refresh ( create the blip ) whenever a new player comes to the server

can you show me the code to do that

I only need this of the blips and some textures of stations that do not sell tickets to have this resource complete, any help will be greatly appreciated

1 Like

Please update to newer build. It’s useless to use such an old build.

i will give you some codes cause i didnt test it but it will give you the picture to fix/do it.

call this after each CreateMissionTrain like this

TriggerServerEvent("FiveM-Trains:updateBlip", Train)

then

if ShowTrainBlips then
        ESX.TriggerServerCallback('FiveM-Trains:askUpdateBlips', function(result)
            local res = result

            for i=1, #res, 1 do
                if DoesEntityExist(res[i]) and not DoesBlipExist(res[i]) then

                    print("ADD BIP FOR " .. res[i])

                    local MetroBlip = AddBlipForEntity(res[i])
                    SetBlipSprite(MetroBlip, 660)
                    SetBlipDisplay(MetroBlip, 4)
                    SetBlipScale(MetroBlip, 0.8)
                    SetBlipColour(MetroBlip, 2)
                    SetBlipAsShortRange(MetroBlip, true)
                    BeginTextCommandSetBlipName("STRING")
                    AddTextComponentString("Metro")
                    EndTextCommandSetBlipName(MetroBlip)

                end
            end

        end)
    end

add this after AddEventHandler("StartTrain", StartTrain) in client side,

and add this to server side

local blips_entity = {}

RegisterServerEvent("FiveM-Trains:updateBlip")
AddEventHandler('FiveM-Trains:updateBlip', function(blips)
	table.insert(blips_entity , blips)

	print(ESX.DumpTable(blips_entity))
end)


ESX.RegisterServerCallback('esx_interact:askUpdateBlips', function(source, cb)
	local found = false

	for i=1, #blips_entity, 1 do
		if not DoesEntityExist(blips_entity[i]) then
			table.remove(blips_entity , i)
		end
	end

	cb(blips_entity)
end)

ok , maybe this is not the perfect or normal way to do it , but here we go , first you will pass the trains entity to server side , then after a player joins to the server it will ask for it from server side , the server side will pass the entities to client side , client side will check if that entity is exist it will add the blip to it . i hope this help you in any way

he cant because of how fivem react to owners of entity and their scope since build 2689 or so

Hmm but FiveM always include older patches and updates. It is still useable. I’m not the expert but just saying what FiveM devs are saying.

Oh and this one still works: [Release] TrainSportation ~ Drive & Be a Passenger in a train!

So trains are still spawnable and driveable

1 Like