Jump to content

how to put math.random?


Gallagher

Recommended Posts

function onClientGetNews(text1, text2, text3, text4, bool1, bool2, bool3, bool4) 
  local text1 = string.gsub(text1, "
", "\n") 
  local text2 = string.gsub(text2, "
", "\n") 
  local text3 = string.gsub(text3, "
", "\n") 
  local text4 = string.gsub(text4, "
", "\n") 
  guiSetText(news1, text1) 
  guiSetText(news2, text2) 
  guiSetText(news3, text3) 
  guiSetText(news4, text4) 
  if bool1 == "true" then 
  else 
    -- unhandled boolean indicator 
  end 
addEvent("onClientGetNews", true) 
addEventHandler("onClientGetNews", getRootElement(), onClientGetNews) 
addEventHandler("onClientResourceStart", resourceRoot, function() 
  build_loginWin() 
  guiSetVisible(background_front, false) 
  showLoginWindow(true) 
  guiSetInputMode("no_binds_when_editing") 
  fadeCamera(true) 
  setCameraMatrix(2885, 2837, 75, -500, 1010, -550) ---------how to put math.random? 
  triggerServerEvent("requestServerNews", localPlayer) 
end) 

when the player enters the camera login server gets this position,

I want cade time he is entering a new camera!

I made this table, but do not know how to use it in setCameraMatrix.

local LoginPos = { 
{2885, 6835, 50, -500, 1010, -550}, 
{5085, 837, 49, -500, 1010, -550}, 
{3285, 3831, 65, -500, 1010, -550}, 
} 
  local number = math.random(table.size(LoginPos)) 
    local x,y,z = LoginPos[number][1],LoginPos[number][2],LoginPos[number][3] 
  

Link to comment

Try this

  
local cameraspositions = { 
    { 329.10980224609, -2117.2749023438, 50.161201477051, 329.65179443359, -2116.4926757813, 49.853763580322 }, 
    { -224.32290649414, -153.71020507813, 35.085899353027, -223.61195373535, -153.04695129395, 34.852146148682 } 
} 
local ind = math.random ( #cameraspositions ) 
setCameraMatrix ( p, unpack ( cameraspositions[ind] ) ) 
  
  

Link to comment
  • Moderators
local number = math.random ( #LoginPos ) 
local x, y, z = unpack ( LoginPos [ number ] ) 

That should do.

but WHAT should I put in setCameraMatrix (2885, 2837, 75, -500, 1010, -550)?

Replace the 3 first arguments by x, y and z ?

setCameraMatrix (x, y, z, -500, 1010, -550) 

Link to comment

work

local LoginPos = { 
{2885, 2837, 75, -500, 200, -1500}, 
{2435, -1779, 17, 300, 1010, 2550}, 
{3285, 3831, 65, 600, 331, -550}, 
} 
  local number = math.random ( #LoginPos ) 
 local x,y,z = LoginPos[number][1],LoginPos[number][2],LoginPos[number][3] 
setCameraMatrix (x, y, z) 
  

I did so and it worked, but it does not work the camera rotation

how do I fix?

Link to comment
  • Moderators
local number = math.random ( #LoginPos ) 
local x, y ,z = LoginPos[number][1], LoginPos[number][2], LoginPos[number][3] 
local tx,ty,tz = LoginPos[number][4], LoginPos[number][5], LoginPos[number][6] 
setCameraMatrix (x, y, z, tx, ty, tz) 

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...