Print GMOD Map Coordinates to Chat?

Hello!
I am recently playing a lot of SWRP. The Server where I am playing uses coordinates and it’s bloody annoying to copy and paste them. Until then, you already got overrun.
I would know if there is a possibility to make a Script which does the following:
When I type in something in console (like f.ex showcoordinates just as example), it prints the message. I could also connect it to commands (Like /advert).
I have no experience in scripts, so I would appreciate any help.
Cheers!

Yes, it’s not that hard, due you have 0 idea about coding, www.scriptfodder.com is your best option

Ah rip, I thought it was a simple script. Yeah, gonna check the place out, if no one knows an solution then I’ll request a Job.

lua_run_cl pos = self:GetPos() Ppos = tostring(pos) RunConsoleCommand(“say”,Ppos)

Shouldn’t this just do the job?


concommand.Add( "printcoords", function( ply, cmd, args )
	print( LocalPlayer():GetPos() )
end )

?

or



bind X "lua_run_cl print(LocalPlayer():GetPos())"




bind X "lua_run_cl print(LocalPlayer():GetPos()); SetClipboardText(LocalPlayer():GetPos())"


Can we not do this everytime someone makes a thread like this? He is asking for help on something very simple.

Toedeli, I don’t know if you mean that the coordinates are printed on the screen or something, but if they are, there is already a console command which is getpos. I believe it gives you the coordinates and angles but you can just copy the coordinates. You can try out Flixs console command and see if that works.

Alright, as I have no idea with LUA (Kinda embarrasing to ask)
Do I have to put it in the LUA Folder?

The second 2 I posted are literally just in-game binds you should be able to do through the console.

lua code can be put in a .lua file in IIRC “GarrysMod\garrysmod\lua\autorun\client” and it should run.

Bearing in mind the server you are playing on needs to allow clientside lua for any of this to work.

No, you could type this in the console




bind k "lua_run_cl pos = self:GetPos() Ppos = tostring(pos) RunConsoleCommand('say',Ppos)"



Everytime you press “k” your coordinates will be printed

if you dont want that anymore just type



unbind k


Thanks a lot guys, currently busy so unable to Play GMOD, thanks all for your help!
And @Cushie does your addon have to be added as .lua file into the LUA Folder?

self wont work in this context iirc. LocalPlayer() instead.

The 1st lua code needs to be in a file to create the command in the location I said above, the 2nd two can just be pasted in the console in-game and will create the command that way. You only need 1 of the 3 methods (The 3rd prints as well as copies to clipboard)

Like I said though the server you play on needs to have clinetisde lua enabled or none of it will work.

It does, I’ve tried it on my server.



function SWEP:DrawHUD()
	surface.SetFont( "CloseCaption_Bold" )
	surface.SetTextColor( 255, 255, 255, 255 )
	surface.SetTextPos( 0, 0 )
	surface.DrawText( tostring(LocalPlayer():GetPos()) )
end

mate