• Player position/vector problems
    8 replies, posted
So basically I'm trying to do a Vector:WithinAABox kind of thing, where if the player's position is within these vectors, and the player press +use, he will be teleported somewhere, but the WithinAABox doesn't seem to work, but I'm just not using it right. [url]http://pastebin.com/9QFfcUyy[/url] Here's my whole code, the vector withinaabox code starts at line 110. PS: Please don't hate for the NWInt stuff. I plan on changing that eventually
Have you tried to print the player position and manually checking if it is in the box?
[QUOTE=Robotboy655;44843481]Have you tried to print the player position and manually checking if it is in the box?[/QUOTE] Relatively off-topic and on-topic, but I would if I wasn't administrating 46x 12 years old -_-
[QUOTE=Captain Spark;44843873]Relatively off-topic and on-topic, but I would if I wasn't administrating 46x 14 years old -_-[/QUOTE] I don't need your excuses, if you didn't, do.
[QUOTE=Robotboy655;44843970]I don't need your excuses, if you didn't, do.[/QUOTE] Just did, returns false.
[QUOTE=Robotboy655;44843481]Have you tried to [B]print the player position and [U][I]manually [/I][/U]checking if it is in the box?[/B][/QUOTE]
[QUOTE=Robotboy655;44843998][/QUOTE] You mean like this? [CODE]print(ply:GetPos()) if Vector(-1870.657471,-392.884827,-4863.968750):WithinAABox(Vector(-1903.97,-384.00,-4799.97),Vector(-1849.11,-386.03,-4799.97)) then ply:SetPos(Vector(-2028.63,-476.51,-4774.08)) end[/CODE]
[lua] local vCenter = Vector(825.862244, -121.231918, -143.968750) //center of the box local boxSize = Vector(50,50,90) local corner1 = vCenter-Vector(boxSize.x,boxSize.y, 0) local corner2 = vCenter+boxSize local telePos = Vector() if SERVER then AddCSLuaFile() hook.Add("KeyPress", "KeyPress.TeleportBox", function(ply, key) if (key == IN_USE) and ply:GetPos():WithinAABox(corner1, corner2) then ply:SetPos(telePos) end end) else hook.Add("PostDrawOpaqueRenderables", "PDOR.TeleBoxDebug", function() render.DrawWireframeBox(vCenter, Angle(), -Vector(boxSize.x,boxSize.y, 0), boxSize, Color(0,0,255), true) end) end [/lua]
[QUOTE=brandonj4;44845366] code [/QUOTE] thanks alot, for like the 10th time
Sorry, you need to Log In to post a reply to this thread.