Deprecate Lua server on dedicated
isdedicatedserver may also be checked by clients to see if they are connected to a dedicated server.
After some discussion with LJ, we feel that this hack--imaginary "server" player on dedicated servers--doesn't really need to exist. If you need to operate server side, you could check
The MR description had me somewhat confused, because it makes it sound like you actually entirely removed the hack where dedicated servers have a dummy invisible player to make them work at all, but it's just Lua side. I'd argue it's technically more natural for Lua to have that hack because that IS how the dedicated server works, but I am cool with the change since I also just want that hack eventually fixed too :p
My main hang-up before I'd +1 though is: storing things on the server player is the the only convenient way to ensure that a script variable gets reset between different sessions (starting a server, then ending and starting another) ... while that doesn't apply to dedicated servers, it was just convenient that you didn't have to write extra code. If this gets merged in as is, the new solution would be to store 2 duplicates of the script variables: one on the server player for player-hosted servers, then script ones with a NetVars hook for dedicated servers. Which would be an incredible new level of obnoxious :V
So I'd like to request that a "ServerStarted" / "ServerEnded" / whatever equivalent hook get made (even if it's a separate merge), so that people storing things on the player have a new clean alternative instead of just being kinda boned
So instead of executing code for the server "player", we'd have to check for isserver and then execute for player_t?
It may be worth mentioning that Lua has a
GameQuithook which is called when a game session ends (including when you return to the title screen or close the game).
Also, I have to admit I have always wished we had some
GameStarthook instead of using a
ThinkFramethat keeps checking whether some variable has been initialised.
Additionally we need
That's not the problem. You can't give commands to the dedicated server.
Commands aren't intrinsically tied to players internally; you don't need access to a "dedicated server player" to run commands on the dedicated server.
COM_BufInsertTextdoes is run the command unconditionally on all clients that come across that function call if the first argument is
isdedicatedservercheck guarantees that it will only run when the dedicated server is running the code.
Both in combination allows us to run code specifically -- only -- on the dedicated server.
Oh, OK, I getcha now