• Making a Box
    6 replies, posted
Hi, I am trying to make a box in a certain area and if someone is in it it runs a function. Sorta like a radar. I tried [url]http://wiki.garrysmod.com/?title=Ents.FindInBox[/url] . Any clue?
Is it the function you dont understand, or how to use it or how to get the cordinates right, or..? You dont post any information.
Sorry, about the lack of explanation. I don't really understand any of it and was hoping someone could explain it to me or give me a really small slit of sample data. Like, how do I make the box? How do I find the x, y, z coordinates in the map? After I make the box how do I run a function inside it?
[quote]Like, how do I make the box?[/quote] You need to create an entity, and probably do something like: [code]function ENT:Think() for k, v in pairs (player.ents.FindInSphere( Vector(0, 0, 0), 50 )) do -- stuff end end [/code] This [i]should[/i] do stuff to players, inside a radius of 50 from the given point. [quote]How do I find the x, y, z coordinates in the map?[/quote] Type GetPos in console to get the cordinates of your current location. [quote]After I make the box how do I run a function inside it?[/quote] You need to create an entity and put in the given code.
So, how would I make a box, not a Sphere? [lua] function ENT:Think() for k, v in pairs (player.ents.FindInBox( Vector(0, 0, 0), 50 )) do -- stuff end end [/lua] Is the Vector different at all?
Well, I dont know with the box. [code]ents.FindInBox( Vector(-32,-32,-32), Vector(32,32,32) )[/code] I'm [i]guessing[/i] the cordinates given are upper-left corner to lower-right corner, or something like that.
That is what I'd assume also BusyMoney. So with the bit of code in the example on the wiki, I'm guessing the box would be 64 x 64 x 64. Also I believe the description is incorrect. [quote] This example finds all the entities near the origin of the map[/quote] This is implying that the maps origin is at (0, 0, 0) which we know most map origins are not at 0, 0, 0. I dont know if you know, but with vectors you are only giving it the end coordinates. The vector start coordinates always start at (0, 0, 0) Why are you doing it this way though? Wouldn't you be better off putting a trigger in the map and then finding players that way? Maybe if you told us the application of this we might be more helpful.
Sorry, you need to Log In to post a reply to this thread.