• Turning off net_graph while taking camera?
    46 replies, posted
[code]if SERVER then AddCSLuaFile( "path/to/this/file.lua") else numRun = 0 firstval = GetConVar("net_graph") timer.Create("Switch" , 1 , 0 , function() if LocalPlayer():GetActiveWeapon() then Wep = LocalPlayer():GetActiveWeapon() lastval = GetConVar("net_graph") if Wep == "gmod_camera" then RunConsoleCommand("net_graph" , 0) elseif numRun > 0 then RunConsoleCommand("net_graph" , lastval) else RunConsoleCommand("net_graph" , firstval) end numRun = numRun + 1 end end ) end[/code] Try that.
[QUOTE=|FlapJack|;16923559][code]if SERVER then AddCSLuaFile( "path/to/this/file.lua") else numRun = 0 firstval = GetConVar("net_graph") timer.Create("Switch" , 1 , 0 , function() if LocalPlayer():GetActiveWeapon() then Wep = LocalPlayer():GetActiveWeapon() lastval = GetConVar("net_graph") if Wep == "gmod_camera" then RunConsoleCommand("net_graph" , 0) elseif numRun > 0 then RunConsoleCommand("net_graph" , lastval) else RunConsoleCommand("net_graph" , firstval) end numRun = numRun + 1 end end ) end[/code] Try that.[/QUOTE] It doesn't work at all, even the net_graph doesn't disappear.
[lua]if ( SERVER ) then AddCSLuaFile( "NameOfFile.lua" ) else local netvar = GetConVar( "net_graph" ):GetInt( ) hook.Add( "Think", "antinetgraph", function( ) if ( ValidEntity( LocalPlayer( ):GetActiveWeapon( ) ) ) then curwep = LocalPlayer( ):GetActiveWeapon( ):GetClass( ) if ( lastwep != curwep ) then if ( curwep == "gmod_camera" ) then netvar = GetConVar( "net_graph" ):GetInt( ) RunConsoleCommand( "net_graph", "0" ) else RunConsoleCommand( "net_graph", tostring( netvar ) ) end lastwep = curwep end end end ) end[/lua] Try that.
[QUOTE=Overv;16924926][lua]if ( SERVER ) then AddCSLuaFile( "NameOfFile.lua" ) else local netvar = GetConVar( "net_graph" ):GetInt( ) hook.Add( "Think", "antinetgraph", function( ) if ( ValidEntity( LocalPlayer( ):GetActiveWeapon( ) ) ) then curwep = LocalPlayer( ):GetActiveWeapon( ):GetClass( ) if ( lastwep != curwep ) then if ( curwep == "gmod_camera" ) then netvar = GetConVar( "net_graph" ):GetInt( ) RunConsoleCommand( "net_graph", "0" ) else RunConsoleCommand( "net_graph", tostring( netvar ) ) end lastwep = curwep end end end ) end[/lua] Try that.[/QUOTE] Thanks, it works!
Hopefully final word/script to this problem: [LUA] local Camera = nil local NAME = "gmod_camera" for _,v in pairs(weapons.GetList()) do if v.Classname == NAME then Camera = v end end print(!Camera and"Failed h"or"H".."acking camera") if !Camera then return end local graph = nil local Deployed = false local VAR = "net_graph" Camera.OldHolster = Camera.Holster or function() end function Camera:Holster(wep) if Deployed then Deployed = false RunConsoleCommand( VAR,tostring(graph)) end self:OldHolster(wep) end Camera.OldDeploy = Camera.Deploy or function() end function Camera:Deploy(wep) if !Deployed then Deployed = true graph = GetConVar( VAR ):GetInt() RunConsoleCommand( VAR,"0") end self:OldDeploy(wep) end for _,ent in ipairs(ents.GetAll()) do if ent and ent:IsValid() and ent:GetClass() == NAME then local table = ent:GetTable() for k,v in pairs(Camera) do table[k] = v end end end [/LUA] Download a slightly more enhanced version and in addon format for clients and.. servers: [url=http://www.garrysmod.org/downloads/?a=view&id=77486][img]http://www.garrysmod.org/img/?t=dll&id=77486[/img][/url]
[QUOTE=Python1320;16942520]Hopefully final word/script to this problem: [LUA] local Camera = nil local NAME = "gmod_camera" for _,v in pairs(weapons.GetList()) do if v.Classname == NAME then Camera = v end end print(!Camera and"Failed h"or"H".."acking camera") if !Camera then return end local graph = nil local Deployed = false local VAR = "net_graph" Camera.OldHolster = Camera.Holster or function() end function Camera:Holster(wep) if Deployed then Deployed = false RunConsoleCommand( VAR,tostring(graph)) end self:OldHolster(wep) end Camera.OldDeploy = Camera.Deploy or function() end function Camera:Deploy(wep) if !Deployed then Deployed = true graph = GetConVar( VAR ):GetInt() RunConsoleCommand( VAR,"0") end self:OldDeploy(wep) end for _,ent in ipairs(ents.GetAll()) do if ent and ent:IsValid() and ent:GetClass() == NAME then local table = ent:GetTable() for k,v in pairs(Camera) do table[k] = v end end end [/LUA] Download a slightly more enhanced version and in addon format for clients and.. servers: [url=http://www.garrysmod.org/downloads/?a=view&id=77272][img]http://www.garrysmod.org/img/?t=dll&id=77272[/img][/url][/QUOTE] Thanks but, what was wrong in the previous version?
Because they THINK.
His is much more stress-free.
Crap. I'm sorry, you must think : " Oh please gtfo with your camera! ", but it doesn't work. The last script I have installed, the addon format one, says this to me when I spawn : [LUA]Hook 'GCamera' Failed: autorun/gcamera.lua:65: attempt to index local 'table' (a nil value)[/LUA] And it doesn't work.
I didn't test it, I wanted to assume it worked. Found major stupid mistakes. Just copypaste my above script and put it to lua folder and then just write lua_openscript_cl <filename.lua> in console. That should do it until I get time to fix this.
You should just use ers35's script. It doesn't run 60 console commands a second and actually works.
[QUOTE=Salads;16982976]You should just use ers35's script. It doesn't run 60 console commands a second and actually works.[/QUOTE] Yeah, but it will bring the net_graph even if people didn't have it.
New try: [url=http://www.garrysmod.org/downloads/?a=view&id=77486][img]http://www.garrysmod.org/img/?t=dll&id=77486[/img][/url] This time it should work but you can't dynamically load it. Also, this time I tested it :)
[url=http://www.facepunch.com/showpost.php?p=16613132&postcount=10]I don't understand why people don't use my version.[/url] It doesn't bug and includes all the features you need. It only toggles the graph if the player had enabled it in the beginning, it doesn't check if the player has the camera out every frame, it only toggles the command ONCE. And to break the ice the whole scripts looks clean and includes comments that explain everything it does nicely.
Feel free to try my version. It doesn't think every frame either. It will even hide developer view if enabled. And now it shouldn't bug anymore, feel free to tell if it does. Mine is also fully clientside and works on almost any server with no SE. I wanted to make a screenshot feature where it turns off net_graph and hud and takes a screenshot so no camera is required, but I couldn't be bothered to do this for now. Just throwing ideas. Only problem with my script that I am aware of is that if you pull out camera and change net_graph value and holster camera it will revert to the settings you had when you turned on the camera aka nothing major.
This gotta be the problem with the most solutions ever.
Sorry, you need to Log In to post a reply to this thread.