Custom Car Spawn

Hello,:::

I edited the New\resources\fivem-map-skater\map.lua and added the following lines:

vehicle_generator “airtug” { -830, 169, 70, heading = 228.2736053466797 }
vehicle_generator “airtug” { -54.26639938354492, -1679.548828125, 28.4414, heading = 228.2736053466797 }

then i deleted the New\cache\http-files\fivem-map-skater.rpf so it will be recreated. But when i teleport to Michaels house then there is no airtug. Did i do something wrong or is there a better way to spawn a car?

Thanks,

Blacky25

-830, 169, 70

Try to change

-830.0, 169.0, 70.0

vehicle_generator “airtug” { -830.0, 169.0, 70.0, heading = 228.2736053466797 }

Doesn’t spawn anything :confused:

Have a same problem. Car didn’t spawning then i am online, but then I have a little red square in the game(means that i’m offline) - car is spawning (but first i need go away from the location, where it it will be spawned, and come back)

1 Like

it could be your server… but idk

@匚яαzγ_廾ατεя said in Custom Car Spawn:

it could be your server… but idk

what may be wrong with server?

it could be Blocking the spawn. when the red square is there, you are simply in your own game, server doesn’t do anything

I think it;s not “my server” problem it’s problem of Fivereborn serrver, cause I testing it on a clear server.

Have some new details. I edit mapmanager_client.lua

this

local hash = GetHashKey(name)
Citizen.Trace('vehicle hash ’ … tostring(hash) … “\n”)
local carGen = CreateScriptVehicleGenerator(x, y, z, heading, 5.0, 3.0, hash, color1, color2, -1, -1, true, false, false, true, true, -1)
SetScriptVehicleGenerator(carGen, true)
SetAllVehicleGeneratorsActive(true)

change to

local hash = “qwerty” --ANY SYMBOLS HERE
Citizen.Trace('vehicle hash ’ … tostring(hash) … “\n”)
local carGen = CreateScriptVehicleGenerator(x, y, z, heading, 5.0, 3.0, hash, color1, color2, -1, -1, true, false, false, true, true, -1)
SetScriptVehicleGenerator(carGen, true)
SetAllVehicleGeneratorsActive(true)

Now in variable “hash” i have some string, and then i load game i get RANDOM car. I don’t understand why?

Somebody explane me please.

Resolved! Creators forgot about “RequestModel(hash)” before “CreateScriptVehicleGenerator” function.

Code in “mapmanager_client.lua” of “vehicle_generator”:

What must be changed that it worked?

Please give me the full code of this function!

1 Like

You must add “RequestModel(hash)” to “getMapDirectives” function in the file mapmanager_client.lua.
full code of this function:

AddEventHandler(‘getMapDirectives’, function(add)
add(‘vehicle_generator’, function(state, name)
return function(opts)
local x, y, z, heading
local color1, color2

        if opts.x then
            x = opts.x
            y = opts.y
            z = opts.z
        else
            x = opts[1]
            y = opts[2]
            z = opts[3]
        end

        heading = opts.heading or 1.0
        color1 = opts.color1 or -1
        color2 = opts.color2 or -1

        local hash = GetHashKey(name)
		
        Citizen.Trace('vehicle hash ' .. tostring(hash) .. "\n")
		 RequestModel(hash)
        local carGen = CreateScriptVehicleGenerator(x, y, z, heading, 5.0, 3.0, hash, color1, color2, -1, -1, true, false, false, true, true, -1)
        SetScriptVehicleGenerator(carGen, true)
        SetAllVehicleGeneratorsActive(true)

        Citizen.Trace("added car gen " .. tostring(carGen) .. "\n")

        state.add('cargen', carGen)
    end
end, function(state, arg)
    Citizen.Trace("deleting car gen " .. tostring(state.cargen) .. "\n")

    DeleteScriptVehicleGenerator(state.cargen)
end)

end)

I just test it. It changed nothing. No vehicles are spawned on the coordinates. Is maybe the order of the resources in the file ‘citmp-server.yml’ important? (spawnpoint resource before mapmanager resource ?)

I try something but nothing works. Can someone help? Maybe a full instruction what must be done that it worked?

I got it. Just the function ‘LoadAllObjectsNow()’ was missed:

@Bob May i ask did you make the other changes here or only the LoasAllObjects() to get this to work?

1 Like

@GEEKmechanic Got it! works good, just trying to find how to get the heading for the vehicle coordinates.

does anyone have the coordinates for the police station parking spot spawn locations?

@Wolfstrike If it helps i used https://www.gta5-mods.com/scripts/show-coordinates to get the coordinates. put the .asi file in your reborn/plugins folder and in game at the bottom of the screen you will see the x, y, z, and angle coordinates.

1 Like

Hi, I tried your solutions, but no car spawn at the coordinates. @GEEKmechanic could you zip me your mapmanager ressource and map.lua file please ? Thanks