#STZ Posted January 21, 2022 Share Posted January 21, 2022 Hello, i need to know the method for Consecutive login for examle if i logged in 12/1 then logged in 13/1 then logged in 14/1 how can i calculate and record 3 points to the player Link to comment
Discord Moderators Megadreams Posted January 21, 2022 Discord Moderators Share Posted January 21, 2022 (edited) There's a few ways you can accomplish this. You could maintain a log of when the player has logged in and compare against that to see if they logged in 3 consecutive days. Another way is only keeping track of the last login and a counter of consecutive days thus far. If the user logs in and their last login wasn't the day before you reset the counter, otherwise if they did you increase it. Obviously if they logged in earlier on that same day you don't modify the counter. Edited January 21, 2022 by Megadreams Link to comment
Hydra Posted January 21, 2022 Share Posted January 21, 2022 You could use setAccountData/getAccountData or with database to store the login times Link to comment
#STZ Posted January 21, 2022 Author Share Posted January 21, 2022 @Hydrai only ask about the calculation method not store method ----- @Megadreams how can i create this function isPlayerLoggedYesterday ( LastLogin , todayDate ) if LastLogin = "2022-01-20" and todayDate "2022-01-21" how can i know if that the day next or not ? for example lastlogin may be 31 and today ma by day 1 its consecutive days if LastLogin = "2022-01-31" and todayDate "2022-02-1" Link to comment
Shady1 Posted January 21, 2022 Share Posted January 21, 2022 you can use getTimestamp() function to find previous day and current day this will return instant timestamp in seconds. https://wiki.multitheftauto.com/wiki/GetTimestamp Since 1 day is 86400 seconds, you will subtract this from the present addCommandHandler("times", function() local time = getTimestamp() local beforeDay = time - 86400 outputDebugString("before day:"..beforeDay) outputDebugString("now: "..time) end) this way you can access previous time and current time i'm not sure if this is what you want Link to comment
The_GTA Posted January 21, 2022 Share Posted January 21, 2022 You don't need to know the algorithm if you can make use of the getRealTime function. By giving it the seconds of current day you can fetch the datetime description of the next day by adding the amount of seconds that eoL|Shady has described. Then you can reconstruct the datestring from that time description. But I guess that eoL|Shady's answer might be enough to get you in the right direction. Link to comment
#STZ Posted January 22, 2022 Author Share Posted January 22, 2022 Thank you all, project done by using timestamp Link to comment
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now