Raised This Month: $276 Target: $400
 69% 

Disconnect Reason


Post New Thread Reply   
 
Thread Tools Display Modes
Plugin Info:     Modification:   Counter-Strike        Category:   General Purpose        Approver:   Arkshine (91)
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-01-2011 , 08:27   Disconnect Reason
Reply With Quote #1

Disconnect Reason
.: v0.6

Description

This plugin notifies players via chat and console the reason that a player has disconnected (ie. Timed out, Client sent 'drop', Kicked). The standard console message notifying of a player disconnect will not be shown when the plugin is enabled. I've also eliminated the cvars found in the previous release that controlled notification types and notification methods; all types of disconnects are displayed in both chat and console. There is also a forward which allows you to utilize disconnect reasons in your own plugins 'client_disconnect_reason( id , drCode , szReason[] )', see below example. The forward remains active regardless of the dr_enabled cvar value which will only control chat\console message. Made by request.

CVars
  • dr_enabled <0/1> - Chat\console notification enabled\disabled status.
    • Default: 1 (0=disabled, 1=enabled)

Forwards
  • client_disconnect_reason( id , drCode , const szReason[] ) - Forward for client_disconnect with reason.
    • id - Player id
    • drCode - Disconnect reason code
      • DR_TIMEDOUT
      • DR_DROPPED
      • DR_KICKED
      • DR_LEVELCHANGE
      • DR_OTHER
    • szReason - Disconnect reason in text form: "Timed out", "Client sent 'drop'", "Kicked", "Dropping fakeclient on level change".

Disconnect Reason Codes
PHP Code:
enum ReasonCodes
{
    
DR_TIMEDOUT,
    
DR_DROPPED,
    
DR_KICKED,
    
DR_LEVELCHANGE,
    
DR_OTHER

Modules
  • Orpheu

Installation
  • Place compiled (.amxx) file in plugins directory as with any other plugin.
  • Place the SV_DropClient file (found in signatures.zip) in amxmodx\configs\orpheu\functions.
  • For forward to work in your plugin(s), you must have this plugin running (do not #include it).

ScreenShots






Example Plugin
PHP Code:
#include <amxmodx>

new const Version[] = "0.1";

enum ReasonCodes
{
    
DR_TIMEDOUT,
    
DR_DROPPED,
    
DR_KICKED,
    
DR_LEVELCHANGE,
    
DR_OTHER
}

public 
plugin_init() 
{
    
register_plugin"Disconnect Reason Example" Version "bugsy" );
}

public 
client_disconnect_reasonid ReasonCodes:drReason , const szReason[] )
{
    
//Display info
    
server_print"id=%d ReasonCode=%d ReasonText=^"%s^"" id drReason szReason );
    
    switch ( 
drReason )
    {
        case 
DR_TIMEDOUTserver_print"Poor guy timed out" );
        case 
DR_DROPPEDserver_print"Ughh, another player left my server :(" );
        case 
DR_KICKEDserver_print"Player kicked, toodaloo!" );
        case 
DR_LEVELCHANGEserver_print"Server changed map, he didnt leave" );
        case 
DR_OTHERserver_print"hmm, why did he get disconnected?" );
    }

Changelog:
  • v0.6
    • Added 'Dropping fakeclient on level change' disconnect reason.
  • v0.5
    • Added client_disconnect_reason forward for hooking client_disconnect with reason.
  • v0.4
    • Removed Sys_Printf hook since I'm pretty sure it is only used for printing to server console which nobody sees anyway so it's pointless to block. I initially assumed it printed to both server and client consoles.
    • Added block for message #Game_disconnected to prevent players from seeing "Name has left the game" in console.
    • Removed post hook for SV_DropClient since it was not needed.
      • v0.4a
        • Minor code cleanup
  • v0.3
    • Improved signature used for SV_DropClient
    • Removed cvars for controlling type and method, all disconnect types are notified in both chat and console.
    • Added Sys_Printf hook to block the default disconnect message in console.
  • v0.2
    • Added condition to check that a real player is disconnecting. xPaw reported that a notification appeared with the server name (id=0).
    • Changed chat notification from messaging all players individually to a single message to all.
  • v0.1
    • Initial release

3400 7/3/15
Attached Files
File Type: zip [signature]SV_DropClient.zip (346 Bytes, 3150 views)
File Type: sma Get Plugin or Get Source (disconnect_reason.sma - 2459 views - 2.8 KB)
__________________

Last edited by Bugsy; 07-03-2015 at 21:44. Reason: Revision
Bugsy is offline
Pastout
Senior Member
Join Date: Dec 2010
Location: 1337 Street LeetTown
Old 09-01-2011 , 08:33   Re: Disconnect Reason
Reply With Quote #2

Wow, cool
Pastout is offline
xPaw
Retired AMX Mod X Moderator
Join Date: Jul 2008
Old 09-01-2011 , 08:42   Re: Disconnect Reason
Reply With Quote #3

Why not use MSG_BROADCAST for chat message?
__________________
xPaw is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-01-2011 , 08:56   Re: Disconnect Reason
Reply With Quote #4

I copied that function from my aimbot detect plugin which notifies on a per player basis. I will modify when I get home.
__________________
Bugsy is offline
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 09-01-2011 , 09:39   Re: Disconnect Reason
Reply With Quote #5

Good job.
dark_style is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-01-2011 , 09:49   Re: Disconnect Reason
Reply With Quote #6

I have to update my tutorial but a better rule would be : all can be changed except the first byte and local vars (e*x).

So you get something like :
Code:
[0x55,0x8B,"*",0x81,"*","*","*","*","*",0x8B,0x4D,"*",0x53,0x56,0x8D,0x45,"*",0x57,0x50,0x51]
__________________
Arkshine is offline
Lolz0r
Veteran Member
Join Date: Nov 2010
Location: Balgaria
Old 09-01-2011 , 09:52   Re: Disconnect Reason
Reply With Quote #7

Nice plugin!
Lolz0r is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 09-01-2011 , 10:02   Re: Disconnect Reason
Reply With Quote #8

I didn't understand the signature mask part very well. I tried to do exactly what was done in the sigscanning tut and your (Arkshine) tut, but for the most post I was just experimenting and it worked. A tutorial dedicated to making signatures/masks from a newbie perspective would be very useful. I have no experience on the subject.
__________________

Last edited by Bugsy; 09-01-2011 at 10:04.
Bugsy is offline
dark_style
Senior Member
Join Date: Jul 2009
Location: Bulgaria
Old 09-01-2011 , 10:06   Re: Disconnect Reason
Reply With Quote #9

I have an idea for you. What about to add the reason when mp_autokick is set to 1 and the player get kicked by it?
dark_style is offline
Arkshine
AMX Mod X Plugin Approver
Join Date: Oct 2005
Old 09-01-2011 , 10:19   Re: Disconnect Reason
Reply With Quote #10

If it can help better :

Code:
55                   push    ebp
8B EC                mov     ebp, esp
81 EC 00 06 00 00    sub     esp, 600h
8B 4D 10             mov     ecx, [ebp+Format]
53                   push    ebx
56                   push    esi
8D 45 14             lea     eax, [ebp+Args]
57                   push    edi
50                   push    eax            
51                   push    ecx
- Blue -> You keep always the first byte, and if there is only one ignore what you see after. (like 'ebp' in the first line)
- Green -> When you see e*x is used, you can keep the byte

Others = could be changed.
__________________

Last edited by Arkshine; 09-01-2011 at 10:22.
Arkshine 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 21:09.


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