PDA

View Full Version : Replacement for NetworkIDValidated?


showdax
09-08-2005, 07:48
Is there any way to get the functionality that IServerPluginCallbacks::NetworkIDValidated provided, with sourcemm? I'm writing a plugin that needs this information as soon as it's known. Getting it on ClientActive won't due.

I know you guys don't like the function because it doesn't give useful information, but for my purposes it's enough. If there's no way to use this with sourcemm, what's the best way to find out when a networkid has been set?

L. Duke
09-08-2005, 13:11
BAILOPAN:The client callbacks are quiet useless, you have, in the order they're called:
ClientConnect :: almost no useful info
ClientChanged
ClientNetworkIdValidated :: no useful info or edict
ClientPutInServer :: IPlayerInfo will be a corrupt pointer
ClientActive :: IPlayerInfo is valid, but ::IsConnected() returns false!

As you can see, it's not pretty...

If you still think you need NetworkIdValidated you can use it in sourcemm. See the sample_mm plugin for how to hook the callbacks.

showdax
09-09-2005, 00:10
I can't seem to get a working instance of the interface. Both of the below return NULL:
m_ServerPluginCallbacks = (IServerPluginCallbacks *)((ismm->engineFactory())(INTERFACEVERSION_ISERVERPLUG INCALLBACKS, NULL));m_ServerPluginCallbacks = (IServerPluginCallbacks *)((ismm->serverFactory())(INTERFACEVERSION_ISERVERPLUG INCALLBACKS, NULL));

showdax
09-09-2005, 06:33
As per BAILOPAN's suggestion, I made it queue up players for checking in GameFrame() until their networkids are validated. Here's basically what I did:
bool Plugin::ClientConnect(edict_t *pEntity, const char *pszName, const char *pszAddress, char *reject, int maxrejectlen)
{
[add player to pending players list]

if (strcmp([player's steamid via IVEngineServer::GetPlayerNetworkID], "STEAM_ID_PENDING") == 0)
g_IsPending = true;

RETURN_META_VALUE(MRES_HANDLED, true);
}

And then in GameFrame:

void Plugin::GameFrame(bool simulating)
{
if (g_IsPending)
{
if (g_Globals->curtime > g_Timer) // g_Globals is CGlobalVars
{
g_Timer = g_Globals->curtime + 0.5;

[function that checks each pending player's steamid and removes them from the pending list if they're validated]

if ([count of pending player list] < 1)
g_IsPending = false;

RETURN_META(MRES_HANDLED);
}
}

RETURN_META(MRES_IGNORED);
}

Mani
11-07-2005, 08:16
Strangley enough I've just implemented a similar version based on this as I need a proper edict on steam id validation (for admin level functionality).

Though in mine the cue is on ClientActive() which does have a valid edict pointer and at that time may also have a valid network ID so potentially saves overhead in GameFrame().

Mani

BAILOPAN
11-07-2005, 10:59
He's only making gameframe "think" every .5 seconds so it's not adding any overhead (considering what the engine calculates every frame, doing a float comparison is a drop in the bucket).

I think technically a network id can be validated after ClientActive though? At least in HL1, it was rare, but it could even happen after PutInServer.

Mani
11-07-2005, 14:13
He's only making gameframe "think" every .5 seconds so it's not adding any overhead (considering what the engine calculates every frame, doing a float comparison is a drop in the bucket).

I think technically a network id can be validated after ClientActive though? At least in HL1, it was rare, but it could even happen after PutInServer.

Yeah I do mine once a second, like you say it's negligable overhead compared to what the source engine is doing :)

Looking at my logs in most cases the network id is already validated by the time ClientActive() is called in which case there is no point putting it on a list to be processed, you might as well call the substitute NetworkIDValidated() function. Occasionally however the network ID is not validated when ClientActive() is called (sometimes it's never validated !!) so that's when I put it on the list for processing during the game frame.

Mani

showdax
11-07-2005, 15:44
This was for a reserved slot plugin, which is why I wanted the network ID as soon as it was known. It would be pretty annoying to join a server and completely load the level, only to find out the server doesn't have room for you.