Jump to content

In Need of Robot/Dummy Code


dual_alliance

Recommended Posts

Hello,

I'm not sure if its called dummy or robot code but it sounds like what l need.  What l need is a code that once a day "-1" from the database,  this is so when the user is banned for x number of days each day the number reduces.  I would be very grateful if you could help me.

Thankyou,

dual_alliance
Link to comment
Share on other sites

what you need to do is set up a PHP script to do what you're after (the query only), and then, you just set up a CRON job to run it for you. if you have shell access to your server, just type "crontab -e" from your command line, then hit "i" to enter insert mode and enter the following job:

[code]
0 0 * * * php /path/to/file/myFile.php
[/code]

basically, that tells the script to run at midnight every day, so if your script is updating your database correctly, you're good to go. obviously "/path/to/file" needs to be the path on your server to the correct location.

hope this helps
Link to comment
Share on other sites

Sorry for replying so late.  Well l do have a type of cPanel but it is just a basic one.  True that is an easier alternative but l am making a game and l need it to give resources to player every 15 minutes so having a date would not be very efficient but it could work for the ban system but l would rather have it to display how many days they are banned for if l can help it.

dual_alliance
Link to comment
Share on other sites

[quote]it could work for the ban system but l would rather have it to display how many days they are banned for[/quote]

Assuming you have a table called "bans" with columns (INT id,) INT user and DATE ban_ends, this query returns the remaining ban days as "days_left":

[code]SELECT DATEDIFF(ban_ends, CURDATE()) days_left FROM bans WHERE user = xx;[/code]
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.