• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

C++ Login MSG Cooldown


This isn't a complete tutorial but should provide you with the correct steps.

1. You should change the line output->addString(fmt::format("{:d}\n{:s}", g_game.getMotdNum(), motd)); to something that is more dynamic. Since it just fetches the MotdNum and motd message and print them out.
2. You'd probably need to use <chrono> to find the time difference or any other C++ library that you see fits.
3. You'll also need to convert a date(DD-MM-YYYY-HH:MM) into a tm struct then feed it into system_clock::from_time_t - C++ Reference (https://www.cplusplus.com/reference/chrono/system_clock/from_time_t/)
4. Find the difference between the current time and your reference using How to get current time and date in C++? (https://stackoverflow.com/questions/997946/how-to-get-current-time-and-date-in-c#:~:text=std%3A%3Achrono%3A%3Aduration%3Cdouble%3E%20elapsed_seconds%20%3D%20end%2Dstart%3B)
5. This will be in seconds, Convert it into days by dividing it by 86400
6. Take the seconds mod 86400 to find the remainder hours
7. Convert it into hours by dividing by 3600.
8. Take the result mod 3600 to find the resulting minutes.
9. Convert it into minutes then dump all of that as a string in your format.


Best of luck :D
 
Back
Top