Raised This Month: $ Target: $400
 0% 

DoD slots for LAN


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
knife108
New Member
Join Date: Oct 2007
Old 10-12-2007 , 04:29   DoD slots for LAN
Reply With Quote #1

guys,i want to make the slots for LAN in Day of Defeat, it will kick the high ping player when a LAN user join the "full" server . but it doesn't work .pls help me.

codes based on xxAvalanchexx and f117bomb.

PHP Code:
#include <amxmodx>
 
 // filename of LAN ips
 #define FILENAME "addons/amxmodx/data/lan.ini"
 
 // load the battering ram!
 
public plugin_init() {
 
set_cvar_num("sv_maxvisibleplayers %i",get_maxplayers()-1);
 
 }
 
// zomg someone is connecting
 
public client_authorized(id) {
 
// full house and a LAN user is connecting
 
if(get_playersnum(1) == get_maxplayers() && is_user_LAN(id)) {
  new 
lagPlayer lag_player();
  if(
lagPlayer) {
   
server_cmd("kick #%i ^"Make room for the LAN users!
^
"",get_user_userid(lagPlayer));
   
checkSlots();
  }
  else {
   
server_cmd("kick #%i ^"There are no available slots left!
^
"",get_user_userid(id));
  }
 }
 else if(
get_playersnum(1) == get_maxplayers()) {
  
server_cmd("kick #%i ^"There are no available slots left!
^
"",get_user_userid(id));
 }
 else {
  
checkSlots();
 }
 }
 public 
client_disconnect(id) {
 
checkSlots();
 }
 public 
checkSlots() {
 if(
get_playersnum(1) == get_maxplayers()-1) {
  
set_cvar_num("sv_maxvisibleplayers %i",get_maxplayers());
 }
 else {
  
set_cvar_num("sv_maxvisibleplayers %i",get_maxplayers()-1);
 }
 }
 public 
lag_player() {
 new 
lagPlayer 0pinglosslag = -1
 
new maxplayers get_maxplayers()
 for(new 
1<= 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 lag ) {
   
lag ping
   lagPlayer 
i
  
}
 }
 if(
lagPlayer
  if ( 
is_user_bot(lagPlayer) ) 
   
server_cmd("kick #%d"get_user_userid(lagPlayer)  ) 
  else 
   
client_cmd(lagPlayer,"echo ^"Dropped due to high ping to free 
slot 
for LAN users^";disconnect")
 return 
lagPlayer  
 
}
// 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 
linetext[64], txtlen;
 while( (
line read_file(FILENAME,line,text,63,txtlen)) != ) {
  
trim(text);
  if( 
equali(ip,text,strlen(text)) ) {
   return 
true;
  }
 }
 return 
false;
 } 
knife108 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 16:03.


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