Checking if the player has completely finished loading into the server

I need some way to tell if a new player has completely finished loading into the server. I noticed that when a player enters the server their character will spawn/become visible, but they will not actually be fully in the game yet. This breaks a lot of features I have written.

So are there any hooks or anything to figure this out quickly?

So far I’ve figured out that OnMove is an acceptable way to work around this problem by only doing stuff if the player can move (which will always be when they are fully loaded into the server). But obviously this hook is called way too many times…
I’ve searched through the new and old Gmod wikis, Google, and pretty much everything else already.

There are several different ways. For non-important things you can use HUDPaint on the client. For important things you can detect it Server-side like this:

net.Start("Hello :D")

util.AddNetworkString("Hello :D")
net.Receive("Hello :D",function(len,ply)

Anything that runs after the client have loaded should work. You just need to skip the “loading”-tick.

However there are no ways I know of that can detect it without trusting the client.
But you can setup a few checks on the server like Move, KeyPress … ect

A friend and I use InitPostEntity on the client and then send a net message to the server. The same way as Acecool is doing it.
Although I’m interested to know if the other hooks pointed out by Acecool are called any sooner?

HUDPaint is called slightly before the player enters ( or before LocalPlayer( ) becomes valid, hence the need to do an IsValid check ).

PlayerInitialSpawn is around Sending Client Info

I have an old version of PlayerFullyConnected which used client-side hook CalcView ( which runs as soon as the player is in the game, but not before ), but for things where the server needs to know about the client joining, you don’t want to leave the client the task of notifying the server…

Current PlayerFullyConnected is called right when player is fully in game ( give or take a tick or so because it processes other players / skipping those already in game ), and it is called in the Server.

There are plenty of hooks that fire just before they’re in game, and there are many hooks that could be used to detect if a player has fully joined such as detecting key-presses and other methods, but again that waits for the client…

I don’t have a “write-up” of all hooks / fire-times, but it is planned… ( All new hooks I write, I do a write-up of when/how/where etc they’re fired, I want to extend that documentation to the default hooks so users know exactly when something is fired, what it is called by so if they overwrite the parent they know to put the calls back in, etc )…

InitPostEntity is a great hook to spawn entities, replace textures on the map when a user joins, and other things.

What exactly in that code lets the server know the client is fully connected? Are you just using SetupMove to fire off the entire thing?

If so, don’t SetupMove and CalcView fire off just as many times as OnMove does?

I haven’t tested OnMove yet; but SetupMove is only called for each specific player when the client is fully joined and able to use the movement keys.

Ok, that makes things a lot easier.

You should definitely try to get a full list of hook timings made. It’d help a ton of people.

I Think the athorised hook gets called just as the player spawns, don’t quote me on it tho xD

Not sure what hook you’re talking about but if it’s called when the player spawns then it won’t work because I needed a hook that calls when the player is loaded in.

PlayerAuthed, if I recall correctly, is called just as Player is Sending Client Info. The player “entity” may spawn in the server, but it may still be !IsValid at that point to the local player as entities the player doesn’t get near are considered NULL.

Example, if you print( Entity( whatever ) ) on clientside of an entity on the other side of map ( out of range ), it’ll print NULL. When the player goes near the entity, and you run same code, it’ll print the information. This may be why LocalPlayer is !IsValid right as player enters the server.

But, yes, I’ll be working on a document that will list “exact” timing of when each hook is called and make that available. Whoever wants to use the info to update the wiki may go ahead ( useful to have on wiki ) if I don’t get around to it.

Directly from my easylua.lua

local strIdentifier = "Loading... NOM NOM NOM"

hook.Add ("Think", strIdentifier, function ()
    if IsValid (LocalPlayer ()) then
        -- If you really want to pass your self, go ahead but it's clientside so your essentially the only one using this hook.
        -- hook.Call ("PlayerFinishedLoading", GAMEMODE, LocalPlayer ())

        hook.Call ("PlayerFinishedLoading", GAMEMODE)
        hook.Remove ("Think", strIdentifier)