Raised This Month: $ Target: $400
 0% 

Show IP plugin help


  
 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
Author Message
st0kata
Member
Join Date: Aug 2007
Old 12-26-2007 , 15:54   Show IP plugin help
Reply With Quote #1

This is my first plugin which shows the IPs of the players in the server and I can't continue working on it before I get what's wrong with this code :/ The idea is to read from an .ini file and if there's a line:
Code:
"stk" "1.2.3.4"
(in-game name of an admin and his/her ip)
and the admin is not with that nickname the plugin will show different IP than the real one. The problem is that it still shows my real IP when I test it. Hope I didn't make some terrible mistakes
PHP Code:
#include <amxmodx>
#include <amxmisc>

#define PLUGIN "Show IP"
#define VERSION "1.0"
#define AUTHOR "st0ka"

new admin_fake_ip[32]
new 
admin_real_ip[32]
new 
filename[256]

public 
plugin_init() 
{
    
register_plugin(PLUGINVERSIONAUTHOR)
    
register_concmd("amx_ips","cmd_showip",ADMIN_ALL,"Shows all users with their IP adresses")
    
get_configsdir(filename,255)
    
format(filename,255,"%s/show_ip.ini",filename)
}

public 
client_connect(id)
{
    new 
random1=random_num(128,160)
    new 
random2=random_num(25,250)
    
    new 
filepointer fopen(filename,"r")
    if(
filepointer)
    {
        new 
read_data[128],admin_ip[32],admin_name[32]
        new 
parsed_admin_ip[32],parsed_admin_name[32]
        while(
fgets(filepointer,readdata,127))
        {
            
parse(read_data,parsed_admin_ip,31,parsed_admin_name,31)
            
remove_quotes(parsed_admin_ip)
            
remove_quotes(parsed_admin_name)
            if(
is_user_admin(id))
            {
                
get_user_ip(id,admin_ip,31,0)
                
get_user_name(id,admin_name,31)
                if(
equal(parsed_admin_ip,admin_ip) && !equal(parsed_admin_name,admin_name))
                {
                    
format(admin_fake_ip,31,"84.43.%d.%d:27005",random1,random2)
                    
format(admin_real_ip,31,"%s",admin_ip)
                }
            }
        }
        
fclose(filepointer)
    }
}

public 
cmd_showip(id
{
    
console_print(id,"================ Users and IP Adresses =============")
    new 
date[32]
    
format_time(date,31,"%d/%m/%Y",-1)
    
console_print(id,"Current date - %s",date)
    new 
time[32]
    
format_time(time,31,"%H:%M",-1)
    
console_print(id,"Current time - %s",time)
    new 
players[32], name[32], ip[32], numids
    get_players
(playersnum
    for(new 
i=0;i<num;i++) 
    {
        
ids players[i]
        
get_user_ip(ids,ip,31,0)
        
get_user_name(ids,name,31
        if(!
is_user_admin(id))
        {
            if(
equal(ip,admin_real_ip))
            {
                
console_print(id,"%s     ->        %s"name,admin_fake_ip)
            }
            else
            {
                
console_print(id,"%s     ->        %s"name,ip)
            }
        }
        else
        {
            
console_print(id,"%s     ->        %s"name,ip)
        }
    }
    
console_print(id""
    
console_print(id"================ Users and IP Adresses =============")
    return 
PLUGIN_HANDLED 


Last edited by st0kata; 12-27-2007 at 10:37.
st0kata is offline
 



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 11:02.


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