Any way to use console to spawn in vehicles and not switch to them immediately?

Discussion in 'Utilities and programming' started by m8121, Sep 10, 2023.

  1. m8121

    m8121
    Expand Collapse

    Joined:
    Sep 10, 2023
    Messages:
    4
    I've been messing around with spawning vehicles and props using console commands. I was wondering if there was any way to spawn in vehicles without switching to them as soon as they spawn in.

    I understand there are a few ways to spawn in traffic, but I'd like to be able to specify the location of the spawned vehicles or props and do so while I still have control over my original vehicle.

    I found this example code here, it does what I want, but switches to the props as soon as they're spawned in. Wondering if I can do this exact thing without switching to the newly spawned entities.


    Code:
    local items = 10
    local offset = vec3(-150, -200, 105)
    
    for i = 0, items - 1 do
      local angle = i / items * 2 * math.pi
     
      local x = math.cos(angle) * 10
      local y = math.sin(angle) * 10
      local z = 0
     
      local vehPos = vec3(x, y, z) + offset
      local vehRot = quatFromAxisAngle(vec3(0,0,1), -angle)
     
      core_vehicles.spawnNewVehicle("cardboard_box", {config = 'vehicles/cardboard_box/large.pc', pos = vehPos, rot = vehRot})
    end
     
  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.
    Dismiss Notice