2006-04-05, 02:50 PM
I've tried to post this on some PHP forums but I didn't really get a final script yet. And since there are some PHP guru's here, I decided to give it a try here
I'm trying to make an RPG game. Every player needs turns to do actions (kill monsters, buy land, ...)
I use a cronjob to add 15 turns to every player every 15 minutes.
But now I want to set a max amount of turns (like 2000) but I don't really know how to do this.
My first code looked like this:
Now I have this:
Would that work?
I'm trying to make an RPG game. Every player needs turns to do actions (kill monsters, buy land, ...)
I use a cronjob to add 15 turns to every player every 15 minutes.
But now I want to set a max amount of turns (like 2000) but I don't really know how to do this.
My first code looked like this:
<?php
include "../connect.php";
$getturns="Update km_users set numturns=numturns+15";
$getturns2=mysql_query($getturns) or die("Could not get turns");
?>
Now I have this:
<?php
<?php
include "../connect.php";
$test ="SELECT numturns FROM km_users";
if($test + 15 > 2000){
$rest = "2000-$test";
$getturns = "UPDATE km_users SET numturns=numturns+$rest";
}
else {
$getturns="Update km_users set numturns=numturns+15";
}
$getturns2=mysql_query($getturns) or die("Could not get turns");
?>
Would that work?