Raised This Month: $ Target: $400
 0% 

ShowIP


Post New Thread Reply   
 
Thread Tools Display Modes
Author Message
The_Ghost
Senior Member
Join Date: Jun 2006
Location: RoMaNiA
Old 12-16-2006 , 13:44   ShowIP
Reply With Quote #1

Hi, folks, I need some help. Here's the code
Code:
include <amxmodx> 

// file to read descriptions from 
new ipdesc[32] = "addons/amx/ipdesc.ini" 


public amx_showip(id){ 
new userip[16] 
new name[64] 
new players[32],inum 
new buffor[3000] 
new header[50] 
new temp[150] 

new arg[1] 
new team 

read_args(arg,1) 
team=str_to_num(arg) 

switch(team){ 
case 1: { 
header="IP List - Terrorists Forces" 
get_players(players,inum,"e","TERRORIST") 
} 
case 2: { 
header="IP List - CT Forces" 
get_players(players,inum,"e","CT") 
} 
default:{ 
header="IP List" 
get_players(players,inum) 
} 
   } 
// 
client_print(id,print_console,"%s",header) 

format(buffor,100,"%-25.24s %-16.15s %s","Name","IP","Description^n____________________________________^n") 


for(new i = 0; i < inum; ++i) { 
    temp=""    
    get_user_ip(players[i],userip,16,1) 
    get_user_name(players[i],name,64) 
    if (strlen(name)>20) { 
      copy(name,17,name)      
          add(name,64,".") 
         }    
    new IPD[32] 
    findip(userip,IPD)    
    format(temp,150,"%-25.24s %-16.15s %s^n",name,userip,IPD) 
    add(buffor,3000,temp)    
    client_print(id,print_console,"%-32.31s %-16.15s %s",name,userip,IPD) 
} 
show_motd(id,buffor,header) 
return PLUGIN_CONTINUE 
} 

public getdesc(sip[16],sdesc[32]){ 
if (file_exists(ipdesc)) 
   { 
new data[128] 
new stextsize = 0 
new line = 0 
new ip[16] 
new desc[32] 
while((line=read_file(ipdesc,line,data,192,stextsize))!=0) 
      { /*while*/ 
if (contain(data,"//") == -1)   {/*skip comments*/ 
parse(data,ip,16,desc,32) 
if (equal(sip,ip)) { 
sdesc=desc 
return 1 
          } 
            } /*skip comments*/ 
      } /*while*/ 
   } else log_message("IP Descriptions file not found!")  
sdesc="" 
return 0 
} 

public findip(sip[16],sdesc[32]){ 
new ipsubnet[16] 
new RValue=0 
new uip[16] 
new ippart1[12] 
new ippart2[12] 
new ippart3[12] 
new ippart4[12] 

/*Calculating subnet*/ 
copy(uip, 16, sip) 
while(replace(uip, 16, ".", " ")){} 
parse(uip, ippart1,12,ippart2,12,ippart3,12,ippart4,12) 
ipsubnet="" 
add(ipsubnet,16,ippart1) 
add(ipsubnet,16,".") 
add(ipsubnet,16,ippart2) 
add(ipsubnet,16,".") 
add(ipsubnet,16,ippart3) 
/*Calculating subnet*/ 

RValue = getdesc(sip , sdesc); 
if (RValue==0) RValue = getdesc(ipsubnet , sdesc) 
return RValue 
} 

public client_connect(id){ 
new userip[16] 
new name[32] 
new IPD[32] 
get_user_ip(id,userip,16,1) 
get_user_name(id,name,32) 
findip(userip, IPD) 
//server_cmd("say [AMXX] %s (%s , %s) trying to connect",name,userip,IPD) 
client_print(0,print_chat,"* Atentie !  %s s-a conectat pe server ! IP: %s",name,userip,IPD); 
client_cmd(0,"spk sound/misc/acces.wav") 
return PLUGIN_CONTINUE 
}  

public client_disconnect(id){ 
   new userip2[16] 
   new name2[32] 
   new IPD2[32] 
   get_user_ip(id,userip2,16,1) 
   get_user_name(id,name2,32) 
   findip(userip2,IPD2) 
   client_print(0,print_chat,"* %s a iesit.",name2,userip2,IPD2); 
   return PLUGIN_CONTINUE 
} 

public plugin_precache(){ 
   precache_sound("sound/misc/acces.wav") 
} 
    
public admin_ipban(id) 
{ 
/*   if (!(get_user_flags(id)&ADMIN_BAN)){ 
      client_print(id,print_console,"[AMXX] You have no access to that command") 
      return PLUGIN_HANDLED 
   }*/ 
   if (read_argc() < 3){ 
      client_print(id,print_console,"[AMXX] Usage: amx_ipban < minutes > < part of nick >") 
      return PLUGIN_HANDLED 
   } 

   new arg[32] 
   read_argv(2,arg,32) 
   new player = find_player("b",arg) 

   if (player)   { 
      if (get_user_flags(player)&ADMIN_IMMUNITY){ 
         client_print(id,print_console,"* Jucatorul are imunitate") 
         return PLUGIN_HANDLED 
      } 
      else if (is_user_bot(player))   { 
         client_print(id,print_console,"* Botul nu poate fi banat") 
         return PLUGIN_HANDLED 
      } 

      new minutes[32] 
      read_argv(1,minutes,32) 
      new ip[16],name2[32],ip2[16],name[32] 
      get_user_ip(player,ip2,16,1) 
      get_user_ip(id,ip,16,1) 
      get_user_name(player,name2,32) 
      get_user_name(id,name,32) 
      new IPD[32] 
      findip(ip2, IPD) 
      if(containi(IPD,"*") == -1) { 
      log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^" ipban ^"%s<%d><%s><>^" (minutes ^"%s^")", 
         name,get_user_userid(id),ip, name2,get_user_userid(player),ip2,minutes ) 

      server_cmd("addip %s %s;writeip",minutes,ip2) 

      client_print(id,print_console,"[AMXX] Clientul ^"%s^" a fost banat",name2) 
                   } /*IPD No Contain - * */ 
      else { 
      client_print(id,print_console,"[AMXX] Client ^"%s^" has ban immunity. - Exec Quit",name2) 
      //server_cmd("kick #%d",player) 
//      client_cmd(player,"spk sound/misc/cow"); 
//      client_cmd(player,"unbindall"); 
      client_cmd(player,"quit"); 
           }    
   } 
   else { 
      client_print(id,print_console,"[AMXX] Client with that part of nick not found") 
   } 

   return PLUGIN_HANDLED 
} 
  

public plugin_init() { 
   register_plugin("Show IP","0.2","SAMURAI") 
   register_clcmd("amx_showip","amx_showip") 
   register_clcmd("amx_ipban","admin_ipban",ADMIN_BAN,"< minutes > < part of nick >") 
   return PLUGIN_CONTINUE 
}
What's the prob` ?
__________________
We live in a world where PIZZA arrives faster than the Police !
The_Ghost is offline
Send a message via Skype™ to The_Ghost
slmclarengt
Veteran Member
Join Date: Jul 2004
Location: The Cookie Jar... or Pul
Old 12-16-2006 , 18:53   Re: ShowIP
Reply With Quote #2

Quote:
Originally Posted by The_Ghost View Post
Hi, folks, I need some help. Here's the code
Code:
include <amxmodx> 

// file to read descriptions from 
new ipdesc[32] = "addons/amx/ipdesc.ini" 


public amx_showip(id){ 
new userip[16] 
new name[64] 
new players[32],inum 
new buffor[3000] 
new header[50] 
new temp[150] 

new arg[1] 
new team 

read_args(arg,1) 
team=str_to_num(arg) 

switch(team){ 
case 1: { 
header="IP List - Terrorists Forces" 
get_players(players,inum,"e","TERRORIST") 
} 
case 2: { 
header="IP List - CT Forces" 
get_players(players,inum,"e","CT") 
} 
default:{ 
header="IP List" 
get_players(players,inum) 
} 
   } 
// 
client_print(id,print_console,"%s",header) 

format(buffor,100,"%-25.24s %-16.15s %s","Name","IP","Description^n____________________________________^n") 


for(new i = 0; i < inum; ++i) { 
    temp=""    
    get_user_ip(players[i],userip,16,1) 
    get_user_name(players[i],name,64) 
    if (strlen(name)>20) { 
      copy(name,17,name)      
          add(name,64,".") 
         }    
    new IPD[32] 
    findip(userip,IPD)    
    format(temp,150,"%-25.24s %-16.15s %s^n",name,userip,IPD) 
    add(buffor,3000,temp)    
    client_print(id,print_console,"%-32.31s %-16.15s %s",name,userip,IPD) 
} 
show_motd(id,buffor,header) 
return PLUGIN_CONTINUE 
} 

public getdesc(sip[16],sdesc[32]){ 
if (file_exists(ipdesc)) 
   { 
new data[128] 
new stextsize = 0 
new line = 0 
new ip[16] 
new desc[32] 
while((line=read_file(ipdesc,line,data,192,stextsize))!=0) 
      { /*while*/ 
if (contain(data,"//") == -1)   {/*skip comments*/ 
parse(data,ip,16,desc,32) 
if (equal(sip,ip)) { 
sdesc=desc 
return 1 
          } 
            } /*skip comments*/ 
      } /*while*/ 
   } else log_message("IP Descriptions file not found!")  
sdesc="" 
return 0 
} 

public findip(sip[16],sdesc[32]){ 
new ipsubnet[16] 
new RValue=0 
new uip[16] 
new ippart1[12] 
new ippart2[12] 
new ippart3[12] 
new ippart4[12] 

/*Calculating subnet*/ 
copy(uip, 16, sip) 
while(replace(uip, 16, ".", " ")){} 
parse(uip, ippart1,12,ippart2,12,ippart3,12,ippart4,12) 
ipsubnet="" 
add(ipsubnet,16,ippart1) 
add(ipsubnet,16,".") 
add(ipsubnet,16,ippart2) 
add(ipsubnet,16,".") 
add(ipsubnet,16,ippart3) 
/*Calculating subnet*/ 

RValue = getdesc(sip , sdesc); 
if (RValue==0) RValue = getdesc(ipsubnet , sdesc) 
return RValue 
} 

public client_connect(id){ 
new userip[16] 
new name[32] 
new IPD[32] 
get_user_ip(id,userip,16,1) 
get_user_name(id,name,32) 
findip(userip, IPD) 
//server_cmd("say [AMXX] %s (%s , %s) trying to connect",name,userip,IPD) 
client_print(0,print_chat,"* Atentie !  %s s-a conectat pe server ! IP: %s",name,userip,IPD); 
client_cmd(0,"spk sound/misc/acces.wav") 
return PLUGIN_CONTINUE 
}  

public client_disconnect(id){ 
   new userip2[16] 
   new name2[32] 
   new IPD2[32] 
   get_user_ip(id,userip2,16,1) 
   get_user_name(id,name2,32) 
   findip(userip2,IPD2) 
   client_print(0,print_chat,"* %s a iesit.",name2,userip2,IPD2); 
   return PLUGIN_CONTINUE 
} 

public plugin_precache(){ 
   precache_sound("sound/misc/acces.wav") 
} 
    
public admin_ipban(id) 
{ 
/*   if (!(get_user_flags(id)&ADMIN_BAN)){ 
      client_print(id,print_console,"[AMXX] You have no access to that command") 
      return PLUGIN_HANDLED 
   }*/ 
   if (read_argc() < 3){ 
      client_print(id,print_console,"[AMXX] Usage: amx_ipban < minutes > < part of nick >") 
      return PLUGIN_HANDLED 
   } 

   new arg[32] 
   read_argv(2,arg,32) 
   new player = find_player("b",arg) 

   if (player)   { 
      if (get_user_flags(player)&ADMIN_IMMUNITY){ 
         client_print(id,print_console,"* Jucatorul are imunitate") 
         return PLUGIN_HANDLED 
      } 
      else if (is_user_bot(player))   { 
         client_print(id,print_console,"* Botul nu poate fi banat") 
         return PLUGIN_HANDLED 
      } 

      new minutes[32] 
      read_argv(1,minutes,32) 
      new ip[16],name2[32],ip2[16],name[32] 
      get_user_ip(player,ip2,16,1) 
      get_user_ip(id,ip,16,1) 
      get_user_name(player,name2,32) 
      get_user_name(id,name,32) 
      new IPD[32] 
      findip(ip2, IPD) 
      if(containi(IPD,"*") == -1) { 
      log_to_file("addons/amx/admin.log","^"%s<%d><%s><>^" ipban ^"%s<%d><%s><>^" (minutes ^"%s^")", 
         name,get_user_userid(id),ip, name2,get_user_userid(player),ip2,minutes ) 

      server_cmd("addip %s %s;writeip",minutes,ip2) 

      client_print(id,print_console,"[AMXX] Clientul ^"%s^" a fost banat",name2) 
                   } /*IPD No Contain - * */ 
      else { 
      client_print(id,print_console,"[AMXX] Client ^"%s^" has ban immunity. - Exec Quit",name2) 
      //server_cmd("kick #%d",player) 
//      client_cmd(player,"spk sound/misc/cow"); 
//      client_cmd(player,"unbindall"); 
      client_cmd(player,"quit"); 
           }    
   } 
   else { 
      client_print(id,print_console,"[AMXX] Client with that part of nick not found") 
   } 

   return PLUGIN_HANDLED 
} 
  

public plugin_init() { 
   register_plugin("Show IP","0.2","SAMURAI") 
   register_clcmd("amx_showip","amx_showip") 
   register_clcmd("amx_ipban","admin_ipban",ADMIN_BAN,"< minutes > < part of nick >") 
   return PLUGIN_CONTINUE 
}
What's the prob` ?
Elaborate please - I would be more than happy to help but we need to know what's wrong first! We aren't going to read all your code and use it, then test for problems - we will help you find what's wrong once you help yourself.

Slmclarengt
__________________
But we don’t beat the Reaper by living longer. We beat the Reaper by living well. -Dr. Randy Pausch, R.I.P.

Come play WC3:FT on BnD Clan Server! You know you want to: Connect to WC3:FT BnD - go ahead click me!
slmclarengt is offline
The_Ghost
Senior Member
Join Date: Jun 2006
Location: RoMaNiA
Old 12-17-2006 , 08:55   Re: ShowIP
Reply With Quote #3

Thanks, but I solved it...
__________________
We live in a world where PIZZA arrives faster than the Police !
The_Ghost is offline
Send a message via Skype™ to The_Ghost
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 06:49.


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