Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

how to detect when a player is allowed to spawn #1773

Closed
tschumann opened this Issue Jan 26, 2017 · 5 comments

Comments

Projects
None yet
2 participants
@tschumann
Copy link

commented Jan 26, 2017

Is there any callback or any easy set of conditions to check to determine when a player can spawn into a map?
As background, I'm working on a bot plugin and I want to call mapname_bot.cfg when a map loads (where mapname_bot.cfg contains a set of calls to addbot which puts a bot in the server).
The problem is I don't know where to exec the .cfg from inside a plugin - ServerActivate is too early. botman's HPB Bot used StartFrame but it uses some check that doesn't work.
At the moment I'm detecting when the first message is sent and execing mapname_bot.cfg after that, which mostly seems to work, but it doesn't in Natural Selection (which presumably tried to send a message very early).

@SamVanheer

This comment has been minimized.

Copy link

commented Jan 26, 2017

You're probably having issues because the Steam server hasn't initialized yet at that point. Fake clients access it to create fake Steam IDs and initialize session tokens:

int64_t steamID = ISteamGameServer_CreateUnauthenticatedUserConnection();
  pClient->network_userid.idtype = 1;
  pClient->network_userid.m_SteamID = steamID;
  ISteamGameServer_BUpdateUserData(steamID, netname, 0);

The ISteamGameServer instance is created after ServerActivate gets called.

The first unconditional call into game code that occurs after server initialization is DLL_FUNCTIONS::pfnCreateInstancedBaselines.

@tschumann

This comment has been minimized.

Copy link
Author

commented Jan 29, 2017

Thanks - I tried that but pfnCreateInstancedBaselines still seems to early. Do you know if anything is called just after ClientPutInServer or DispatchSpawn? Ideally I'd use either of those functions but if the plugin were running on a server then there wouldn't necessarily be any players.

@SamVanheer

This comment has been minimized.

Copy link

commented Jan 29, 2017

I'm not seeing any calls made into the server dll after ClientPutInServer.

It goes like this:
SV_Spawn_f->SV_WriteSpawn->ClientPutInServer

At the end of SV_WriteSpawn it will set the client's state to spawned so that it can receive network messages. No further calls into the server are made after that.

Putting a check in pfnStartFrame seems like the best bet here, setting a flag on the player to update them should work.

@SamVanheer

This comment has been minimized.

Copy link

commented Jan 29, 2017

Added a request for this. I know it's possible because i did it for Svengine.

@tschumann

This comment has been minimized.

Copy link
Author

commented Feb 18, 2017

Hm, I think using some min/max cvars to add bots until the server is populated is probably the easiest way of doing this.
Thanks for the help.

@tschumann tschumann closed this Feb 18, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.