MyBB Community Forums

Full Version: PHP help?
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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 Smile
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?
Fixed ^_^ Got a way easier code.
You can close this if you want.