run client command on specific map startup?

Hey, I’ve got a small issue that I believe can be alleviated using lua, and as I haven’t the expertise I would appreciate some help for a small script. I have a map that has the unit extents of 31744x31744, and as source’s default r_farz value is about 30k, I need to increase that when the map starts up so as to remove any back-clipping plane visible when looking diagonally across it.
I’ve tried doing it through the map itself using a point_clientcommand triggered by a logic_auto, but that doesn’t seem to work for garry’smod. Basically, all I’d like is a script that runs “r_farz 50000” when this particular map starts up.
I hope making a thread for this is okay, as the “hire a coder” thread didn’t seem appropriate for something this small.
Any help would be greatly appreciated.

Isn’t r_farz a cheat command? You’d need to use the farZ part of CalcView

if SERVER and game.GetMap( ) == "gm_flatgrass" then
  AddCSLuaFile( )
  local function CalcView( pl, pos, ang, fov, near, far )
    return { farZ = 50000 }

  hook.Add( "CalcView", "SpecialMap.FixFarZ", CalcView )

If it isn’t, then something like

if SERVER and game.GetMap( ) == "gm_flatgrass" then
  AddCSLuaFile( )
  local function Initialize(  )
    RunConsoleCommand( "r_farz", 50000 )

  hook.Add( "Initialize", "SpecialMap.FixFarZ", Initialize )

Should give you the right direction - this hasn’t been tested.

[lua]hook.Add(“Initialize”, “rfartz”, function() if game.GetMap() == “yourmapnamewithouthbsp” then RunConsoleCommand(“r_farz”, 50000) end end)[/lua]
something like this, dunno if maybe r_farz is blocked. ALL PESUDOCODEEEE.

edit:// Kogitsune did got an Valid point with the sv_cheat thing. i don’t know the command. so use his version insteed.

[lua] if game.GetMap() == “mapname” then RunConsoleCommand( “disconnect” ) end [/lua] sorry if its not good I’m on phone

For future reference, it isn’t a cheat command, so you can run it any time. Thank you very much for your help!

[editline]10th October 2014[/editline]

Your script worked flawlessly. Again, thank you.

This topic is solved, and can be closed now.

[editline]26th November 2014[/editline]

November edit:

For anybody who might somehow have stumbled across this topic, r_farz actually is considered a cheat command in multiplayer. Instead refer to the calcview script.