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:
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(PLUGIN, VERSION, AUTHOR)
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], num, ids
get_players(players, num)
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
}