Jump to content

Need Help With Random Picking


damien111

Recommended Posts

I want my script top randomly pick 1 of 10 or 20 functions to execute. This is for taxi script. The script will first detect if he is in a taxi. The player will randomly be given a marker to go to with a per near it. When he enters the marker the ped is warped to the car,he has to take it to another marker. Then the random chooser function is executed again and so forth. My only problem so far is with this random choosing thing. Can someone point me in the right direction. Thanks

Written with my kindle fire sorry bout any typos!!!!

Link to comment

First, we make the table with many coordinates:

local coordinates = 
    { 
        { 0, 0, 5 }, 
        { 0, 0, 10 } 
    } 

second, we make a function to get random from it:

function getRandomCoordinates ( ) 
    return unpack ( coordinates [ math.random ( #coordinates  ) ] ) 
end 

And third, we use our function:

x, y, z = getRandomCoordinates ( ) 

About the vehicle, you can use getPedOccupiedVehicle.

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