TopNotch - Get USGN username (ingame) 
17 comments Hello guys,
It's been a while I've uploaded a file to Unreal Software... But today I'm bringing you an useful tool.
With this small script, you can convert a USGN ID to a USGN name, and vice versa.
Actually there is already a file in the file archive, which probably does about the same (
Get USGN Name (20)).
The difference is, his script weighs 2.55MB and this one 1kb and is pure Lua. And,... also allows finding a usgn id by username.
Features
USGN ID to Username
Username to USGN ID
Added sample join message
Added sample commands:
- !nametoid <name>
- !idtoname <usgn id>
Functions
Config
Requirements
cURL
wget (optional)
30-05-2016:
Checks if USGN is online before actually doing the requests
https://github.com/topn0tch/usgnconvert
Have fun.
It's been a while I've uploaded a file to Unreal Software... But today I'm bringing you an useful tool.
With this small script, you can convert a USGN ID to a USGN name, and vice versa.
Actually there is already a file in the file archive, which probably does about the same (


The difference is, his script weighs 2.55MB and this one 1kb and is pure Lua. And,... also allows finding a usgn id by username.





- !nametoid <name>
- !idtoname <usgn id>





30-05-2016:

https://github.com/topn0tch/usgnconvert
Have fun.
edited 18×, last 27.03.17 07:14:01 pm

Comments
17 comments



Log in!
You need to log in to be able to write comments!Log in

@
Vennece: Every time you either convert a name into U.S.G.N. ID or vice versa, a packet request will be sent to the website to acquire the specific user's data so no, it's not recommendable for offline users or those who have instant loss with the Internet connection.
For that matter, I've been thinking same like
Hajt just past days. I guess you might want to implement his idea as it can be very useful in particular cases. Overall, this script isn't just lightweight but also you've came with a new idea in hand. Great!

For that matter, I've been thinking same like



I think some server might find this code usefull, but yeah nice code with only that small lines! One like from me


Cool script , Make sure that it function's Correctly Before you will Upload a another file , And thanks
@
VADemon: Thank you for the suggestion, the script now checks if USGN is online, otherwise it won't proceed.

How does it handle server errors like 403, 404, timeouts?
Doesn't io.popen stop execution of everything else until curl is finished?
Basically +1 to @
Hajt's comment.
Doesn't io.popen stop execution of everything else until curl is finished?
Basically +1 to @


Wait, does Linux version of CS2D is compiled with -DLUA_USE_LINUX? If it doesn't, io.popen will throw "popen not supported" instead. However, this is not the case for Windows build of CS2D and io.popen will work as expected.
Also the "Linux" requirement doesn't needed here because Windows build of cURL can be download in here.
Anyway, the idea of using cURL is nice.
Also the "Linux" requirement doesn't needed here because Windows build of cURL can be download in here.
Anyway, the idea of using cURL is nice.
In my opinion better solution is download the list of all users into one file and then load it to an array.
Why? It'll work always even if Unreal Software doesn't work and io.popen freezes the server while sending requests. Moreover you can add auto-update by using crontab to get newest list of users.
Code:
1
2
3
4
5
6
7
8
2
3
4
5
6
7
8
-- wget -O /home/cs2d/users.txt 'http://www.unrealsoftware.de/users.php?raw&s=0&c=4294967295'
users = {}
local file = io.open("/home/cs2d/users.txt", "r")
for line in file:lines() do
local userid, name = line:match("([^,]+),([^,]+)")
table.insert(users, tonumber(userid), name)
end
file:close()
users = {}
local file = io.open("/home/cs2d/users.txt", "r")
for line in file:lines() do
local userid, name = line:match("([^,]+),([^,]+)")
table.insert(users, tonumber(userid), name)
end
file:close()
Why? It'll work always even if Unreal Software doesn't work and io.popen freezes the server while sending requests. Moreover you can add auto-update by using crontab to get newest list of users.



