Pivity

Getting Entity Pos

Last read Never
#1

Hey guys, i've scrawled everywhere, however can't find a simple solution, so i'm now hoping for help from Gmodstore, How in the heck do i find out an entity / props pos?

#2

entity:GetPos() will return a vector of the position http://wiki.garrysmod.com/page/Entity/GetPos

Friendly x 1
#3
ByOwainat 3rd of February 2018 21:49:59
entity:GetPos()will return a vector of the positionhttp://wiki.garrysmod.com/page/Entity/GetPos

Doesn't work mate, say's unknown command :/

Friendly x 1
#4

Ooooh, you want a console command that gets an ents position?

Agree x 1
#5

Preferably yeah :) , if not i can run it on a server, how would I do that with the command you gave? My bad for any noobiness

Friendly x 1
#6
concommand.Add("entitypos", function()
local ent = LocalPlayer():GetEyeTrace().Entity
if(IsValid(ent)) print(ent:GetPos()) end
end)

should work, put this in a client lua file in autorun and look at an entity and type entitypos in console

Winner x 2Agree x 1Disagree x 1
#7

Depends how you'd want to do it. You'd need to run Lua code that would create the command. So you'd need access to the server so you can upload files, or the server would need to allow custom client Lua. Would you want maybe a command that lists all entities and their positions in console, or a maybe a command that gives you the position of the entity you're looking at? It all depends on how you wanna do it.

#8
ByThreebowat 3rd of February 2018 21:55:43
concommand.Add("entitypos", function() local ent = LocalPlayer():GetEyeTrace().Entity if(IsValid(ent)) print(ent:GetPos()) end end)should work, put this in a client lua file in autorun and look at an entity and typeentityposin console

Did this however running the command still says unknown command rip XD

Friendly x 1
#9

Have you restarted your server? May seem like a stupid quest, but tickets have taught me that things like that happen way too often XD

#10

I'm still tryna run it in singleplayer lmao

Edited Brainwave, basically i was tryna avoid doing it on my server, but i just thought i'd put it on the map i want to modify with props and put it onto sandbox mode, the gm i run restricts all props, so i'll give it ago now, cheers guys will report back :)

Edited Yeah still says Unknown command

Edited So just to check, i've created a new .lua file in this directory (tried both client and server) am i doing this correct? ( i feel like such a pleb rn) https://gyazo.com/ecc6956a3736aa13e96fe2c86371f62b

Edited Resolved. I just ran Entity:GetPos through as a rcon command, thanks for the support guys! /CloseThread

Funny x 1
#11

Hahaha, that last bit was a little messy XD Well, glad it's all resolved <3

Agree x 1Friendly x 1
#12
ByOwainat 4th of February 2018 00:09:58
Hahaha, that last bit was a little messy XD Well, glad it's all resolved <3

I think it was just me derping haha

Friendly x 2
#13
ByThreebowat 3rd of February 2018 21:55:43

you forgot 'then', it would be

concommand.Add("entitypos", function()
local ent = LocalPlayer():GetEyeTrace().Entity
if(IsValid(ent)) then print(ent:GetPos()) end

end)

Agree x 1Friendly x 1
#14
concommand.Add( "entity_position", function( ply )
local trace = ply:GetEyeTrace()
if ( IsValid( trace.Entity ) ) then
print( "Entity position:", trace.Entity:GetPos() )
else
print( "Crosshair position:", trace.HitPos )
end

end )

Dumb x 1
#15
By#Attacheat 4th of February 2018 11:27:52
you forgot 'then', it would beconcommand.Add("entitypos", function() local ent = LocalPlayer():GetEyeTrace().Entity if(IsValid(ent)) then print(ent:GetPos()) end end)

yeah too much javascript lol

Edited

ByObitusat 4th of February 2018 17:27:32

concommand.Add( "entity_position", function( ply ) local trace = ply:GetEyeTrace() if ( IsValid( trace.Entity ) ) then print( "Entity position:", trace.Entity:GetPos() ) else print( "Crosshair position:", trace.HitPos ) end end )i already answered this above, fam

Friendly x 2Funny x 1Dumb x 1
#16
ByThreebowat 4th of February 2018 18:30:19
yeah too much javascript lolEditedi already answered this above, fam

Why so rude? Just helping out and making it better (In my opinion)

@Behnzon The code I have is printing this if looking at an entity: Entity Position: .....

And if it is not pointed at an entity it lets you know and prints this: Crosshair Position: .....

Dumb x 3Friendly x 1
#17

It's all good guys running Entity:GetPos through ulx rcon works great :)

Agree x 2Winner x 1
Users viewing this thread
Nobody