Jump to content

Taxi Job


Lloyd Logan

Recommended Posts

Create a table, place many coordinates there, get a random index and unpack the coordinates, then create the marker.

Sorry, I am totally confused, so far i have,

local dropOffs = { 
[1]={1813.51733, -1889.07434, 14.54434}, 
[2]={1825.07617, -1821.19128, 14.55475}, 
[3]={1824.75806, -1715.95935, 14.49071}, 
[4]={1843.08228, -1526.89624, 14.60579}, 
[5]={1853.63428, -1413.55920, 14.53299}, 
[6]={1855.38696, -1311.96008, 14.65701}, 
[7]={1827.38684, -1257.55383, 14.68799}, 
[8]={1760.68250, -1289.40527, 14.60042}, 
[9]={1711.00635, -1319.90845, 14.53422}, 
[10]={1738.90808, -1444.43054, 14.50528}, 
[11]={1841.47546, -1503.76233, 14.59137}, 
[12]={1822.14709, -1564.29834, 14.52254}, 
[13]={1817.74731, -1665.99097, 14.60268}, 
[14]={1818.21057, -1777.69324, 14.57040} 
}  

for k, v ipairs(dropOffs) do 

Thats all I have got right now :(( I feel i might give up on scripting altogether now!

Link to comment
math.random returns a random number from another number, e.g:
result = math.random ( 10 ) 
outputChatBox ( result ) 

that'll get a random number of 10.

With #table you can get the total amount of items inside a table ( NOTE: IT MUST BE AN INDEXED TABLE ).

A couple of points.

1. Will it get 1 random co-ordinates out 10?

2. I dont understand how i could use #, and what's and indexed table?

Link to comment
createMarker(unpack ( fireLocations [ math.random ( #dropoffs ) ] ), "cylinder", 1.5, 255, 0, 0) 

or

function unpackPos() 
return unpack ( fireLocations [ math.random ( #dropoffs ) ] ) 
end 
  
local x, y, z=unpackPos() 
createMarker(x, y, z, "cylinder", 1.5, 255, 0, 0) 

Edited by Guest
Link to comment
Both wrong, you are trying to unpack a number.
createMarker ( unpack ( dropoffs [ math.random ( #dropoffs ) ] ), "cylinder", 1.5, 255, 0, 0 ) 

I done this, but nothing happens?

local dropoffs = { 
[1]={1802.951171875, -1889.1865234375, 13.185905456543}, 
[2]={1784.349609375, -1890.255859375, 13.176010131836} 
}  
  
function rMarker() 
    createMarker ( unpack ( dropoffs [ math.random ( #dropoffs ) ] ), "cylinder", 1.5, 255, 0, 0 ) 
end 
addCommandHandler("heyy", rMarker) 

Link to comment
local dropoffs = { 
[1]={1802.951171875, -1889.1865234375, 13.185905456543}, 
[2]={1784.349609375, -1890.255859375, 13.176010131836} 
} 
  
function rMarker() 
local x, y, z = unpack ( dropoffs [ math.random ( #dropoffs ) ] ) 
    createMarker ( x, y, z, "cylinder", 1.5, 255, 0, 0 ) 
end 
addCommandHandler("heyy", rMarker) 

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