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