Is it possible to turn the result of a console command into a string?

For an addon I am making, I am trying to get info from the ‘status’ command that isn’t otherwise accessible by a function or a GetConVarString.

How can I turn the result of the command into a string?

First you need a c module.

[editline]19th July 2015[/editline]

Surely there are better ways to get “status” info than using the status command and ripping the output.

Turns out there isn’t. I am just trying to get the server host IP and Port. Which GetConVarString(“hostip”) and GetConVarString(“hostport”) dont do very well for some reason.

[lua]function game.GetIP()

local hostip = GetConVarString( "hostip" ) -- GetConVarNumber is inaccurate
hostip = tonumber( hostip )

local ip = {}
ip[ 1 ] = bit.rshift( bit.band( hostip, 0xFF000000 ), 24 )
ip[ 2 ] = bit.rshift( bit.band( hostip, 0x00FF0000 ), 16 )
ip[ 3 ] = bit.rshift( bit.band( hostip, 0x0000FF00 ), 8 )
ip[ 4 ] = bit.band( hostip, 0x000000FF )

return table.concat( ip, "." )

end[/lua]

Use that there to get a server IP.

GetConVarString( “hostport” ) Works fine.

I tried using the GetConVarString(“hostport”) but on some servers I tested it on reported they it just brought back ‘27015’ when the port was something else (yet sometimes it DOES give the custom port, weird).