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
Add support for sending gameevent to specific client. #505
Conversation
@@ -31,6 +31,8 @@ | |||
|
|||
#include "EventManager.h" | |||
#include "sm_stringutil.h" | |||
#include "PlayerManager.h" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So is this blank line needed?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...
Thinking about it more, it shouldn't be necessary to add any further hooking. Even copying the event data in the "workaround" can be avoided, since you can use Event.FireToClient in an event prehook. Pattern would be something like:
|
So event.BroadcastDisabled = true; is no longer required? |
I don't fully understand the question, but this is a better example of the above, if you don't want to actually block the event serverside.
When you only block broadcast, it stops the event from going to clients, but the server will still do any processing that it may have for the event (such as the log line for player_death). If you block the event itself, that gets blocked, too. I hope that clarifies things. |
IClient *pClient = pPlayer->GetIClient(); | ||
if (!pClient) | ||
{ | ||
return pContext->ThrowNativeError("Sending events to fakeclients is not supported on this game (client %d)", client); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are super rare cases where a client can be connected but still have an invalid net channel (KAC/SMAC used to cause crashes in convar queries). Despite this, everything looks fine.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pics or it didn't happen.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ironically it was part of the code you refactored 😄
https://hg.alliedmods.net/releases/sourcemod-1.3/rev/82cfdef347cc
I also initially planned on adding support for blocking existing events, per client on-the-fly, but API was getting complex and potentially inefficient. (This can still be added at some point). The net effect of that can still be achieved by blocking existing events with a prehook, saving event data, and then resending to the desired clients (not ideal, but doable).
Only tested on TF2 in Windows