[SCRIPT] statistics2.0

I decided to make some improvements to the script, since it is a bit annoying to use /mlogin to access your user account and then use /login to access the admin/mod/guard/etc account on your server.

  • Now it will not be necessary to put /mlogin, you just have to put /login.
  • In case you want to use your user account along with the administrator/mod/guard/etc account(password), you should use the same password.
    For example, suppose that the administrator password of your server is megaADM12, you must create an account using the same password:

/register MegaStar megaADM12 -> You have successfully registered.

To login to your account you must enter /login <username> <password>

/login MegaStar megaADM12
You logged in as MegaStar (admin)
Your stats is: User: MegaStar, Kills: 0, Deaths: 0, Ratio: 0.0, Flag Captured: 0

As you may have noticed, at the side of my nick comes out "(admin)" This means that you have just successfully entered the administrator account of your server.

  • In the case that the password is moderator, it will be "(Moderator)", the same will be with guard/trusted,etc.
  • In the case of players who are only registered players, it will come out "(Registered User)"

Example:

  • Previously the command /top only showed the 2 best players of the server, now the best 5 players of the server will come out.
  • The commands /register, /top, /users, /login and /stats were debugged so that the code is more fluid and can work without problems.
  • Click on the Spoiler button to see the commands with more details and how to use the script.

[details=Click for details]

Re-read:

I just made a script that allows you to save your kills, deaths and flags captured when you have login on the server, registered users can save his kills, deaths and flags captured.

New Update:

Before there was no control over registered users, so a player could create more than 2 accounts, now has more control and will only allow 2 accounts per IP, why 2 accounts per IP and not only 1? this is because some players share the same internet and when sharing it also share the same IP and therefore it is advisable to put 2 accounts per IP instead of 1 (you can change the number of accounts per IP, just open the script and in the line where it says "MAX_ACCOUNT_PER_IP = 2" change the 2 by the number of accounts per IP you want).

Commands:

  • /register: Will ask you to enter username and password, if the username already exists, the registration will not be done.
  • /login: You must enter your username and password that you previously created, if the password is incorrect the login will not be done (this also works with the admin/mod/etc password of your server, just make sure you use the same password)
  • /top: Will tell you the 5 best players of the server, this is counted by the kills of the users.
  • /logout: Logout of your account.
  • /users: Shows you all the names of registered users every 1 second.
  • /stats: If the player is logged into his account, to see his statistics he should only put "/stats" (this only applies if the player is logged into his account otherwise he will get a message saying "you must enter the name of the user"), to see the statistics of another player you should only put "/stats username".

-You must download the file statistics.txt and put it inside your dist folder (dist / statistics.txt))
-The file statistics.txt will have two lines already written "#0.0.0.0 None #None 0 0 0" please do not delete those lines because this count as a means of support for when the /top command is used.
-The /top players is counted by kills, what do I mean by this? the user who has more kills will be in the top1 and the second will be in the top2, the third in the top3, etc (max 5).
-The kills, deaths and flag captured of the player will be saved only when the player initiates login his account.
-If you try to put "/logout" without having logged into your account, you will get a message saying "You are already logged.".
-If a player already has more than 1 account and tries to register again, they will get a message that says "You have an account already created."

Example:

suppose I'm about to register and login in my account

/register MegaStar megaADM12 -> You have successfully registered.
/login MegaStar megaADM12 -> You logged in as MegaStar (admin)
Your stats is: User: MegaStar, Kills: 0, Deaths: 0, Ratio: 0.0, Flags captured: 0

Suppose that MoDeR login on his account at that moment

MoDeR kill Deuce2.
MoDeR kill Deuce3.
MegaStar kill Deuce5.
MegaStar kill Deuce2.
MegaStar kill Deuce3.
MegaStar kill MoDeR.
MegaStar captured the blue flag.

/top
top 5: User: Mario, Kills: 0, Deaths: 0, Ratio: 0.0, Flags Captured: 1
Top 4: User: MoDeR, Kills: 2, Deaths: 1, Ratio: 2.0, Flags Captured: 0
Top 3: User: MegaStar, Kills: 4, Deaths: 0, Ratio: 4.0, Flags Captured: 1
top 2: User: FireKill, Kills: 10, Deaths: 1, Ratio: 10.0, Flags Captured: 3
top 1: User: ProPlayer, Kills: 20, Deaths: 1, Ratio: 20.0, Flags Captured: 4
/stats
Your stats is: Kills: 4, Deaths: 0, Ratio: 4.0, Flags Captured: 1

/stats MoDeR
Stats of the user MoDeR: Kills: 2, Deaths: 1, Ratio: 2.0, Flags Captured: 0

/users
Registered Users:

  1. MegaStar
  2. MoDeR
  3. Mario
  4. ProDeuce
  5. AserejeAdeje

/logout
Logout successfully.

The ratio will always round the result of (kills / deaths) to the tenth.
example:
kills = 7
deaths = 3
result = 2.3333333333333335
ratio-round = 2.3 [/details]

Recommendation:

You can use the passreload.py script of Danke, this script allows you to modify/add/remove the passwords of the config.txt without having to reset your server:

· "Passwords": {
        "admin": ["megaADM23"],
        "moderator": ["modpass12"],
        "guard": ["khe1212"],
        "trusted": ["nou"]
    },

Once you finish modifying you should only put /reloadconfig in the server (you can also do it in the run) this will do that you do not have to close the server and reopen it when you modify something related to the permissions and passwords of your server, without a doubt this script will help you a lot and at the same time you can use it when you want to add a registered user to administrator/guard/moderator/etc.
To do so, you should only increase the user's password, for example:

· "Passwords": {
        "admin": ["megaADM23", "User password"],
        "moderator": ["modpass12"],
        "guard": ["khe1212"],
        "trusted": ["nou"]
    },

then you must put /reloadconfig and tell the player to put /logout and login again in his account and finally he will be in the administrator group!

if you have any questions, just answer in this topic, thanks.


statistics.txt (52 Bytes)

passreload.py (1.17 KB)

statistics.py (11.1 KB)

Nice script! I believe it would be nice to have a message when the best player login, like:
“[TOP1] Deuce joined the game”

Updated, now has a ratio and flag captured.

Final update, now work with /login.
Thanks.