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

Solved Reserve slot for disconnected player


Post New Thread Reply   
 
Thread Tools Display Modes
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-12-2020 , 23:27   Re: Reserve slot for disconnected player
Reply With Quote #11

Added this condition to client_authorized.

PHP Code:
    else if ( iSlotID != -)
    {
        
g_siSlotsiSlotID ][ AuthID ][ ] = EOS;
        
g_siSlotsiSlotID ][ DisconnectTime ] = 0;
        
g_iUsedSlots--;
    } 
__________________

Last edited by Bugsy; 02-13-2020 at 06:45.
Bugsy is offline
4ever16
Veteran Member
Join Date: Apr 2015
Old 02-13-2020 , 17:17   Re: Reserve slot for disconnected player
Reply With Quote #12

The plugin didn't work.

Last edited by 4ever16; 02-13-2020 at 17:31.
4ever16 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-13-2020 , 17:53   Re: Reserve slot for disconnected player
Reply With Quote #13

You have to provide some details. I was getting weird behavior testing with bots since I think they reconnect sooner than the slot is created for a disconnecting player. Let me know what happens so I can try to fix it.
__________________

Last edited by Bugsy; 02-13-2020 at 23:09.
Bugsy is offline
4ever16
Veteran Member
Join Date: Apr 2015
Old 02-14-2020 , 13:50   Re: Reserve slot for disconnected player
Reply With Quote #14

Nothing happens. I disconnect (slot should be reserve for me) but other users can still connect.

Last edited by 4ever16; 02-14-2020 at 13:50.
4ever16 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-14-2020 , 17:26   Re: Reserve slot for disconnected player
Reply With Quote #15

It's only going to prevent others from connecting if current player count + actively reserved slots >= max players. Isn't this what you'd want?
__________________
Bugsy is offline
4ever16
Veteran Member
Join Date: Apr 2015
Old 02-14-2020 , 18:36   Re: Reserve slot for disconnected player
Reply With Quote #16

For example.

I connect to the server.
I disconnect = reserved slot for me. No one else can connect. Only the user who disconnected = me. If the disconnected player doesnt comeback for like 3 minutes his reserve slot is removed and everyone else can connect.

If multiply users disconnects same thing there, only they can connec/reconnect for 3 minutes no one else. After those 3 minutes anyone can connect.

Last edited by 4ever16; 02-14-2020 at 18:37.
4ever16 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-14-2020 , 19:11   Re: Reserve slot for disconnected player
Reply With Quote #17

Take make sure I understand correctly, assume the below:

Max players = 32
Players on the server = 6 (including me)

If I disconnect, you want it to not allow anyone else to connect except me, or anyone else who has a slot, even though the server can support 27 players (32 - 5)?

How do you expect to get new players on your server, it will basically lock everyone out until all slots have expired.

The way I coded the plugin is to only block people from joining if the total number of players actively on the server + the number of disconnect slots in use exceeds the number of players the server can support. This makes it so it only kicks people if allowing them to join would prevent the slot people to reconnect.
__________________

Last edited by Bugsy; 02-14-2020 at 19:13.
Bugsy is offline
4ever16
Veteran Member
Join Date: Apr 2015
Old 02-15-2020 , 08:33   Re: Reserve slot for disconnected player
Reply With Quote #18

Quote:
Originally Posted by Bugsy View Post
Take make sure I understand correctly, assume the below:

Max players = 32
Players on the server = 6 (including me)

If I disconnect, you want it to not allow anyone else to connect except me, or anyone else who has a slot, even though the server can support 27 players (32 - 5)?

How do you expect to get new players on your server, it will basically lock everyone out until all slots have expired.
Thats the point.
New players can join only when reserve slots are expired.
4ever16 is offline
Bugsy
AMX Mod X Moderator
Join Date: Feb 2005
Location: NJ, USA
Old 02-15-2020 , 14:03   Re: Reserve slot for disconnected player
Reply With Quote #19

Ok.. try this version. It will not work properly with bots since they all share the same authid.
PHP Code:

#include <amxmodx>

#define MAX_PLAYERS 32

const SLOT_COUNT 5;
const 
SLOT_NOT_FOUND = -1;

new const 
g_szKickReason[] = "There are no unreserved slots, please try again later.";

enum SlotInfo
{
    
AuthID34 ],
    
DisconnectTime
}

new 
g_siSlotsSLOT_COUNT ][ SlotInfo ];

new 
g_szAuthIDMAX_PLAYERS ][ 34 ];
new 
bool:g_bKickedMAX_PLAYERS ];

new 
g_iUsedSlots;
new 
g_pReserveTime;

public 
plugin_init()
{
    
register_plugin"Disconnect Reserve Slot" "0.2" "bugsy" );
    
    
g_pReserveTime register_cvar"drs_reserveminutes" "5" );
}

#if AMXX_VERSION_NUM < 190
public client_disconnectid )
#else
public client_disconnectedid )
#endif
{
    
RefreshSlots();
    
    if ( !
g_bKickedid ] )
    {
        
AddSlotid );
    }
}

public 
client_authorizedid )
{
    new 
iSlotID;
    
    
get_user_authidid g_szAuthIDid ] , charsmaxg_szAuthID[] ) );
    
g_bKickedid ] = false;
    
    
RefreshSlots();

    if ( 
g_iUsedSlots )
    {
        
iSlotID GetPlayerSlotIDid );
        
        if ( 
iSlotID == SLOT_NOT_FOUND )
        {
            
g_bKickedid ] = true;
            
server_cmd"kick #%d ^"%s^"" get_user_useridid ) , g_szKickReason );
        }
        else
        {
            
g_siSlotsiSlotID ][ AuthID ][ ] = EOS;
            
g_siSlotsiSlotID ][ DisconnectTime ] = 0;
            
g_iUsedSlots--;
        }
    }
}

AddSlotid )
{
    if ( 
g_iUsedSlots SLOT_COUNT )
    {
        for ( new 
sizeofg_siSlots ) ; i++ )    
        {
            if ( 
g_siSlots][ AuthID ][ ] == EOS )
            {
                
copyg_siSlots][ AuthID ] , charsmaxg_siSlots[][ AuthID ] ) , g_szAuthIDid ] );
                
g_siSlots][ DisconnectTime ] = get_systime();
                
g_iUsedSlots++;
                break;
            }
        }
    }
}

GetPlayerSlotIDid )
{
    new 
iSlotID SLOT_NOT_FOUND;
    
    for ( new 
sizeofg_siSlots ) ; i++ )    
    {
        if ( 
equalg_siSlots][ AuthID ] , g_szAuthIDid ] ) )
        {
            
iSlotID i;
            break;
        }
    }
    
    return 
iSlotID;
}

RefreshSlots()
{
    new 
iSlotTime = ( get_pcvar_numg_pReserveTime ) * 60 );
    new 
iSysTime get_systime();
    
    for ( new 
sizeofg_siSlots ) ; i++ )
    {
        if ( 
g_siSlots][ DisconnectTime ] && ( ( g_siSlots][ DisconnectTime ] + iSlotTime ) < iSysTime ) )
        {
            
g_siSlots][ AuthID ][ ] = EOS;
            
g_siSlots][ DisconnectTime ] = 0;
            
g_iUsedSlots--;
        }
    }        

__________________

Last edited by Bugsy; 02-20-2020 at 19:06.
Bugsy is offline
4ever16
Veteran Member
Join Date: Apr 2015
Old 02-20-2020 , 00:54   Re: Reserve slot for disconnected player
Reply With Quote #20

Thanks working good!
4ever16 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 11:02.


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