Day of Defeat Plugins Community
This site is an archive — everything is readable and downloadable, nothing can be posted. Admin
Archive › Old Forum Threads › Help › Scripting Help › DoD LAN Priority
7 posts, 2 people · 792 views Thread Rating: ★★★★★
closedDoD LAN Priority
Started by knife108 on 10-11-2007, 01:50 AM
K knife108
started this thread
Posts: 108
Threads: 10
Joined: Apr 2006
10-11-2007, 01:50 AM #1
rn//based on:rn//slots_reservation   --f117bomb ;rn//ilovelan                --Avalanche;rnrn////////////////////////////////////rn// rn//Cvar: rn//* amx_reservation <value> rn//* 1 - Kicks the Player with shortest playing time when a LAN user connects to a full server.rn//* 2 - Kick the Player with the highest ping when a LAN user connects to a full server. rn// rn//set a lan.ini file in addons/amxmodx/data/rnrn//add LAN ips in lan.ini:rn//    10.0rn//    192.168rn//    217.147.10rn//    217.147.20rn//rn////////////////////////////////////rnrnrn#include <amxmodx>rn#include <amxmisc> rnrnrnrn // filename of LAN ipsrn #define FILENAME "addons/amxmodx/data/lan.ini"rnrnrn// Comment if you don't want to hide true max_players  rn#define HIDE_RESERVEDSLOTS rnrnpublic plugin_init() rn{ rn	register_plugin("DoD Slot for LAN","0.1","") rn	register_cvar("amx_reservation","1") rn	rn	#if defined HIDE_RESERVEDSLOTS rn	set_cvar_num( "sv_visiblemaxplayers" , get_maxplayers() - 1 ) rn	#endif rn	rn} rnrnpublic client_authorized(id) {rnrn	new maxplayers = get_maxplayers()rn	new players = get_playersnum( 1 ) rn	new limit = maxplayers - 1rn	new resType = get_cvar_num( "amx_reservation" ) rn	new whorn	rn	if ( players > limit ) //21/20rn	{ rn		if ( get_user_flags(id) & is_user_LAN(id) ) rn		{ rn			switch(resType) {     rn				case 1: rn					who = kickFresh()rn				case 2: rn					who = kickLag()rn			}rn			if(who)  {rn				new name[32]rn   				get_user_name( who, name , 31 )rn   				client_cmd(id,"echo ^"* %s was kicked for the LAN rnrnusers!^"" ,name )rn   			}rn			return PLUGIN_CONTINUE rn		} rnrn		if ( is_user_bot(id) ) rn			server_cmd("kick #%d", get_user_userid(id)  ) rn		else rn			client_cmd(id,"echo ^"There are no available slots left!rnrn^";disconnect")rn			rn		return PLUGIN_HANDLED // block connect in other plugins (especially in rnrnconsgreet)	 rn	} rn	return PLUGIN_CONTINUE rn} rnrnrnkickLag() {rn	new who = 0, ping, loss, worst = -1rn	new maxplayers = get_maxplayers()rn	for(new i = 1; i <= maxplayers; ++i) {rn		if ( !is_user_connected(i) && !is_user_connecting(i) ) rn			continue // not used slot  rn		if (get_user_flags(i)& is_user_LAN(i)) rn			continue // has reservation, skip himrn		get_user_ping(i,ping,loss) // get pingrn		if ( ping > worst ) {rn			worst = pingrn			who = irn		}rn	}rn	if(who) rn		if ( is_user_bot(who) ) rn			server_cmd("kick #%d", get_user_userid(who)  ) rn		else rn			client_cmd(who,"echo ^"Dropped due to high ping to free slot rnrnfor LAN users^";disconnect")rn	return who  rnrn }rnrnkickFresh() {rn	new who = 0, itime, shortest = 0x7fffffffrn	new maxplayers = get_maxplayers()rn	for(new i = 1; i <= maxplayers; ++i){rn		if ( !is_user_connected(i) && !is_user_connecting(i) )rn			continue // not used slotrn		if (get_user_flags(i)& is_user_LAN(i))rn			continue // has reservation, skip himrn		itime = get_user_time(i) // get user playing time with connection rnrnduration  rn		if ( shortest > itime ) {rn			shortest = itimern			who = irn		}rn	}rn	if(who) rn		if ( is_user_bot(who) ) rn			server_cmd("kick #%d", get_user_userid(who)  ) rn		else rn			client_cmd(who,"echo ^"There are no available slots left!rnrn^";disconnect")rn	return whorn}rnrn // see if this player is a member of the LANrn public bool:is_user_LAN(id) {rnrn	new ip[32];rn	get_user_ip(id,ip,31,0);rnrn	new line, text[64], txtlen;rn	while( (line = read_file(FILENAME,line,text,63,txtlen)) != 0 ) {rn		trim(text);rnrn		if( equali(ip,text,strlen(text)) ) {rn			return true;rn		}rn	}rnrn	return false;rn }
rnrnrnrnserver command line +maxplayer 26 ,and restart server the maxvisibleplayer is 25, full is 25/25 !rnrnLAN users can't join when server is 25/25 !rnrnsomething wrong ? :( rnrnpls test it !

FeuerSturm
posted here
Posts: 166
Threads: 15
Joined: Jun 2007
10-12-2007, 01:42 AM #2

if you hide the reserved slot players can't connect through the server browserrnwhen the server is "full", so the LAN players would either connect throughrnconsole (connect xxx.xxx.xxx.xxx:xxxxx) or you have to unhide the reservedrnslot to let players connect via steam server browser.

K knife108
started this thread
Posts: 108
Threads: 10
Joined: Apr 2006
10-12-2007, 02:53 AM #3

i had commented this line rn

rnrn//#define HIDE_RESERVEDSLOTS rnrn
rnrnrestart server sv_maxvisibleplayers = "-1" ? rnrnif hide reserved slots sv_maxvisibleplayers = 25rnrnwhen no LAN users join server,it will "full" at 25/26, but it shows 26/26,i mean server did not kick the 26th player! rnrndoes any problem with the codes ?

FeuerSturm
posted here
Posts: 166
Threads: 15
Joined: Jun 2007
10-12-2007, 12:03 PM #4

i looked through the code quickly and i have to say there's a lot of stuffrnin it that "might" work and a lot of stuff that won't work.rnrni wouldn't use that plugin at all, i would suggest to use my "DoD AdminSlots v0.7"rnand setup all the LAN IPs in users.ini like that:rnrn

"XXX.XXX.XXX.XXX" "" "b" "de"
rnrnthe flag "b" is the reserved slot, after that it should work.rnrnbesides the fact that the plugin is "crap" that you posted, it's not DoDrnspecific at all.rnrnUse DoD AdminSlots and you won't have a problem anymore!

K knife108
started this thread
Posts: 108
Threads: 10
Joined: Apr 2006
10-12-2007, 12:12 PM #5
i looked through the code quickly and i have to say there's a lot of stuffrnin it that "might" work and a lot of stuff that won't work.rnrni wouldn't use that plugin at all, i would suggest to use my "DoD AdminSlots v0.7"rnand setup all the LAN IPs in users.ini like that:rnrn
"XXX.XXX.XXX.XXX" "" "b" "de"
rnrnthe flag "b" is the reserved slot, after that it should work.rnrnbesides the fact that the plugin is "crap" that you posted, it's not DoDrnspecific at all.rnrnUse DoD AdminSlots and you won't have a problem anymore!
rnrnthx buddy !rnrni would do all u said and if i hide the slots , does the LAN users in users.ini can join the server via steam browser ?

FeuerSturm
posted here
Posts: 166
Threads: 15
Joined: Jun 2007
10-12-2007, 12:22 PM #6

if the slot is hidden, the steam browser thinks the server is full, there'srnno way to get around not hidding it.

K knife108
started this thread
Posts: 108
Threads: 10
Joined: Apr 2006
10-12-2007, 10:08 PM #7

i added no any admin user only LAN ips to user.ini file like

"XXX.XXX.XXX.XXX" "" "b" "de"
rnrnshould i setup the amx_password_field "1234" for them ,i mean the client also need add setinfo "1234" to config.cfg ?

Archive › Old Forum Threads › Help › Scripting Help › DoD LAN Priority
DoD Plugins Archive · Repository · Old Forum Threads · Maps · Admin · built 14 Sep 2026 00:34 UTC