Getting Entity Pos
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?
entity:GetPos() will return a vector of the position http://wiki.garrysmod.com/page/Entity/GetPos
Ooooh, you want a console command that gets an ents position?
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
should work, put this in a client lua file in autorun and look at an entity and type entitypos in console
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.
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 consoleDid this however running the command still says unknown command rip XD
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
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
Hahaha, that last bit was a little messy XD Well, glad it's all resolved <3
end )
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
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: .....
It's all good guys running Entity:GetPos through ulx rcon works great :)