knife108
10-11-2007, 02:50 AM
//based on:
//slots_reservation --f117bomb ;
//ilovelan --Avalanche;
////////////////////////////////////
//
//Cvar:
//* amx_reservation <value>
//* 1 - Kicks the Player with shortest playing time when a LAN user connects to a full server.
//* 2 - Kick the Player with the highest ping when a LAN user connects to a full server.
//
//set a lan.ini file in addons/amxmodx/data/
//add LAN ips in lan.ini:
// 10.0
// 192.168
// 217.147.10
// 217.147.20
//
////////////////////////////////////
#include <amxmodx>
#include <amxmisc>
// filename of LAN ips
#define FILENAME "addons/amxmodx/data/lan.ini"
// Comment if you don't want to hide true max_players
#define HIDE_RESERVEDSLOTS
public plugin_init()
{
register_plugin("DoD Slot for LAN","0.1","")
register_cvar("amx_reservation","1")
#if defined HIDE_RESERVEDSLOTS
set_cvar_num( "sv_visiblemaxplayers" , get_maxplayers() - 1 )
#endif
}
public client_authorized(id) {
new maxplayers = get_maxplayers()
new players = get_playersnum( 1 )
new limit = maxplayers - 1
new resType = get_cvar_num( "amx_reservation" )
new who
if ( players > limit ) //21/20
{
if ( get_user_flags(id) & is_user_LAN(id) )
{
switch(resType) {
case 1:
who = kickFresh()
case 2:
who = kickLag()
}
if(who) {
new name[32]
get_user_name( who, name , 31 )
client_cmd(id,"echo ^"* %s was kicked for the LAN
users!^"" ,name )
}
return PLUGIN_CONTINUE
}
if ( is_user_bot(id) )
server_cmd("kick #%d", get_user_userid(id) )
else
client_cmd(id,"echo ^"There are no available slots left!
^";disconnect")
return PLUGIN_HANDLED // block connect in other plugins (especially in
consgreet)
}
return PLUGIN_CONTINUE
}
kickLag() {
new who = 0, ping, loss, worst = -1
new maxplayers = get_maxplayers()
for(new i = 1; i <= maxplayers; ++i) {
if ( !is_user_connected(i) && !is_user_connecting(i) )
continue // not used slot
if (get_user_flags(i)& is_user_LAN(i))
continue // has reservation, skip him
get_user_ping(i,ping,loss) // get ping
if ( ping > worst ) {
worst = ping
who = i
}
}
if(who)
if ( is_user_bot(who) )
server_cmd("kick #%d", get_user_userid(who) )
else
client_cmd(who,"echo ^"Dropped due to high ping to free slot
for LAN users^";disconnect")
return who
}
kickFresh() {
new who = 0, itime, shortest = 0x7fffffff
new maxplayers = get_maxplayers()
for(new i = 1; i <= maxplayers; ++i){
if ( !is_user_connected(i) && !is_user_connecting(i) )
continue // not used slot
if (get_user_flags(i)& is_user_LAN(i))
continue // has reservation, skip him
itime = get_user_time(i) // get user playing time with connection
duration
if ( shortest > itime ) {
shortest = itime
who = i
}
}
if(who)
if ( is_user_bot(who) )
server_cmd("kick #%d", get_user_userid(who) )
else
client_cmd(who,"echo ^"There are no available slots left!
^";disconnect")
return who
}
// see if this player is a member of the LAN
public bool:is_user_LAN(id) {
new ip[32];
get_user_ip(id,ip,31,0);
new line, text[64], txtlen;
while( (line = read_file(FILENAME,line,text,63,txtlen)) != 0 ) {
trim(text);
if( equali(ip,text,strlen(text)) ) {
return true;
}
}
return false;
}
server command line +maxplayer 26 ,and restart server the maxvisibleplayer is 25, full is 25/25 !
LAN users can't join when server is 25/25 !
something wrong ? :(
pls test it !
//slots_reservation --f117bomb ;
//ilovelan --Avalanche;
////////////////////////////////////
//
//Cvar:
//* amx_reservation <value>
//* 1 - Kicks the Player with shortest playing time when a LAN user connects to a full server.
//* 2 - Kick the Player with the highest ping when a LAN user connects to a full server.
//
//set a lan.ini file in addons/amxmodx/data/
//add LAN ips in lan.ini:
// 10.0
// 192.168
// 217.147.10
// 217.147.20
//
////////////////////////////////////
#include <amxmodx>
#include <amxmisc>
// filename of LAN ips
#define FILENAME "addons/amxmodx/data/lan.ini"
// Comment if you don't want to hide true max_players
#define HIDE_RESERVEDSLOTS
public plugin_init()
{
register_plugin("DoD Slot for LAN","0.1","")
register_cvar("amx_reservation","1")
#if defined HIDE_RESERVEDSLOTS
set_cvar_num( "sv_visiblemaxplayers" , get_maxplayers() - 1 )
#endif
}
public client_authorized(id) {
new maxplayers = get_maxplayers()
new players = get_playersnum( 1 )
new limit = maxplayers - 1
new resType = get_cvar_num( "amx_reservation" )
new who
if ( players > limit ) //21/20
{
if ( get_user_flags(id) & is_user_LAN(id) )
{
switch(resType) {
case 1:
who = kickFresh()
case 2:
who = kickLag()
}
if(who) {
new name[32]
get_user_name( who, name , 31 )
client_cmd(id,"echo ^"* %s was kicked for the LAN
users!^"" ,name )
}
return PLUGIN_CONTINUE
}
if ( is_user_bot(id) )
server_cmd("kick #%d", get_user_userid(id) )
else
client_cmd(id,"echo ^"There are no available slots left!
^";disconnect")
return PLUGIN_HANDLED // block connect in other plugins (especially in
consgreet)
}
return PLUGIN_CONTINUE
}
kickLag() {
new who = 0, ping, loss, worst = -1
new maxplayers = get_maxplayers()
for(new i = 1; i <= maxplayers; ++i) {
if ( !is_user_connected(i) && !is_user_connecting(i) )
continue // not used slot
if (get_user_flags(i)& is_user_LAN(i))
continue // has reservation, skip him
get_user_ping(i,ping,loss) // get ping
if ( ping > worst ) {
worst = ping
who = i
}
}
if(who)
if ( is_user_bot(who) )
server_cmd("kick #%d", get_user_userid(who) )
else
client_cmd(who,"echo ^"Dropped due to high ping to free slot
for LAN users^";disconnect")
return who
}
kickFresh() {
new who = 0, itime, shortest = 0x7fffffff
new maxplayers = get_maxplayers()
for(new i = 1; i <= maxplayers; ++i){
if ( !is_user_connected(i) && !is_user_connecting(i) )
continue // not used slot
if (get_user_flags(i)& is_user_LAN(i))
continue // has reservation, skip him
itime = get_user_time(i) // get user playing time with connection
duration
if ( shortest > itime ) {
shortest = itime
who = i
}
}
if(who)
if ( is_user_bot(who) )
server_cmd("kick #%d", get_user_userid(who) )
else
client_cmd(who,"echo ^"There are no available slots left!
^";disconnect")
return who
}
// see if this player is a member of the LAN
public bool:is_user_LAN(id) {
new ip[32];
get_user_ip(id,ip,31,0);
new line, text[64], txtlen;
while( (line = read_file(FILENAME,line,text,63,txtlen)) != 0 ) {
trim(text);
if( equali(ip,text,strlen(text)) ) {
return true;
}
}
return false;
}
server command line +maxplayer 26 ,and restart server the maxvisibleplayer is 25, full is 25/25 !
LAN users can't join when server is 25/25 !
something wrong ? :(
pls test it !