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
{
AuthID[ 34 ],
DisconnectTime
}
new g_siSlots[ SLOT_COUNT ][ SlotInfo ];
new g_szAuthID[ MAX_PLAYERS + 1 ][ 34 ];
new bool:g_bKicked[ MAX_PLAYERS + 1 ];
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_disconnect( id )
#else
public client_disconnected( id )
#endif
{
RefreshSlots();
if ( !g_bKicked[ id ] )
{
AddSlot( id );
}
}
public client_authorized( id )
{
new iSlotID;
get_user_authid( id , g_szAuthID[ id ] , charsmax( g_szAuthID[] ) );
g_bKicked[ id ] = false;
RefreshSlots();
if ( g_iUsedSlots )
{
iSlotID = GetPlayerSlotID( id );
if ( iSlotID == SLOT_NOT_FOUND )
{
g_bKicked[ id ] = true;
server_cmd( "kick #%d ^"%s^"" , get_user_userid( id ) , g_szKickReason );
}
else
{
g_siSlots[ iSlotID ][ AuthID ][ 0 ] = EOS;
g_siSlots[ iSlotID ][ DisconnectTime ] = 0;
g_iUsedSlots--;
}
}
}
AddSlot( id )
{
if ( g_iUsedSlots < SLOT_COUNT )
{
for ( new i = 0 ; i < sizeof( g_siSlots ) ; i++ )
{
if ( g_siSlots[ i ][ AuthID ][ 0 ] == EOS )
{
copy( g_siSlots[ i ][ AuthID ] , charsmax( g_siSlots[][ AuthID ] ) , g_szAuthID[ id ] );
g_siSlots[ i ][ DisconnectTime ] = get_systime();
g_iUsedSlots++;
break;
}
}
}
}
GetPlayerSlotID( id )
{
new iSlotID = SLOT_NOT_FOUND;
for ( new i = 0 ; i < sizeof( g_siSlots ) ; i++ )
{
if ( equal( g_siSlots[ i ][ AuthID ] , g_szAuthID[ id ] ) )
{
iSlotID = i;
break;
}
}
return iSlotID;
}
RefreshSlots()
{
new iSlotTime = ( get_pcvar_num( g_pReserveTime ) * 60 );
new iSysTime = get_systime();
for ( new i = 0 ; i < sizeof( g_siSlots ) ; i++ )
{
if ( g_siSlots[ i ][ DisconnectTime ] && ( ( g_siSlots[ i ][ DisconnectTime ] + iSlotTime ) < iSysTime ) )
{
g_siSlots[ i ][ AuthID ][ 0 ] = EOS;
g_siSlots[ i ][ DisconnectTime ] = 0;
g_iUsedSlots--;
}
}
}
__________________