• How can i make a box and check if a player is in?
    8 replies, posted
How can i make a box and check if a player is in? I know it's a noob question but i tried everything and couldn't do it :( Than you :)
[b][url=http://wiki.garrysmod.com/?title=Ents.FindInBox]Ents.FindInBox [img]http://wiki.garrysmod.com/favicon.ico[/img][/url][/b] is what you need.
I need a Captain Obvious rating :-D.
I won't loop through all entities in the box, i will do it with a range of coordinates and check if the player position is in the range. Thank you anyway
Ents.FindInBox is so much easier. Also, from what I know you can set a argument to only check for players. If not I could even do that. [editline]10th March 2011[/editline] My bad. No filters. Ignore my comments, I'm an idiot.
I have tryed with [lua]if (player:GetPos(1) > -6966 && player:GetPos(1) < -6866 && player:GetPos(2) > -9685 && player:GetPos(2) < -9620) then return true else return false end;[/lua] and I'v got this :( [lua]...lua:1] attempt to compare number with userdata[/lua] How can i compare it? Thanks you :/
[QUOTE=eilex;28562131]How can i compare it? Thanks you :/[/QUOTE]I'm not exactly sure how you'd do that, but I can point out the mistakes you did in this: Ent:GetPos() does not take any arguments and if it would you'd still be comparing vector to a number.
Fixed :) It works with [lua]player:GetPos().x[/lua] not with [lua]player:GetPos(1)[/lua]
You don't need to do the whole "if myBoolean then return true else return false end" Just do "return myBoolean"
Sorry, you need to Log In to post a reply to this thread.