Forcing command on join

Is there anyway for me to force a console command on my clients as they join my server?
(no malicious intent involved)

If you would like to make a hardcore script, then yes. but if you don’t then no.

Download eventscripts.

Go to Gmod/Addons/Eventscripts, making a new folder called “ForceCommand”
Make a .txt file in there called ForceCommand.txt

event player_connect
    es_cexec event_var(userid) <commands to run>

Add es_load ForceCommand to the autoexec.cfg


or you can make a lua file in the autorun/server and just do this.

function GM:PlayerInitialSpawn(ply)

Replace kill with the command


function GM:PlayerInitialSpawn(ply)


Use them instead of SendLua.


Because they’re supposed to be better than SendLua?

‘Supposed’ to be better, it really doesn’t matter which one is used, however, in this situation SendLua is preferred because it is easier to use and requires less coding.

I agree, it requires less coding. But, I’d still go with usermessages as they’re more effecient than SendLua. But you’re right, in this situation with a newbie - it isnt really required.

SendLua	0.029998779296875
Usermessage	0.029998779296875

Those are the times it took each to send a simple command to the client, as you can see, they are the same. Using a usermessage in this situation or a similar situation with a newbie or without is never required.

What if the client doesn’t download lua from the server?

Ontop of that, you would need to have a clientside file to hook into the usermessage. In this case, SendLua is definately better.

Then the client deserves to not have full benefits within the server. It was his choice to not download them.

Obviously they’re the same since you’re sending packets to your own computer. SendLua has to send ‘RunConsoleCommand(“kill”)’ whereas the usermessage would be something like “RunKill” or “ConRun” and “kill”.

What if the client doesn’t connect to the server? :OOO

I hate it when my gamemode goes “Hey if you edit cl_init.lua I remove myself from your harddrive.”

I didn’t say that i sent them to myself.

Well if the delay is exactly the same I doubt that you sent them over the Internet.

Sandbox deletes any changes you make to it on restart.


Then you need to use the gm_getgamedescription module (If thats it’s name)