Raised This Month: $ Target: $400
 0% 

[Need help!] Checking disconnects not working with my script!


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
Ethorbit
Member
Join Date: Sep 2016
Location: Oregon
Old 07-13-2017 , 01:44   [Need help!] Checking disconnects not working with my script!
Reply With Quote #1

PHP Code:
#include <sourcemod>
 
#include <sdktools>

public void OnClientDisconnect_Post(client)
{
    
DoThis(client);
}

public 
void DoThis(client) {
    
char mapname[128];
    
GetCurrentMap(mapnamesizeof(mapname));

 if (
strncmp(mapname"dm_surrender_h"14) == 0)
    {
    if (
IsFakeClient(client))
    {
    
Plugin_Stop;
    }
    else
    {
        if (
GetClientCount() == 1) {
                        
//console commands I had here that are irrelevant to the issue
            
Plugin_Continue;
            }
    if (
GetClientCount() >= 2) {
                        
//console commands I had here that are irrelevant to the issue
            
Plugin_Continue;
            }
        }
    }

I also tried this:

PHP Code:
#include <sourcemod>
 
#include <sdktools>

public void OnPluginStart()
{
RegConsoleCmd("disconnect"Command_Disconnect);
}

public 
Action Command_Disconnect(clientargs)
{
    
DoThis(client);
}

public 
void DoThis(client) {
    
char mapname[128];
    
GetCurrentMap(mapnamesizeof(mapname));

 if (
strncmp(mapname"dm_surrender_h"14) == 0)
    {
    if (
IsFakeClient(client))
        {
        
Plugin_Stop;
        }
        else
        {
                  if (
GetClientCount() == 1) {
                        
//console commands I had here that are irrelevant to the issue
            
Plugin_Continue;
               }
            if (
GetClientCount() >= 2) {
            
//console commands I had here that are irrelevant to the issue
            
Plugin_Continue;
           }
        }
    } 

Does anyone know why these aren't working?

OnClientDisconnect works, however it will count the player that disconnected too, so I don't like that.

Last edited by Ethorbit; 07-13-2017 at 16:24.
Ethorbit is offline
DarkDeviL
SourceMod Moderator
Join Date: Apr 2012
Old 07-14-2017 , 04:48   Re: [Need help!] Checking disconnects not working with my script!
Reply With Quote #2

Use OnClientDisconnect and instead of:

Code:
if (GetClientCount() == 1) {
then do:

Code:
if ((GetClientCount() - 1) == 1) {
?
__________________
Mostly known as "DarkDeviL".

Dropbox FastDL: Public folder will no longer work after March 15, 2017!
For more info, see the [SRCDS Thread], or the [HLDS Thread].
DarkDeviL is offline
Reply



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 01:30.


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