• Check if player is in an area..
    9 replies, posted
Sorry if this post is not that exact. (Type if you wan't more explaining) Okay, i wanna check if someone is in spawn. So i thought to my self can you do like, AreaCreate(Pos, Pos,Name) and then like if player is in area then...
Here's an implementation I made here: [url]https://github.com/SuperiorServers/plib_v2/blob/master/lua/plib/libraries/zone.lua[/url] [editline]18th July 2016[/editline] Use: local Area = QuadPrism( vecMinCorner, vecMaxCorner ); print( Area:PointInside( Player:GetPos() ); or local Area = Sphere( vecCentre, flRadius ); print( Area:PointInside( Player:GetPos() );
@code_gs Not really what i looked for... :| I just wana make a rectangle, but how do you create it, i can see you get the center and all that, but creating it...
[img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/FindInBox]ents.FindInBox[/url] And loop through the result and check for IsPlayer(). Or use a custom Trigger Entity. (An entity that triggers once a player enters it's bounding box). If you just want to check if a SpawnPoint is valid and a player will be able to spawn there without getting stuck You should probably use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/util/TraceHull]util.TraceHull[/url]
[QUOTE=RazMouze;50731837]@code_gs Not really what i looked for... :| I just wana make a rectangle, but how do you create it, i can see you get the center and all that, but creating it...[/QUOTE] That's what a QuadPrism is; a rectangular prism is just a kind. How are you wanting to create the zone?
[QUOTE=Lolle;50731857][img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/FindInBox]ents.FindInBox[/url] And loop through the result and check for IsPlayer(). Or use a custom Trigger Entity. (An entity that triggers once a player enters it's bounding box). If you just want to check if a SpawnPoint is valid and a player will be able to spawn there without getting stuck You should probably use [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/util/TraceHull]util.TraceHull[/url][/QUOTE] Very useful! What is used in this addon [url]https://scriptfodder.com/scripts/view/583/nlr-zones-updated[/url] [editline]18th July 2016[/editline] [QUOTE=code_gs;50731864]That's what a QuadPrism is; a rectangular prism is just a kind. How are you wanting to create the zone?[/QUOTE] I want so you use like the command GetPos and then you type in two cordinates it finds the space between the two points, and i can check if someone is in that space and lets just say slay them or something.
[QUOTE=RazMouze;50731870]Very useful! What is used in this addon [url]https://scriptfodder.com/scripts/view/583/nlr-zones-updated[/url] [editline]18th July 2016[/editline] I want so you use like the command GetPos and then you type in two cordinates it finds the space between the two points, and i can check if someone is in that space and lets just say slay them or something.[/QUOTE] I'm guessing that although he just displays the area as a circle, he's really doing an [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/FindInSphere]ents.FindInSphere[/url] check each Think or at whatever interval. FindInBox will achieve the same thing in a rectangle.
[QUOTE=code_gs;50731907]I'm guessing that although he just displays the area as a circle, he's really doing an [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/ents/FindInSphere]ents.FindInSphere[/url] check each Think or at whatever interval. FindInBox will achieve the same thing in a rectangle.[/QUOTE] if i use the ents.FindInBox() how is the coordinates supposed to be inside the ()?
You need to have the minimum and maximum vector of your box. If this is a static area, you can go into single-player and type "lua_run print( Entity(1):GetPos() )" for the farthest corners, and form Vector( lowest X, lowest Y, lowest Z ) and Vector( highest X, highest Y, highest Z ) for the function arguments inside the ().
[QUOTE=code_gs;50731971]You need to have the minimum and maximum vector of your box. If this is a static area, you can go into single-player and type "lua_run print( Entity(1):GetPos() )" for the farthest corners, and form Vector( lowest X, lowest Y, lowest Z ) and Vector( highest X, highest Y, highest Z ) for the function arguments inside the ().[/QUOTE] Thanks :)
Sorry, you need to Log In to post a reply to this thread.