Is there a script to make a random vehicle appear?
so that you don’t choose your vehicle
thank you
local vehicleList = { "adder", "t20", "seashark" }
RegisterCommand("randomcar", function()
local randomCar = vehicleList[math.random(#vehicleList)]
local vehicle = CreateVehicle(..., randomCar)
...
end)
Pseudo + did not test obviously
I would try something like this:
local vehicleModels = {
"blista",
"faggio",
"comet"
}
function getRandomVehicleModel()
local randomIndex = math.random(1, #vehicleModels)
return vehicleModels[randomIndex]
end
and then
local vehicleModel = getRandomVehicleModel()
local player = GetPlayerPed(-1)
local x, y, z = table.unpack(GetEntityCoords(player))
local heading = GetEntityHeading(player)
local vehicle = CreateVehicle(GetHashKey(vehicleModel), x, y, z, heading, true, false)
I did not try it out, but it should work.