itHyperoX Posted July 10, 2017 Share Posted July 10, 2017 Hello guys, i'm currently working on pilot job, but i got some problems. How can i make this work? What i want: When player spawned the job vehicle, the player get a random checkpoint in another airport. When he hit the checkpoint, new checkpoint created from table. local posTable = { {{-1341.5460205078, -149.02934265137, 14.1484375}}, {{-1586.5443115234, -214.85159301758, 14.1484375}}, {{-1478.2484130859, 12.554589271545, 14.369514465332}} } function createRandomPos() local rTable = posTable[math.random(#posTable)] spawnX, spawnY, spawnZ = unpack(rTable) jobMarker = createMarker(spawnX,spawnY,spawnZ,"checkpoint",2,255,255,0,100) end addEvent("startPilotMarkers",true) addEventHandler("startPilotMarkers",root,function() createRandomPos() addEventHandler("onClientMarkerHit",jobMarker,function() destroyElement(jobMarker) outputChatBox("Success") createRandomPos() end) end) Link to comment
#BrosS Posted July 10, 2017 Share Posted July 10, 2017 local posTable = { {-1341.5460205078, -149.02934265137, 14.1484375}, {-1586.5443115234, -214.85159301758, 14.1484375}, {-1478.2484130859, 12.554589271545, 14.369514465332} } function createRandomPos() local x, y, z = unpack(posTable[math.random(#posTable)]) jobMarker = createMarker(x,y,z,"checkpoint",2,255,255,0,100) end addEvent("startPilotMarkers",true) addEventHandler("startPilotMarkers",root,function() createRandomPos() addEventHandler("onClientMarkerHit",jobMarker,function() destroyElement(jobMarker) outputChatBox("Success") createRandomPos() end) end) Link to comment
pa3ck Posted July 11, 2017 Share Posted July 11, 2017 local posTable = { {{-1341.5460205078, -149.02934265137, 14.1484375}}, {{-1586.5443115234, -214.85159301758, 14.1484375}}, {{-1478.2484130859, 12.554589271545, 14.369514465332}} } You have double {{ }} brackets, meaning if you wanted to get the first 3 positions, you'd need posTable[1][1][1], posTable[1][1][2], posTable[1][1][3] or with unpack( posTable [ math.random ( #posTable ) ] [ 1] ) Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now