Hello i'm trying to make something.
If player are in an specific arena he can't do an commands for example.
I have never worked with vector on gmod and i'm totally blocked. How can i make an simple cube arena who show on my screen ?
Thanks you in advance.
This is the easy way if you can't do simple vector logic:
[url]http://wiki.garrysmod.com/page/Vector/WithinAABox[/url]
Keep in mind that the first vector must have all the minimal values you want to check and second all the largest values of a vector. ( Or just see second example )
Thanks you,i love you.
[editline]12th May 2016[/editline]
I have another problem,i wrote an small code :
[code]
concommand.Add( "voirvector", function(ply)
local PlayerPos = ply:GetPos()
print(PlayerPos)
print(PlayerPos:WithinAABox( Vector(7078, -7154, 0),Vector(7663,-7663, 96)))
end )
[/code]
When i launch the command on the middle of my spawn area it print me this :
7517.074707 -7522.984863 0.031250
false
ply:GetPos() return an vector value who are in the box but PlayerPos:WithinAABox still return me false.
[QUOTE=Robotboy655;50302922][b]Keep in mind that the first vector must have all the minimal values you want to check [/b]and second all the largest values of a vector. ( Or just see second example )[/QUOTE]
[QUOTE=Robotboy655;50303167][/QUOTE]
So i have to invert the two previous vector ? Like that ?
print(PlayerPos:WithinAABox(Vector(7663,-7663, 96),Vector(7078, -7154, 0)))
because it still print me false
[QUOTE=Marbella;50303195]So i have to invert the two previous vector ? Like that ?
print(PlayerPos:WithinAABox(Vector(7663,-7663, 96),Vector(7078, -7154, 0)))
because it still print me false[/QUOTE]
Yeah, I got confused with WithinAABox as well. The first vector argument needs to be smaller IN ALL OF ITS VALUES than the second one. So x1 < x2 y1 < y2 z1 < z2 etc.
-7154 > -7663
There is a function that helps you with this. [URL="http://wiki.garrysmod.com/page/Global/OrderVectors"]http://wiki.garrysmod.com/page/Global/OrderVectors[/URL]
[QUOTE=NeatNit;50303367]-7154 > -7663[/QUOTE]
Yeah but my getpos always return an value who are > -7663
[editline]12th May 2016[/editline]
I finally done it,thanks google !
[code]
local vCenter = Vector( 7517, -7507, 0) //center of the box
local boxSize = Vector(150,170,95)
local corner1 = vCenter-Vector(boxSize.x,boxSize.y, 0)
local corner2 = vCenter+boxSize
local telePos = Vector()
concommand.Add("testpos",function(ply)
print(ply:GetPos():WithinAABox(corner1,corner2))
end)
hook.Add("PostDrawOpaqueRenderables", "PDOR.TeleBoxDebug", function()
render.DrawWireframeBox(vCenter, Angle(), -Vector(boxSize.x,boxSize.y, 0), boxSize, Color(0,0,255), true)
end)
[/code]
Sorry, you need to Log In to post a reply to this thread.