toptional Posted April 2, 2013 Posted April 2, 2013 I'm not sure how to use math.random I'm trying to create a vehicle randomly on the map can anyone give me an example? I tried this but it's not working planeCrash= createVehicle ( 577, math.random,math.random,math.random) Thanks.
DakiLLa Posted April 2, 2013 Posted April 2, 2013 You have to specify the intervals from which the random value will be taken, e.g.: local rnd = math.random( 10, 20 )
toptional Posted April 2, 2013 Author Posted April 2, 2013 Is there anyway i can find out the coordinates of intervals from the gta map? without figuring them out will takes long?
DiSaMe Posted April 2, 2013 Posted April 2, 2013 The X coordinate is -3000 on the edge of the western side and 3000 on the east. The Y coordinate is -3000 in the south and 3000 in the north.
toptional Posted April 2, 2013 Author Posted April 2, 2013 I got it working, but it's kind of a bad way, the planes spawns in water sometimes sometimes in a building. so i was thinking of creating a table and selecting a random selection of 3 coordinates, any idea how this could be done? I can't figure it out.
tosfera Posted April 2, 2013 Posted April 2, 2013 Best thing that I prefer to do so, is create an array in another array giving the X, Y, Z into it. The use a loop to get random info. Something like; local saves = { {"0","0","5","522"}, {"632","1253","51","522"}} local rand = math.rand(#saves); for i, item in ipairs(saves) do eventVehicle = createVehicle(item[4],item[1], item[2], item[3]); end
Ludo Posted April 2, 2013 Posted April 2, 2013 Best thing that I prefer to do so, is create an array in another array giving the X, Y, Z into it. The use a loop to get random info. Something like; local saves = { {"0","0","5","522"}, {"632","1253","51","522"}} local rand = math.rand(#saves); for i, item in ipairs(saves) do eventVehicle = createVehicle(item[4],item[1], item[2], item[3]); end That will create a vehicle for each line in the table, so if you want the creation of just 1 vehicle you should do something like this: --x, y, z, model spawns = { {200, 200, 34, 522}, {400, 300, 25, 411}, {567, 235, 56, 567} } function whatEver() rLine = math.random(1, #spawns) createVehicle(spawns[rLine][1], spawns[rLine][2], spawns[rLine][3], spawns[rLine][4]) end --Remember to call the function C:
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