Raised This Month: $12 Target: $400
 3% 

Solved I need help in (player_disconnect)


Post New Thread Reply   
 
Thread Tools Display Modes
dr_lex
Member
Join Date: Dec 2014
Old 12-02-2020 , 16:31   Re: I need help in (player_disconnect)
Reply With Quote #11

Quote:
Originally Posted by Dragokas View Post
I think we can do it by hooking CBaseClient:: PerformDisconnection, responsible for logging the message in console.log:

PHP Code:
CBaseClient *__cdecl CBaseClient::PerformDisconnection(CBaseClient *this, const char *a2)
{
...
ConMsg("Dropped %s from server (%s)\n"v5a2); 
But I don't know how to do it correctly. Maybe, somebody help?

My attempt:
Spoiler


PS. The topic is marked "Solved" when actually is not at all.
As you said, this question is difficult to answer.
Most likely, it just doesn't work in l4d2.

For me, this topic is no longer so important, since I went a different way to solve it. It was good to get an answer, but it probably won't be.
__________________
dr_lex is offline
Balimbanana
Member
Join Date: Jan 2017
Old 12-03-2020 , 01:09   Re: I need help in (player_disconnect)
Reply With Quote #12

I have been able to get normal responses in the "reason" from the event "player_disconnect"
You must have a plugin that is overwriting the disconnect reason. If a plugin hooks "player_disconnect" with EventHookMode_Pre and does a return Plugin_Changed or return Plugin_Handled, it would most likely be blocking the "reason" for further events.

I got the returns of:
Code:
By disconnect or quit
Disconnect by 1 "Disconnect by user."
By kick
Disconnect by 1 "Kicked by Console"
From this:
PHP Code:
public void OnPluginStart()
{
    
HookEventEx("player_disconnect"Event_DisconnectEventHookMode_Post);
}

public 
Action Event_Disconnect(Event event, const char[] namebool dontBroadcast)
{
    
char szReason[128];
    
GetEventString(event"reason"szReasonsizeof(szReason), "No Reason");
    
int client GetClientOfUserId(GetEventInt(event,"userid"));
    
PrintToServer("Disconnect by %i \"%s\""clientszReason);

Edit:
As expected, running this on separate plugin:
PHP Code:
HookEventEx("player_disconnect"Event_DisconnectPreEventHookMode_Pre);

public 
Action Event_DisconnectPre(Event event, const char[] namebool dontBroadcast)
{
    
SetEventString(event"reason""Overridden");
    return 
Plugin_Changed;

Changed the returns of the other plugins Post hook to:
Code:
Disconnect by 1 "Overridden"

Last edited by Balimbanana; 12-03-2020 at 01:14.
Balimbanana is offline
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -4. The time now is 08:26.


Powered by vBulletin®
Copyright ©2000 - 2024, vBulletin Solutions, Inc.
Theme made by Freecode