• Make So when someone joins a Console command is run on them
    24 replies, posted
Hey Guys So lately i started a gmod server and i got a special addon but its enabled as default which i dont want so theres a console toggle command but how do i do so whenever someone joins (doesent matter if they have been on before or not) the server runs a console command on them
Make a clientside script that calls RunConsoleCommand when they spawn in
[QUOTE=Zortex;50236085]Hey Guys So lately i started a gmod server and i got a special addon but its enabled as default which i dont want so theres a console toggle command but how do i do so whenever someone joins (doesent matter if they have been on before or not) the server runs a console command on them[/QUOTE] If it's a convar search the addon directory for CreateConVar and change the value to what you want it to be, rather than relying on calling RunConsoleCommand.
Okay Thanks Guys [editline]1st May 2016[/editline] Just one problem, Its in a .gma file and idk what one of them it is cause i got lots of them (still server) and i dont wanna extract them all with gmad (i actully do but it takes too long as i only can extract 1 at the time)
You don't need to extract anything if you know what console command you need to run
Yea But Just another Question does anyone know anything like gmad that can extract multiple gmas
[QUOTE] hook.Add("PlayerSpawn", "SpawnAndCon", function() RunConsoleCommand("") end) [/QUOTE]
[QUOTE=Appledevdude;50242323][/QUOTE] I think he means a client console command... in which case it would be: [CODE] -- server-side hook.Add( "PlayerAuthed", "RunCommand", function( ply ) net.Start( "RunConsoleCommand" ) net.Send( ply ) end ) -- client-side net.Receive( "RunConsoleCommand", function() RunConsoleCommand( string command, vararg arguments ) -- however I don't think this can be used to make them connect to a different server, however one of the other functions can. Was trying to find which one it was to verify but can't find it in my code now! end ) [/CODE]
[QUOTE=Zortex;50236281]Yea But Just another Question does anyone know anything like gmad that can extract multiple gmas[/QUOTE] Right click a .gma file, select Open With... and then browse to gmad.exe and set it as default. Now every time you double click a .gma, it will instantly extract it. Not multiple at once, but practically as fast and easy.
[QUOTE=Semajnad;50242343]I think he means a client console command... in which case it would be: [CODE] -- server-side hook.Add( "PlayerAuthed", "RunCommand", function( ply ) net.Start( "RunConsoleCommand" ) net.Send( ply ) end ) -- client-side net.Receive( "RunConsoleCommand", function() RunConsoleCommand( string command, vararg arguments ) -- however I don't think this can be used to make them connect to a different server, however one of the other functions can. Was trying to find which one it was to verify but can't find it in my code now! end ) [/CODE][/QUOTE] Even easier: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/ConCommand]Player:ConCommand[/url]
[QUOTE=Zet0r;50242361]Right click a .gma file, select Open With... and then browse to gmad.exe and set it as default. Now every time you double click a .gma, it will instantly extract it. Not multiple at once, but practically as fast and easy.[/QUOTE] after this highlight all the gma's you want to extract and hit enter
[QUOTE=NeatNit;50242466]Even easier: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/ConCommand]Player:ConCommand[/url][/QUOTE] Nice, didn't know that could be run server-side. Well ye, but I'm not sure which one is needed to make a player use the connect command. Depends on what it's needed for.
[QUOTE=NeatNit;50242466]Even easier: [img]http://wiki.garrysmod.com/favicon.ico[/img] [url=http://wiki.garrysmod.com/page/Player/ConCommand]Player:ConCommand[/url][/QUOTE] Thank You For this [editline]5th May 2016[/editline] Okay so i realised that the thing with gmad yes thanks but the gmas i had in my addons folder wasent the ones i meant to use cause i used workshop content download so when i started server first time it downloaded alota addons where did they go?
Same place, but in the server's directory
ik please ignore my last post [editline]6th May 2016[/editline] [QUOTE=Semajnad;50242343]I think he means a client console command... in which case it would be: [CODE] -- server-side hook.Add( "PlayerAuthed", "RunCommand", function( ply ) net.Start( "RunConsoleCommand" ) net.Send( ply ) end ) -- client-side net.Receive( "RunConsoleCommand", function() RunConsoleCommand( string command, vararg arguments ) -- however I don't think this can be used to make them connect to a different server, however one of the other functions can. Was trying to find which one it was to verify but can't find it in my code now! end ) [/CODE][/QUOTE] Hey so Where do i place this im new to lua i would guess this would be in just the lua > autorun Directory? Cause this uses both serverside and clientside or would i create 2 lua files that go in client and server Directorys`?
You could put it in lua/autorun, but if you did that, you'd have to put [CODE] if CLIENT then -- code end -- and if SERVER then -- code end [/CODE] Around the appropriate code, or you could just create 2 separate lua files, it doesn't really make a difference
Okay Thanks that was what i thought [editline]6th May 2016[/editline] so this would work? [code] if CLIENT then net.Receive( "RunConsoleCommand", function() RunConsoleCommand( string VNT_CloneHUD_FX, vararg 0 ) RunConsoleCommand( string VNT_CloneHUD_Toggle, vararg 0 ) end ) end if SERVER then hook.Add( "PlayerAuthed", "RunCommand", function( ply ) net.Start( "RunConsoleCommand" ) net.Send( ply ) end ) end [/code]
[QUOTE=Zortex;50267573]Okay Thanks that was what i thought [editline]6th May 2016[/editline] so this would work? [code] if CLIENT then net.Receive( "RunConsoleCommand", function() RunConsoleCommand( string VNT_CloneHUD_FX, vararg 0 ) RunConsoleCommand( string VNT_CloneHUD_Toggle, vararg 0 ) end ) end if SERVER then hook.Add( "PlayerAuthed", "RunCommand", function( ply ) net.Start( "RunConsoleCommand" ) net.Send( ply ) end ) end [/code][/QUOTE] You are specifying data types when calling RunConsoleCommand. Don't.
How Would i then do it I litterly almost know nothing about lua thats why im asking for help
[QUOTE=Zortex;50267624]How Would i then do it I litterly almost know nothing about lua thats why im asking for help[/QUOTE] Remove the data types when calling the method. I am a bit concerned about you doing networking without understanding what you are doing, the net library can easily be abused if you are not careful, mostly when sending stuff to the server but if you do not know what vulnerable code looks like you are more prone to write it.
[QUOTE=Hoffa1337;50267636]Remove the data types when calling the method. I am a bit concerned about you doing networking without understanding what you are doing, the net library can easily be abused if you are not careful, mostly when sending stuff to the server but if you do not know what vulnerable code looks like you are more prone to write it.[/QUOTE] He doesn't need the net library.. You need to understand that clientside lua is loaded as soon as they load in to the server. He doesn't need to network anything.
[QUOTE=tyguy;50267670]He doesn't need the net library.. You need to understand that clientside lua is loaded as soon as they load in to the server. He doesn't need to network anything.[/QUOTE] You are missing the point, the provided solution he tried to run was using the net library, thus he was willing to execute that code on his server. Now imagine he expands on the code by copy pasting new functionality but without understanding what it's doing he might introduce vulnerabilities. You can feel free to spoonfeed him a solution if that makes you happy, but I would recommend trying to understand what's going on code-wise before taking it further.
[QUOTE=Hoffa1337;50267722]You are missing the point, the provided solution he tried to run was using the net library, thus he was willing to execute that code on his server. Now imagine he expands on the code by copy pasting new functionality but without understanding what it's doing he might introduce vulnerabilities. You can feel free to spoonfeed him a solution if that makes you happy, but I would recommend trying to understand what's going on code-wise before taking it further.[/QUOTE] alright fair enough @OP: you can just do something like: [lua] timer.Simple(0.6, function() RunConsoleCommand("put command here", 0) end ) [/lua] you should put that in cl_init.lua of your gamemode
[QUOTE=tyguy;50267735]alright fair enough @OP: you can just do something like: [lua] timer.Simple(0.6, function() RunConsoleCommand("put command here", 0) end ) [/lua] you should put that in cl_init.lua of your gamemode[/QUOTE] Thanks for Helping it works now
[QUOTE=Zortex;50267787]Thanks for Helping it works now[/QUOTE] no problem :) enjoy
Sorry, you need to Log In to post a reply to this thread.