Reputation: 11
I am making a game and i want to do this: every 30 minutes every player must gain coins (online players and offline players too!). So there will be a way that the database will automatically update the columns after 30 minutes and will add to every player some coins.
Upvotes: 1
Views: 69
Reputation: 8583
You would want to create an event like so
CREATE EVENT addcoins
ON SCHEDULE AT '2014-11-12 12:00:00' + INTERVAL 30 MINUTE
DO
UPDATE `player_tbl` SET `player_tbl`.`coins` = `player_tbl`.`coins` + 1;
Upvotes: 1
Reputation: 185
An alternative is to use a cronjob - you can create a script (e.g. in PHP) on your server then create a cronjob to execute the script every 30 minutes.
Upvotes: 0