Jump to content

[HELP]Random Spawn


Domingos MTA

Recommended Posts

Posted (edited)

I am making a script to spawn objects in random places on the map, but I have a question, is there a function that does this automatically or do I need to manually add the locations?

Edited by Domingos MTA
Posted (edited)
function random()
  local x, y = math.random(-2000, 2000), math.random(-2000, 2000)
  local z = getGroundPosition(x, y, 200)
  createObject(9000, x, y, z) --Replace object id with your own
end

 

Edited by Miika
Posted

Simple way is go to gamemode /play folder open it look for file some like bou...I forget the name check them by editing u will see all local spawns with. Vehicles spawn too edit the local spawn to ur required spawn ! This will only work on play mode(free roam)

Posted
5 hours ago, Miika said:

function random()
  local x, y = math.random(-2000, 2000), math.random(-2000, 2000)
  local z = getGroundPosition(x, y, 200)
  createObject(9000, x, y, z) --Replace object id with your own
end

 

getGroundPosition

It is required that the point is near enough to the local player so that it's within the area where collision data is loaded. If this is not the case, an incorrect position will be returned

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