Jump to content

[math.random]


SzbyDev

Recommended Posts

I try to random spawn locations but not working

local fegyverPedP = {

		--{2274.2573242188, -262.47836303711, 9.2684917449951},
		--{1491.6328125, 295.41278076172, 18.663465499878},
		[1] = {2756.822265625, -2513.9208984375, 13.642685890198},
		[2] = {2761.572265625, -2531.7333984375, 13.638335227966},

	}


    function createped(fegyverPed,fegyverPedP)
       local randompos = math.random(1, #fegyverPedP)
	   fegyverPed = createPed(111, fegyverPedP[randompos], fegyverPedP[randompos], fegyverPedP[randompos])
	   --outputChatBox(fegyverPedP[randompos][1], fegyverPedP[randompos][2], fegyverPedP[randompos][3])
       setElementInterior(fegyverPed, 0)
       setElementDimension(fegyverPed, 0)
       setElementFrozen(fegyverPed, true)
       setElementRotation(fegyverPed, 0, 0, 90)
	end	
  • Confused 1
Link to comment
  • Moderators
Quote

	   fegyverPed = createPed(111, fegyverPedP[randompos], fegyverPedP[randompos], fegyverPedP[randompos])
	   --outputChatBox(fegyverPedP[randompos][1], fegyverPedP[randompos][2], fegyverPedP[randompos][3])

 

The answer to your question is already in YOUR comments. ¬¬

 

local fegyverPed = createPed(111, fegyverPedP[randompos][1], fegyverPedP[randompos][2], fegyverPedP[randompos][3])

 

 

Link to comment
36 minutes ago, asdninja said:

I try to random spawn locations but not working


local fegyverPedP = {

		--{2274.2573242188, -262.47836303711, 9.2684917449951},
		--{1491.6328125, 295.41278076172, 18.663465499878},
		[1] = {2756.822265625, -2513.9208984375, 13.642685890198},
		[2] = {2761.572265625, -2531.7333984375, 13.638335227966},

	}


    function createped(fegyverPed,fegyverPedP)
       local randompos = math.random(1, #fegyverPedP)
	   fegyverPed = createPed(111, fegyverPedP[randompos], fegyverPedP[randompos], fegyverPedP[randompos])
	   --outputChatBox(fegyverPedP[randompos][1], fegyverPedP[randompos][2], fegyverPedP[randompos][3])
       setElementInterior(fegyverPed, 0)
       setElementDimension(fegyverPed, 0)
       setElementFrozen(fegyverPed, true)
       setElementRotation(fegyverPed, 0, 0, 90)
	end	

local fegyverPedP = {
    {2274.2573242188, -262.47836303711, 9.2684917449951},
    {1491.6328125, 295.41278076172, 18.663465499878},
    }

function createped(fegyverPed,fegyverPedP)
    posPed = math.random(1,#fegyverPedP)
    for i,v in ipairs (fegyverPedP) do
        if i = posPed then
            fegyverPed = createPed(111, v[1], v[2], v[3])
            setElementInterior(fegyverPed, 0)
            setElementDimension(fegyverPed, 0)
            setElementFrozen(fegyverPed, true)
            setElementRotation(fegyverPed, 0, 0, 90)
        end
    end
end


Edited by AncienT
Link to comment
  • Moderators
local fegyverPedP = {
	{2756.822265625, -2513.9208984375, 13.642685890198},
	{2761.572265625, -2531.7333984375, 13.638335227966}
}


function createThisPed(positions)
   local randomPos = math.random(#positions)
   local fegyverPed = createPed(111, positions[randomPos][1], positions[randomPos][2], positions[randomPos][3])
   setElementInterior(fegyverPed, 0)
   setElementDimension(fegyverPed, 0)
   setElementFrozen(fegyverPed, true)
   setElementRotation(fegyverPed, 0, 0, 90)
end	

createThisPed(fegyverPedP)

Untested

Edited by IIYAMA
Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...