Wulf submitted a new resource:
GeoIP - Provides a geographic information API for IP addresses
Read more about this resource...
GeoIP [Unmaintained]
Discussion in 'Plugin Support' started by Wulf, Oct 3, 2015.
-
Wulf Community Admin
-
Wulf Community Admin
-
@Wulf perfect for Notifications
Thanks. Makes stuff easier for me.
-
GREAT !! Can you update the Country Block for Rust Experimental | Oxide to use this?
-
Wulf Community Admin
-
Im not sure but, the debug is still true @Wulf
I will take a look at this and perhaps add support to Notifier. -
Wulf Community Admin
-
Wulf Community Admin
-
Hey wulf,
I have setup this piece of code here, which is fairly easy for any programmer to understand really:
Code:# Is GeoIP loaded? if GeoIP: # Player UID and IP uid = self.playerid(player) pip = self.players[uid]['ip'].split(':')[0] # Cache Player Country And Country Code self.players[uid]['country'] = GeoIP.Call('GetCountry', pip) self.players[uid]['country_short'] = GeoIP.Call('GetCountryCode', pip) # Debug Messages print('GeoIP: %s' % 'Loaded' if GeoIP else 'Not Loaded') print('Player ID: ' + uid) print('Player IP: ' + pip) print('Player Country: %s' % self.players[uid]['country']) print('Player Country Code: %s' % self.players[uid]['country_short']) print(GeoIP.Call('GetCountry', pip)) print(GeoIP.Call('GetCountryCode', pip))
Code:[Oxide] 8:01 AM [Info] GeoIP: Loaded [Oxide] 8:01 AM [Info] Player ID: 76561197999302614 [Oxide] 8:01 AM [Info] Player IP: 188.82.58.52 [Oxide] 8:01 AM [Info] Player Country: None [Oxide] 8:01 AM [Info] Player Country Code: None [Oxide] 8:01 AM [Info] None [Oxide] 8:01 AM [Info] None
Am I doing something wrong or is this some sort of connection issue? ...Your code maybe?
P.S: Either .Call() or CallHook() return the same -
Wulf Community Admin
-
Yes I do sir, both full of data.
-
Wulf Community Admin
-
@Wulf I got an issues with this right now. I've sent you a message.
Code:string country = "Unknown"; var geoIP = plugins.Find("GeoIP"); if(geoIP) country = geoIP?.Call("GetCountryCode", player.net.connection.ipaddress).ToString(); else Puts("GeoIP is not loaded!");
Nevermind. It propably is because its my local server so the ip is localhost...Last edited by a moderator: Oct 8, 2015 -
Wulf Community Admin
-
-
Wulf Community Admin
-
Code:void OnPlayerInit(BasePlayer player) { var geoIP = plugins.Find("GeoIP"); string country = geoIP ? geoIP.Call("GetCountryCode", player.net.connection.ipaddress).ToString() : "Unknown"; if(player.net.connection.ipaddress.Contains("127.0.0.1:")) country = "Local"; NextTick(() => { // Send Welcome Message if((bool)Config["Settings", "Enable Welcome Message"]) { List<object> msgObject = Config["Messages", "Welcome"] as List<object>; List<string> messages = new List<string>(); foreach(string curMsg in msgObject) messages.Add(curMsg); string name = GetFormattedName(player); string msg = ListToString(messages, 0, "\n").ToString().Replace("{player}", name); msg = ReplaceTags(msg); msg = $"<color={Config["Colors", "Welcome"].ToString()}>{msg}</color>"; SendChatMessage(player, msg); } // Broadcast Join Message if((bool)Config["Settings", "Enable Join Message"]) { string name = GetFormattedName(player); string msg = Config["Messages", "Join"].ToString().Replace("{player}", name).Replace("{country}", country); BroadcastChat($"<color={Config["Colors", "Join"].ToString()}>{msg}</color>"); SendConsole(msg); } }); }
-
Wulf Community Admin
-
-
Wulf Community Admin