Jump to content

[QUESTION] Couple Scripting Questions


F13MTA

Recommended Posts

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

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