/* 
Black Knight's Password Remover v1.0 
*/ 
 
#include <core> 
#include <string> 
#include <admin> 
#include <adminlib> 
 
new AM_VERSION_STRING[] = "1.0"; 
new seconds=600; 
new passcmd[MAX_TEXT_LENGTH]="admin_nopass"; 
new datacmd[MAX_TEXT_LENGTH]=""; 
new spasswd[MAX_TEXT_LENGTH]="none"; 
new spasswd2[MAX_TEXT_LENGTH]=""; 
new timerid=0; 
 
public plugin_connect(HLUserName, HLIP, UserIndex) { 
   if (UserIndex >= 1 && UserIndex <= MAX_PLAYERS && timerid!=0) { 
      kill_timer(timerid); 
      timerid=0; 
   } 
   return PLUGIN_CONTINUE; 
} 
 
public plugin_disconnect(HLUserName, UserIndex) { 
   if (UserIndex >= 1 && UserIndex <= MAX_PLAYERS) { 
      set_timer("start_check_empty",10,0); 
   } 
   return PLUGIN_CONTINUE; 
} 
 
public reset_password(Timer,Repeat,HLUserName,HLParam){ 
   plugin_exec(passcmd,datacmd); 
   exec("exec server.cfg"); 
   return PLUGIN_CONTINUE; 
} 
 
start_counter(){ 
   new apasswd[MAX_NAME_LENGTH]; 
   getstrvar("sv_password",apasswd,MAX_NAME_LENGTH); 
   if (streq(apasswd,spasswd)==0 && streq(apasswd,spasswd2)==0){ 
      timerid=set_timer("reset_password",seconds,0); 
   } 
   return PLUGIN_CONTINUE; 
} 
 
public start_check_empty(Timer,Repeat,HLUserName,HLParam){ 
   new maxplayer=playercount(); 
   if (maxplayer==0) { 
      start_counter(); 
   } 
   return PLUGIN_CONTINUE; 
} 
 
public plugin_init() { 
   plugin_registerinfo("Black Knights Password Remover","Removes password, if server is empty for some time.",AM_VERSION_STRING); 
   set_timer("start_check_empty",10,0);    
   return PLUGIN_CONTINUE; 
}