SA-MP Forums

Go Back   SA-MP Forums > SA-MP Scripting and Plugins > Scripting Help

Reply
 
Thread Tools Display Modes
Old 30/12/2019, 06:49 AM   #1
JaKe Elite
High-roller
 
JaKe Elite's Avatar
 
Join Date: Apr 2012
Location: Philippines
Posts: 3,687
Reputation: 486
Default Inactive Accounts / Properties [MYSQL]

How can I detect if the account has been inactive for like, let's say 1-2 weeks? If they have been inactive for 1-2 weeks, their properties will be automatically sold.
JaKe Elite is offline   Reply With Quote
Old 30/12/2019, 07:47 AM   #2
harsimarriar96
Little Clucker
 
Join Date: Jul 2014
Location: India
Posts: 28
Reputation: 7
Default Re: Inactive Accounts / Properties [MYSQL]

Everytime when they log in, store the last login date, and everyday set an automated task to remove all the properties from users who have last login date greater than a week.
harsimarriar96 is offline   Reply With Quote
Old 30/12/2019, 08:35 AM   #3
Mugala
High-roller
 
Mugala's Avatar
 
Join Date: Nov 2012
Location: Georgia, Tbilisi
Posts: 1,161
Reputation: 73
Default Re: Inactive Accounts / Properties [MYSQL]

With my practice, I would make it by using MySQL in-built functions, such as DATEDIFF(date1,date2).
Store player's last login date in a database like:
PHP Code:
UPDATE `PlayersTableSET `LastOnDate` = NOW() WHERE `Name` = 'PlayerName' OR `ID` = PlayerID 
so NOW() function stores a CURRENT DATE in a database.
before doing that, you need to add a checker, which will calculate days.
PHP Code:
SELECT DATEDIFF(NOW(),LastOnDateFROM `PlayersTableWHERE `Name` = 'PlayerName' OR `ID` = PlayerID 
so with plugin MySQL R41-1 you can make something like this:
PHP Code:
new Days;
cache_get_value_index_int(0,0,Days);
if(
Days 14)
{
    
//do your job here

__________________
Coding in 8 languages including Pawn, C#, C++ and SQL.
Available for hiring.

If you have a coding question or need an assistance in a code, just PM me.
If you want me to create something for you, here is a Discord Mugala#5651

Currently helping Community members in a coding.
Mugala is offline   Reply With Quote
Old 30/12/2019, 09:58 AM   #4
Calisthenics
Gangsta
 
Join Date: May 2018
Posts: 958
Reputation: 167
Default Re: Inactive Accounts / Properties [MYSQL]

Mysql has a cron-like feature called Event Scheduler. You can read more here: https://forum.sa-mp.com/showthread.php?t=546630

Store when last seen as a DATETIME and make an index key for the column. Now all you need is an UPDATE query in event that resets values when more than 2 weeks has passed.
__________________
Calisthenics is offline   Reply With Quote
Old 30/12/2019, 01:52 PM   #5
JaKe Elite
High-roller
 
JaKe Elite's Avatar
 
Join Date: Apr 2012
Location: Philippines
Posts: 3,687
Reputation: 486
Default Re: Inactive Accounts / Properties [MYSQL]

Thank you so much! I will check all those out, thanks for the reply appreciated
JaKe Elite is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
[Include] Properties System [MySQL] F1N4L Includes 1 07/01/2017 10:33 PM
[Include] Properties System [MySQL] F1N4L Lançamentos/Releases 23 11/06/2016 04:17 AM
Managing Inactive accounts perfectboy Scripting Help 3 31/05/2015 05:50 PM
MySQL - Auto Remove InActive Accounts SPA Scripting Help 9 07/09/2014 01:52 PM
[MySQL] Cannot load properties, get an error Type-R Scripting Help 6 27/04/2014 02:33 PM


All times are GMT. The time now is 08:51 PM.


Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.