F13MTA Posted March 13, 2018 Share Posted March 13, 2018 I was wondering if anyone knew how to make items spawn randomly at differenct coordinates I supply. (IE: I want there to be 4 possible items spawn at 123.1, 123.1, 123.1) Also.. if I have 10 people in one dimension, how can I select one of the 10, and set them to their own team. I know how to set them to the team and all, but selecting one person at random. If you know of any resources on the community or anything I can use for reference or use, it'd be much appreciated <3 Link to comment
Forthwind Posted March 13, 2018 Share Posted March 13, 2018 (edited) 1. You can either make a table such as: myTable = { [1] = [itemID, x, y, z), [2] = [itemID, x, y, z), --etc } function spawnObject() number = math.random(1, 2) -- First item and last item in table createObject(myTable[number][1], myTable[number][2], myTable[number][3], myTable[number][4]) end -- add some edits to make it loop whatever times you want it to loop, to spawn said items or, if you're working on a flat surface where z is always the same you can do: createObject(itemID, math.random(x first side, x other side), math.random(y first side, y other side), z) Althrough I would recommend using the first method as you got full control. 2. Haven't really had any experience with this but I'm suggesting you to read the wiki about getElementsByType. Edited March 13, 2018 by Forthwind 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