• Forcing command on join
    19 replies, posted
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 Insert [code] event player_connect { es_cexec event_var(userid) <commands to run> }[/code] Add es_load ForceCommand to the autoexec.cfg Restart nom
or you can make a lua file in the autorun/server and just do this. [code] function GM:PlayerInitialSpawn(ply) ply:ConCommand("kill") end [/code] Replace kill with the command
[QUOTE=stinkfire;16789117]or you can make a lua file in the autorun/server and just do this. [code] function GM:PlayerInitialSpawn(ply) ply:ConCommand("kill") end [/code] Replace kill with the command[/QUOTE] No [code] function GM:PlayerInitialSpawn(ply) ply:SendLua([[RunConsoleCommand("kill")]]) end [/code]
Userrrmessaaggeeesss Use them instead of SendLua.
[QUOTE=Horsey;16792902]Userrrmessaaggeeesss Use them instead of SendLua.[/QUOTE] Why?
Because they're supposed to be better than SendLua?
[QUOTE=Horsey;16792958]Because they're supposed to be better than SendLua?[/QUOTE] '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.
[code] SendLua 0.029998779296875 Usermessage 0.029998779296875 [/code] 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.
[QUOTE=Horsey;16792958]Because they're supposed to be better than SendLua?[/QUOTE] 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.
[QUOTE=|FlapJack|;16794041]What if the client doesn't download lua from the server?[/QUOTE] Then the client deserves to not have full benefits within the server. It was his choice to not download them.
[QUOTE=MakeR;16793164]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.[/QUOTE] 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". [QUOTE=|FlapJack|;16794041]What if the client doesn't download lua from the server?[/QUOTE] What if the client doesn't connect to the server? :OOO [QUOTE=|FlapJack|;16794041]Ontop of that, you would need to have a clientside file to hook into the usermessage. In this case, SendLua is definately better.[/QUOTE] I hate it when my gamemode goes "Hey if you edit cl_init.lua I remove myself from your harddrive."
[QUOTE=Zetanor;16794106]Obviously they're the same since you're sending packets to your own computer.[/QUOTE] 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.
[QUOTE=Zetanor;16794106] I hate it when my gamemode goes "Hey if you edit cl_init.lua I remove myself from your harddrive."[/QUOTE] Sandbox deletes any changes you make to it on restart.
DeriveGamemode("sandbox")
[QUOTE=Zetanor;16794275]DeriveGamemode("sandbox")[/QUOTE] Then you need to use the gm_getgamedescription module (If thats it's name)
No.
Sorry, you need to Log In to post a reply to this thread.