AlliedModders

AlliedModders (https://forums.alliedmods.net/index.php)
-   Scripting Help (https://forums.alliedmods.net/forumdisplay.php?f=11)
-   -   Help fixing this GeoIP plugin to allow bots and LAN address (https://forums.alliedmods.net/showthread.php?t=10087)

Kamikaze 02-08-2005 01:01

Help fixing this GeoIP plugin to allow bots and LAN address
 
Ok, I have this GEOIP plugin that's made by Eisbein, he refuses to fix this problem so I tried fixing it myself but I can't get it to work. What happens is this plugin will display what country your from and when I connect to my server on the LAN, it will show ERROR for me since I have a LAN IP, all bots on CS/CZ will show the same thing so I wanted to know if it's possible to make it show BOT for BOTs and show LAN for addresses in the 192.168.0.0-192.168.255.255/10.0.0.0-10.255.255.255 ranges. I know this is mainly because of the GEOIP module not understanding Bots or LANs but how do I make it so this plugin will do that check, everything I've tried hasn't worked for me.

Here's the plugin without any changes made to it:

Code:
/* * AMX MODX SCRIPT * * show land / Country in Spect * * by Eisbein >>[email protected] * use / benutze say /country or /land * * mfG PAPA_SCHLUMPF */ #include <amxmodx> #include <geoip> new playerip[17], getcountry[46], country[33][46] public plugin_init() {   register_plugin("Land","1.0","Eisbein")   register_event("StatusValue","show_country","bd","1=2")   register_clcmd("say /country","show_owncountry")   register_clcmd("say /land","show_owncountry")   register_cvar("amx_showcountry","1") } public client_connect(id) {   if (!(get_cvar_num("amx_showcountry")))   {     return PLUGIN_CONTINUE   }   get_user_ip(id, playerip, 16, 1)   geoip_country(playerip,getcountry)   country[id] = getcountry   return PLUGIN_CONTINUE } public show_country(id) {   if (!(get_cvar_num("amx_showcountry")))   {     return PLUGIN_CONTINUE   }   new target = read_data(2)   if (target != id && target != 0)   {     set_hudmessage(0, 255, 255, -1.0, 0.35, 0, 6.0, 6.0, 0.5, 0.15, 27)     show_hudmessage(id,"%s",country[target])   }   return PLUGIN_CONTINUE } public show_owncountry(id) {   client_print(id,print_chat,"%s",country[id])   return PLUGIN_HANDLED }

PM 02-08-2005 06:57

Try something like this:
Code:
/* * AMX MODX SCRIPT * * show land / Country in Spect * * by Eisbein >>[email protected] * use / benutze say /country or /land * * mfG PAPA_SCHLUMPF */ #include <amxmodx> #include <geoip> is_ip_internal(ip[]) {   // Now, we parse it:   new segoff[3];   new curseg = 0;   for (new i = 0; i < 15; ++i)   {     if (!ip[i])       break;     if (ip[i] == '.')     {       ip[i] = 0;   // Set to 0 so str_to_num will work later       segoff[curseg++] = i + 1;       if (curseg == 3)         break;       continue;     }   }   new seg[4];   seg[0] = str_to_num(ip);   seg[1] = str_to_num(ip[ segoff[0] ]);   seg[2] = str_to_num(ip[ segoff[1] ]);   seg[3] = str_to_num(ip[ segoff[2] ]);     // Check whether it's in range   if (seg[0] == 10)     return 1;   if (seg[0] == 192 && seg[1] == 168)     return 1;   if (seg[0] == 172 && seg[1] >= 16 && seg[1] <= 31)     return 1;       // Also allow loopback   if (seg[0] == 127 && seg[1] == 0 && seg[2] == 0 && seg[3] == 1)      return 1;   if (equal(ip, "loopback"))     return 1;     return 0; } new playerip[17], getcountry[46], country[33][46] public plugin_init() {   register_plugin("Land","1.0","Eisbein")   register_event("StatusValue","show_country","bd","1=2")   register_clcmd("say /country","show_owncountry")   register_clcmd("say /land","show_owncountry")   register_cvar("amx_showcountry","1") } public client_connect(id) {   if (!(get_cvar_num("amx_showcountry")))   {     return PLUGIN_CONTINUE   }   get_user_ip(id, playerip, 16, 1)   if (is_ip_internal(playerip))     copy(country[id], 45, "LAN")   else   {     geoip_country(playerip,getcountry)     copy(country[id], 45, getcountry)   }   return PLUGIN_CONTINUE } public show_country(id) {   if (!(get_cvar_num("amx_showcountry")))   {     return PLUGIN_CONTINUE   }   new target = read_data(2)   if (target != id && target != 0)   {     set_hudmessage(0, 255, 255, -1.0, 0.35, 0, 6.0, 6.0, 0.5, 0.15, 27)     show_hudmessage(id,"%s",country[target])   }   return PLUGIN_CONTINUE } public show_owncountry(id) {   client_print(id,print_chat,"%s",country[id])   return PLUGIN_HANDLED }

(I've taken is_ip_internal from one of my previous posts)

Kamikaze 02-08-2005 19:52

Ok now it recognizes LAN addresses but it now doesn't work with anyone else that's not on the LAN (all the internet players).


All times are GMT -4. The time now is 19:18.

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