• Execute console commands which are considered cheats in multiplayer on map spawn
    11 replies, posted
Hey, so I'm having issues executing certain commands on a multiplayer server because they're considered cheats for some reason. I have a lua file with these commands in my lua/autorun folder, which works fine if I play on my map in singleplayer: RunConsoleCommand( "cl_windspeed", "75" ) RunConsoleCommand( "cl_tree_sway_dir", "8", "8" ) RunConsoleCommand( "r_rainlength", "0.009" ) RunConsoleCommand( "r_rainwidth", "1" ) RunConsoleCommand( "r_rainalpha", "1" ) RunConsoleCommand( "r_rainsidevel", "350" ) RunConsoleCommand( "r_rainradius", "2100" ) RunConsoleCommand( "r_rainspeed", "1200f" ) RunConsoleCommand( "r_rainalphapow", "1" ) I tried adding those commands into my autoexec.cfg, then server.cfg, and then packing them into the .bsp but they doesn't seem to have any effect. Is there a way to have sv_cheats enabled for a split second while those commands are being executed, then being turned back off by a lua file, a way to allow clients to use those commands, or just bypass the sv_cheats check? I tried adding sv_cheats to the above file as well but console says the command is blocked so that didn't work either. I have no lua knowledge so that's as far as I can go
AddCSLuaFile( ) if CLIENT then hook.Add( "Initialize", "Fishke_Execute_Console_Commands", function( ) RunConsoleCommand( "cl_windspeed", "75" ) RunConsoleCommand( "cl_tree_sway_dir", "8", "8" ) RunConsoleCommand( "r_rainlength", "0.009" ) RunConsoleCommand( "r_rainwidth", "1" ) RunConsoleCommand( "r_rainalpha", "1" ) RunConsoleCommand( "r_rainsidevel", "350" ) RunConsoleCommand( "r_rainradius", "2100" ) RunConsoleCommand( "r_rainspeed", "1200f" ) RunConsoleCommand( "r_rainalphapow", "1" ) end ) end Try putting that into an script in the gmod lua autorun folder. what its doing is, since anything in autorun is ran on both client and server, we only care about the client right now, we add a hook onto the GM:Initialize hook and run all the console command functions. GM:Initialize is run once while the gamemode is loading
I tried replacing the file with yours but the commands still had their default values set when I checked the console
oh im dumb i didnt read that they were considered cheats. its a little difficult to get the behavior you want since if the map is on a server then it would need to switch svcheats every time someone joined, unless that isnt really a problem?
I was thinking if there was an alternative to server.cfg because whatever I put in there doesn't work as if GMod doesn't even read it at all. The commands would only be executed once as soon as the server loads the map and afterwards whoever joins the server/map will automatically receive those settings, as it would be very convenient if the map had an embedded lua file in the bsp file that automatically set those commands for you and server hosters wouldn't need to bother setting additional commands anywhere. Pity that point_servercommand in Hammer doesn't work in GMod. I did some digging around before and came across this page: FCVAR Enumerations I have no idea how those work at all but maybe if there was a way to change it so those above commands aren't flagged as FCVAR_CHEAT, or if there was a way to replace that flag with FCVAR_CLIENTCMD_CAN_EXECUTE so clients could use those commands without having sv_cheats enabled
You can't change cvars that require sv_cheats without a binary module or enabling sv_cheats.
If you want a cvar that was set on the server to also be set on a client that joins then the cvar must have the FCVAR_REPLICATED flag set which it looks like none of the ones you want set have or even exist on the server. I don't think you can override existing cvars flags but I will do some testing with them.
So I take it there isn't a way to run/force those commands server side using lua? Everything I've tried and managed to get working lua-code wise just ends up in console reporting the command is blocked or simply doing nothing.
This isn't very smart to do but if you can't find any other option I think you would be able to do AddCSLuaFile() if (SERVER) then RunConsoleCommand( "sv_cheats", "1" ) end if (CLIENT) then RunConsoleCommand( "cl_windspeed", "75" ) RunConsoleCommand( "cl_tree_sway_dir", "8", "8" ) RunConsoleCommand( "r_rainlength", "0.009" ) RunConsoleCommand( "r_rainwidth", "1" ) RunConsoleCommand( "r_rainalpha", "1" ) RunConsoleCommand( "r_rainsidevel", "350" ) RunConsoleCommand( "r_rainradius", "2100" ) RunConsoleCommand( "r_rainspeed", "1200f" ) RunConsoleCommand( "r_rainalphapow", "1" ) end if (SERVER) then RunConsoleCommand("sv_cheats", "0") end
sv_cheats is a blacklisted command to RunConsoleCommand. If you can install modules, you can use cvar3 to remove FCVAR_CHEAT from the concommands you want to change.
Oh ok, good to know!
Looks like I have to find a workaround. Thanks for the help everyone
Sorry, you need to Log In to post a reply to this thread.