Updating resources...
- rockinliam
- Posts: 466
- Joined: Sun Jun 07, 2009 11:26 am
Updating resources...
How would i go about updating the resources of all the players in a database? Could i do it via a php script and a cronjob? If so what would be in the php script to update every user according to the level of their buildings and how would i make it safe to not be run by the player?
Skillset: C/C++, OpenGL, C#, Lua, PHP, MySql, Web Dev etc.
Website: https://liam-griffiths.co.uk/
Website: https://liam-griffiths.co.uk/
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Updating resources...
do it via cron job,
just run the query and a while statement
query = Select lumber, metal from players
while query
{
query[lumber] = query[lumber]+5;
update players lumber=query[lumber] where name=query[name]
}
as far as keeping the script safe you could put a passcode in it
run the cron like www.mygame\cronjob1.php?code=23453443
then in the script
if ($_GET
just run the query and a while statement
query = Select lumber, metal from players
while query
{
query[lumber] = query[lumber]+5;
update players lumber=query[lumber] where name=query[name]
}
as far as keeping the script safe you could put a passcode in it
run the cron like www.mygame\cronjob1.php?code=23453443
then in the script
if ($_GET
Code: Select all
= 23453443)
{
do cron
}
else
{
leave blank
}- Jackolantern
- Posts: 10891
- Joined: Wed Jul 01, 2009 11:00 pm
Re: Updating resources...
For added security, if you only run the cron every couple of minutes, you can store the last time it was run in the database, and add logic to the script to check the last time it was run and ensure it is not running prematurely. Besides foiling exploiters, this could also help prevent disastrous system glitches. If you run it many times per minute, the added overhead could be a problem, though.
The indelible lord of tl;dr
- rockinliam
- Posts: 466
- Joined: Sun Jun 07, 2009 11:26 am
Re: Updating resources...
Ok guys thanks for the ideas, its too late at night for me to do this now, but il write it out tommorrow, and tell you if i work
*fingers crossed*
Skillset: C/C++, OpenGL, C#, Lua, PHP, MySql, Web Dev etc.
Website: https://liam-griffiths.co.uk/
Website: https://liam-griffiths.co.uk/
- hallsofvallhalla
- Site Admin
- Posts: 12026
- Joined: Wed Apr 22, 2009 11:29 pm
Re: Updating resources...
good idea, just set a timer in the database and have it check if a hour has went by or whatever time you have set.