Hello
Can someone give me download link and tell me how to install geoip module for garrys mod 13 server?
E:using linux vps
[url]http://www.facepunch.com/showthread.php?t=969950[/url]
Linux version:
[QUOTE=kna_rus;23358208]Linux version here:
Binary: [url]http://dl.dropbox.com/u/3679614/gm_geoloc_linux.dll[/url]
Sources:
gm_geoloc.cpp
[code]#include "GMLuaModule.h"
#ifdef _LINUX
#include "GeoIP.h"
#include "GeoIPCity.h"
#else
#include "libgeoip/GeoIP.h"
#include "libgeoip/GeoIPCity.h"
#endif
namespace IPLoc {
GeoIP * giCity;
GeoIP * giISP;
GMOD_MODULE(Init, Shutdown);
LUA_FUNCTION(GetIPInfo)
{
Lua()->CheckType(1, GLua::TYPE_STRING);
const char *FindMe = Lua()->GetString(1);
GeoIPRecord *gir;
ILuaObject *tbl = Lua()->GetNewTable();
if (giCity!=NULL) {
gir = GeoIP_record_by_addr(giCity, FindMe);
if (gir != NULL) {
tbl->SetMember("City",gir->city);
tbl->SetMember("Country",gir->country_name);
tbl->SetMember("Region",gir->region);
#ifndef _LINUX
tbl->SetMember("CityCode",(float)gir->postal_code); //for some reason latest linux libgeoip-dev does not have this
#endif
if (giISP!=NULL) {
char* isp=GeoIP_org_by_name(giISP,FindMe);
if (isp != NULL) {
tbl->SetMember("ISP",isp);
}
}
GeoIPRecord_delete(gir);
}
}
Lua()->Push(tbl);
tbl->UnReference();
return 1;
}
int Init(lua_State *L)
{
giCity = GeoIP_open("garrysmod/data/GeoIP.dat", GEOIP_INDEX_CACHE);
giISP = GeoIP_open("garrysmod/data/GeoIPISP.dat", GEOIP_STANDARD);
ILuaObject *tbl = Lua()->GetNewTable();
tbl->SetMember("Get", GetIPInfo);
Lua()->SetGlobal("GeoIP", tbl);
tbl->UnReference();
return 0;
}
int Shutdown(lua_State *L)
{
//GeoIP_delete(giCountry);
GeoIP_delete(giCity);
GeoIP_delete(giISP);
return 0;
}
}[/code]
Makefile (64bit system, sorry, you have to get 32-bit libGeoIP.a somewhere or edit makefile):
[code]INCLUDES = -I.
CFLAGS = -m32 -fpermissive -Wall -DLINUX -D_LINUX -DNDEBUG $(INCLUDES)
MODE = Release
LIBDIR = output/$(MODE)
OBJDIR = $(LIBDIR)/obj
SOURCEDIR = .
OBJECTS = $(OBJDIR)/gm_geoloc.obj
LIBS = ./libGeoIP.a
CC = gcc
MKDIR = mkdir -p
AR = ar
RM = rm -f
RMDIR = rmdir -p
all: $(LIBDIR)/gm_geoloc_linux.dll
$(LIBDIR)/gm_geoloc_linux.dll: $(OBJECTS)
$(MKDIR) $(LIBDIR)
$(CC) -shared -o $@ $(CFLAGS) $(OBJECTS) $(LIBS)
$(OBJDIR)/%.obj : $(SOURCEDIR)/%.cpp
$(MKDIR) $(OBJDIR)
$(CC) -c -o $@ $< $(CFLAGS)
clean:
$(RM) $(OBJECTS)
$(RM) $(LIBDIR)/gm_geoloc_linux.dll
$(RMDIR) $(OBJDIR)[/code][/QUOTE]
but how do i exactly install it. i put the file in bin folder but that obviously didnt work
The module itself just provides lua functions. You need to write scripts that use said functions to do what you want. If you can't write lua scripts, then this module isn't meant for you.
[CODE]require("geoip")
hook.Add("PlayerInitialSpawn","ImRacistSoIKickWholeCountries", function(ply)
if !IsValid(ply) then return end
local geostat = GeoIP.Get(ply:IPAddress())
if geostat and geostat.country_name then
if geostat.country_name == "United States" then
ply:Kick("You're not wanted here")
end
end
end)[/CODE]
i found this code somewhere on these forums and dont say im racist or anything -.- i just want to play with people from my country.
i understand this needs geoip but if i put the dll in bin folder i get errors with this code.
[QUOTE=Ahvikene;42035402]dont say im racist or anything -.- i just want to play with people from my country.[/QUOTE]
But you are only banning americans :c
i havent changed the code yet omfg -.-
-snip-
[QUOTE=code_gs;42043606][lua]if geostat.country_name == "United States" then
ply:Kick("You're not wanted here")[/lua]
You're only kicking US players...[/QUOTE]
In case there was any doubt....
Simple code edit for you:
[code]
if geostat.country_name != "YOUR COUNTRY HERE" then
ply:Kick("You're not wanted here")
[/code]
This will actually kick everyone that is not from your country.
[QUOTE=Anthophobian;42044019]Simple code edit for you:
[code]
if geostat.country_name != "YOUR COUNTRY HERE" then
ply:Kick("You're not wanted here")
[/code]
This will actually kick everyone that is not from your country.[/QUOTE]
i know that it does that. if you people cant read then i need help with geoip not the script -.-
If you're using the module compiled by mfsinc he changed the table name to geolite
So change GeoIP.Get(ply:IPAddress()) to geolite.Get(ply:IPAddress())
[editline]2nd September 2013[/editline]
Also IIRC IPAddress() returns the port to, so if the lookup fails you might have to use string.Split(ply:IPAddress(), ":")[1]
[QUOTE=isnipeu;42046714]If you're using the module compiled by mfsinc he changed the table name to geolite
So change GeoIP.Get(ply:IPAddress()) to geolite.Get(ply:IPAddress())
[editline]2nd September 2013[/editline]
Also IIRC IPAddress() returns the port to, so if the lookup fails you might have to use string.Split(ply:IPAddress(), ":")[1][/QUOTE]
changed :So change GeoIP.Get(ply:IPAddress()) to geolite.Get(ply:IPAddress())
[ERROR] addons/riik/lua/autorun/riik.lua:1: Module not found!
1. require - [C]:-1
2. unknown - addons/riik/lua/autorun/riik.lua:1
[ERROR] addons/riik/lua/autorun/riik.lua:1: Module not found!
1. require - [C]:-1
2. unknown - addons/riik/lua/autorun/riik.lua:1
cant anyone help me?
post the contente of riik.lua.
[CODE]require("geoip")
hook.Add("PlayerInitialSpawn","ImRacistSoIKickWholeCountries", function(ply)
if !IsValid(ply) then return end
local geostat = Geolite.Get(ply:IPAddress())
if geostat and geostat.country_name then
if geostat.country_name == "United States" then
ply:Kick("You're not wanted here")
end
end
end)[/CODE]
I also tried[CODE]require("geolite")[/CODE]
i dont know which one is right -.-
was the module updated to Gmod13?
well im not sure -.-
i just want to get a plugin so i could play with people from my country.
i only found this one script that needed geoip.
Sorry, you need to Log In to post a reply to this thread.