Database
๐ป Saving Player's Alcohol Intoxication State to the Database
๐ง System Overview
This system ensures a realistic gameplay experience by saving and restoring the player's alcohol intoxication state. Even after leaving the server, the playerโs condition is preserved and updated upon rejoining.
๐พ Saving to the Database
When a player leaves the server while intoxicated:
๐งช Their current blood alcohol level (in โฐ) is saved.
๐ The exact time of disconnect is also recorded.
This data is stored in a database to be referenced when the player reconnects.
๐ Reading on Rejoin
When the player rejoins the server:
๐ The system checks if there's a saved intoxication state.
โฑ๏ธ It calculates how much time has passed since the player left.
โ๏ธ Based on the configuration file, the sobering rate is determined.
โ The amount of alcohol to be reduced is calculated according to the elapsed time.
๐งฎ The new intoxication level is applied, and the corresponding effects are reactivated.
โ
Final Conditions
โ If the player has been offline long enough to fully sober up, no effect is applied.
โ Otherwise, the reduced alcohol level is assigned, and the appropriate visual or gameplay effect is triggered.
๐ Summary
This system adds immersion by preventing players from bypassing the consequences of intoxication simply by logging out. It maintains full continuity of the player's state between sessions.
Last updated