Forum

> > CS2D > Scripts > Any location script?
Forums overviewCS2D overview Scripts overviewLog in to reply

English Any location script?

11 replies
To the start Previous 1 Next To the start

old Any location script?

Gaios
Reviewer Off Offline

Quote
Hello,

are there any alternatives for file cs2d Locmod 1.0 ? It's not that good (it's database based) and only for Windows. I need something other.

Or user SQ can add to Steam API a
loccountrycode
key.
> https://developer.valvesoftware.com/wiki/Steam_Web_API

But still this solution can be omitted because of If set on the user's Steam Community profile, The user's country of residence, 2-character ISO country code.


EDIT:
I just found it, file cs2d Player's Country Info (Y.A.T.E.S.) . Sorry buddy. But this one requires installations. I hope there are better solutions.

old Re: Any location script?

SQ
Moderator Off Offline

Quote
I'm adding non-freezing tcp requests into CS2D for next version. You will be able to write you own whatever you want.

1
2
3
4
5
6
7
8
9
10
11
12
13
addhook("tcpreceiver","hook_tcp")

tcp_id = reqtcp("steamcommunity.com","/profiles/76561198386951497?xml=1")

print("create id: "..tcp_id)

function hook_tcp(id, state, result)
	print("receive id: "..id)
	print("state: "..state)
	if (state > 0) then
		print(result)
	end
end

old Re: Any location script?

Talented Doge
User Off Offline

Quote
It is great to hear that you are adding some internet thing to CS2D.

By the way, what is the difference between curl/wget and tcp requests? I don't really know their differences.

old Re: Any location script?

GeoB99
Moderator Off Offline

Quote
user Gaios has written
EDIT:
I just found it, file cs2d Player's Country Info (Y.A.T.E.S.) . Sorry buddy. But this one requires installations. I hope there are better solutions.

Care to explain "requires installations" from your sentence? I believe the description from the upload I wrote should be quite understandable for everyone on how to get this script working, even for an average Joe, and it takes only a few minutes. There's already a standalone script in case you're not using file cs2d Y.A.T.E.S (3.0.2) - Admin Script / Framework .

old Re: Any location script?

Masea
Super User Off Offline

Quote
user Gaios has written
@user Masea: Rofl, where's that written?
No where. I've been said user DC to update cs2d.com. But not yet ever happened. Maybe too soon.

Just type
lua print(player(1,"country"))
at console then you see what it is. user SQ once talked me about it.

old Re: Any location script?

Cure Pikachu
User Off Offline

Quote
user Masea has written
Just type
lua print(player(1,"country"))
at console then you see what it is.

Just tried that and it returned
false
. For the record, I am running 1.0.0.5 p3.

old Re: Any location script?

VaiN
User Off Offline

Quote
If you are interested in a non-Windows solution, I'd recommend the popular unix choice of GeoIP. It's what I decided to go with for my scripts. With this method, it's all local so you don't have to wait on a remote response, or require a player to be logged in.

For Debian/Ubuntu:
1
sudo apt-get install geoip-bin

You'll want to download the up-to-date database. You can auto-update in your script:
1
2
3
4
os.execute('wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCountry/GeoIP.dat.gz')
os.execute('gunzip GeoIP.dat.gz')
os.execute('wget http://geolite.maxmind.com/download/geoip/database/GeoLiteCity.dat.gz')
os.execute('gunzip GeoLiteCity.dat.gz')

And here's how to get the data from CLI:
1
2
3
4
5
-- country:
handle = io.popen("geoiplookup -f GeoIP.dat " .. ip .. " | awk -F, '{print $2;}'")

-- state/region:
handle = io.popen("geoiplookup -f GeoLiteCity.dat " .. ip .. " | awk -F, '{print $4;}'")

Should be enough to get you started.
edited 1×, last 28.11.17 07:36:39 am
To the start Previous 1 Next To the start
Log in to reply Scripts overviewCS2D overviewForums overview