Chalwk

Market

Tiddy-bits:

Big change to the script.

I never really liked binding accounts to the IP, as a player will lose their stats when it changes or if the server is restarted. 

As such, I have written an account saving system for the Market script.

Players are now required to create an account (in-game) to use it.
 

Account Management Commands:
1. /account create <username> <password>
You'll be logged in automatically after account creation.
 

2. /account login <username> <password>


Account details are saved to a local database called accounts.json.

Some data is cached for a period of time, based on your IP address.
If your IP changes or the server is restarted, you will have to log in again.
 

Also added two new features: Flashlight teleporting and command cooldowns. 
1. If you have enough money, press your flashlight key to teleport to wherever you're aiming.
2. All commands (including flashlight boosting) have configurable cooldowns (default 60 seconds each).
 

Technical note about the Market script and data caching:

When you log in with the correct username and password, your balance will be restored. 

Balances are linked to a JSON table and the table is saved to the file when the game ends.

You do not need to be online when your stats are saved during end-game. This is due to them being cached for a period of time, based on your IP address. So long as the game ends within a reasonable amount of time, and not so long that dynamic IP addresses have a chance to change; I'm talking like, 24 hours or so. Most games end within 20 minutes.
 

That database looks like this, by the way:

{
  "Player1": {
    "balance": 1000,
    "password": "password1234"
  },
  "Player2": {
    "balance": 500,
    "password": "12345"
  }
}

 

Alternatively, I could save a player's stats to the JSON database every time their balance is updated.

But that would be too many i/o operations and might cause lag (especially on larger databases); This is why I opted to save stats when the game ends.

The key of the account table is their custom username, by the way. Not gamer tag.
 

Video demonstration of this system:

 

 

Edited by Chalwk
Enclusion and Takka like this

- I invite you to join my Halo Discord Server.

- Add me on discord: Chalwk#9284
- HSP Repo

- HSP Repo Wiki (new)

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!


Register a new account

Sign in

Already have an account? Sign in here.


Sign In Now
  • Recently Browsing   0 members

    No registered users viewing this page.