Page 1 of 1
[0.14.19] All Number Usernames
Posted: Sun Nov 06, 2016 8:29 am
by zackman0010
I was watching a server that I am admin of when I noticed a player with an all numbers username. As it is hosting a PvP scenario, I got curious and attempted to see which force he was on. Trying to index his name, however, caused an error. Example below.
Results of using /p
Code: Select all
Players (18):
chocolateTthunder
Baltrius
Revagor
Zecheria
vixoopo1
dzentak
BRPW
kopetam
chipmike24
lu4kmo4r
HeavenlyDeath
CognizantGhost
IronCartographer
rayjiff
haeruhu
Nighthawks
01001010 (<--- All Number Username)
ViperZ
Results of trying to use all numbers username as index
Code: Select all
/silent-command print(game.players["01001010"].force.name)
Cannot execute command. Error: [string "print(game.players["01001010"].force.name)"]:1: attempt to index field '01001010' (a nil value)
The commands were input into the console, I was not actually in-game.
Re: [0.14.19] All Number Usernames
Posted: Sun Nov 06, 2016 9:08 pm
by Rseding91
I'm not sure if there's a simple solution for this. The "index by name" option is mostly just for convince as the name can be empty if the player is running single player.
The only way you can guarantee to get the player you're after is by using the player index or if you have multiple players iterate and check name for the one you want.
Re: [0.14.19] All Number Usernames
Posted: Mon Nov 07, 2016 9:46 pm
by kovarex
I don't think that we should allow usernames with numbers only.
Re: [0.14.19] All Number Usernames
Posted: Mon Nov 07, 2016 9:50 pm
by Klonan
kovarex wrote:I don't think that we should allow usernames with numbers only.
That seems like a rather arbitrary rule
Re: [0.14.19] All Number Usernames
Posted: Tue Nov 08, 2016 11:25 am
by kovarex
Klonan wrote:kovarex wrote:I don't think that we should allow usernames with numbers only.
That seems like a rather arbitrary rule
Why? What kind of username is it if it has only numbers? How many like these do we have?
I mean, this kind of scripting problem would be very unexpected.
Re: [0.14.19] All Number Usernames
Posted: Tue Nov 08, 2016 11:49 am
by posila
Thanks for the report. Should be fixed in next release.
Re: [0.14.19] All Number Usernames
Posted: Tue Nov 08, 2016 1:43 pm
by posila
Actually, it was not fixed ... it seams lua always treats key as string, so our logic "can we convert the key to number? if yes search by index otherwise search by string" is probably the best we can do without hard to explain behavior (like what if somebody make username "1")
Re: [0.14.19] All Number Usernames
Posted: Sat Feb 10, 2018 1:09 am
by Jon8RFC
Re: [0.14.19] All Number Usernames
Posted: Sat Feb 10, 2018 1:36 am
by Rseding91
I doubt it. That was a different issue related to JSON.
Re: [0.14.19] All Number Usernames
Posted: Sat Feb 10, 2018 1:51 am
by Jon8RFC
I was more so referring to this specific post than the issue regarding json:
posila wrote:kovarex wrote:That is weird, because we had similar problems when saving numbers in lua state, and as far as I remember, we solved it without using hexes for numbers.
In the end, we did solve it by serializing numbers in lua state in hex format
Still a no-go, with whatever was done for numerals in hex format?