Witam jak zrobic aby losowa?o miejsce repsu Pojazdu?
Mam doki i jest 1 miejscie gdzie sie spawnuje Pojazd i sie buguj? Wi?c chce aby Sie losowa?o gdzie ma sie respic pojazd
Kod
[lua]
local cs=createColSphere(-1567.35,105.95,3.55+15, 4)
function shuffle(t)
local n = #t
while n >= 2 do
-- n is now the last pertinent index
local k = math.random(n) -- 1 <= k <= n
-- Quick swap
t[n], t[k] = t[k], t[n]
n = n - 1
end
return t
end
local function vr()
if (#getElementsWithinColShape(cs,"vehicle")>0) then
return
end
local pojazdy=getElementsByType("vehicle")
if (#pojazdy<1) then return end
local wybrane={}
for _,pojazd in ipairs(pojazdy) do
if isElementInWater(pojazd) and not getVehicleController(pojazd) then
local x,y,z=getElementPosition(pojazd)
if (z<-1) then
table.insert(wybrane,pojazd)
end
end
end
if (#wybrane<1) then return end
-- for i,v in ipairs(wybrane) do
-- local dbid=getElementData(v,"dbid")
-- outputDebugString("Pojazd " .. getElementModel(v) .. (isElementInWater(v) and "woda" or "nie") .. " dbid " .. dbid)
-- end
outputDebugString("Pojazdow w wodzie/pod mapa: " .. #wybrane)
shuffle(wybrane)
local pojazd=wybrane[1]
-- local x,y,z=getElementPosition(pojazd)
-... |