Still doesn't work..
Outputing two index of 5 are the same
like: 5,2,2,1,3
My new code:
local peds = {}
local createdPeds = {}
local createPeds = {
[1] = {1067.0164794922, 2035.6273193359, 10.8203125, 90},
[2] = {1067.0299072266, 2041.1890869141, 10.8203125, 90},
[3] = {-2067.029296875, 2035.0201416016, 9.8203125,90},
[4] = {2067.0295410156, 1032.1505126953, 10.8203125,90},
[5] = {1067.0295410156, 2027.8729248047, 10.8203125,90}
}
function getRandomizePos()
local rnd = math.random ( #createPeds )
while createdPeds[rnd] do
rnd = math.random ( #createPeds )
end
table.insert(createdPeds,rnd)
local x,y,z,rot = createPeds[rnd][1],createPeds[rnd][2],createPeds[rnd][3],createPeds[rnd][4]
return x,y,z,rot,rnd
end
addEventHandler("onResourceStart", resourceRoot,
function ()
for index, v in pairs(dealerPeds) do
local x,y,z,rot,rnd = getRandomizePos()
local int = rnd
peds[int] = createPed(0,x,y,z)
if peds[int] then
setElementRotation(peds[int],0,0,rot)
end
createBlip(x,y,z,6,2,255,0,0,0,0,600)
end
end