Jump to content

[SOLVED] Updates section not refreshing GRPG framework


LOUDMOUTH

Recommended Posts

I am having problems with my updates section.  It is supposed to refill the users attributes.  It is refilling too fast and also the hospital is not updating.

 

It should be updating the users section of the mysql every minute. 

 

 

Can anyone help me out please?

 

 

<?

//Updates

$updates_sql = mysql_query("SELECT * FROM `updates` WHERE `name` = 'trevor'");

while ($line = mysql_fetch_array($updates_sql, MYSQL_ASSOC)) {

$update = $line['lastdone'];

}

$timesinceupdate = time() - $update;

if ($timesinceupdate>=300) {

$num_updates = floor($timesinceupdate / 300);

//stock market stuff
$result = mysql_query("SELECT * FROM `stocks`");
while($line = mysql_fetch_assoc($result)) {
	$amount = rand (strlen($line['cost']) * -1, strlen($line['cost']));
	$newamount = $line['cost'] + $amount;
	if ($newamount < 1){
		$newamount = 1;
	}
	$result2 = mysql_query("UPDATE `stocks` SET `cost`='".$newamount."' WHERE `id`='".$line['id']."'");
}
//stock market stuff

$result = mysql_query("SELECT * FROM `grpgusers`");

while($line = mysql_fetch_assoc($result)) {

	$updates_user = new User($line['id']);

	if ($updates_user->rmdays > 0) {

		$multiplier = 2;

	} else {

		$multiplier = 1;

	}

	$username = $updates_user->username;

	$newawake = $updates_user->awake + (5 * $num_updates) * $multiplier;

	$newawake = ($newawake > $updates_user->maxawake) ? $updates_user->maxawake : $newawake;

	$newhp = $updates_user->hp + (10 * $num_updates) * $multiplier;

	$newhp = ($newhp > $updates_user->maxhp) ? $updates_user->maxhp : $newhp;

	$newenergy = $updates_user->energy + (2 * $num_updates) * $multiplier;

	$newenergy = ($newenergy > $updates_user->maxenergy) ? $updates_user->maxenergy : $newenergy;

	$newnerve = $updates_user->nerve + (2 * $num_updates) * $multiplier;

	$newnerve = ($newnerve > $updates_user->maxnerve) ? $updates_user->maxnerve : $newnerve;

	$result2 = mysql_query("UPDATE `grpgusers` SET `awake` = '".$newawake."', `energy` = '".$newenergy."', `nerve` = '".$newnerve."', `hp` = '".$newhp."' WHERE `username` = '".$username."'");

}

//update the timer and db

$thetime = time();

$result2 = mysql_query("UPDATE `updates` SET `lastdone` = '".$thetime."' WHERE `name` = 'trevor'");

$leftovertime = $timesinceupdate - (floor($timesinceupdate / 300) * 300);

if ($leftovertime>0) {

	$newupdate =  time() - $leftovertime;

	$setleftovertime = mysql_query("UPDATE `updates` SET `lastdone` = '".$newupdate."' WHERE `name` = 'trevor'");

}

}









$updates_sql = mysql_query("SELECT * FROM `updates` WHERE `name` = 'hospital'");

while ($line = mysql_fetch_array($updates_sql, MYSQL_ASSOC)) {

$update = $line['lastdone'];

}

$timesinceupdate = time() - $update;

if ($timesinceupdate>=60) {

$num_updates = floor($timesinceupdate / 60);

$result = mysql_query("SELECT * FROM `grpgusers`");

//DO STUFF

while($line = mysql_fetch_assoc($result)) {

	$result_user = mysql_query("SELECT * FROM `grpgusers` WHERE `id`='".$line['id']."'");

	$updates_user = mysql_fetch_array($result_user);



	$newhospital = $updates_user['hospital'] - (60 * $num_updates);

	$newhospital = ($newhospital < 0) ? 0 : $newhospital;

	$newjail = $updates_user['jail'] - (60 * $num_updates);

	$newjail = ($newjail < 0) ? 0 : $newjail;

	$result2 = mysql_query("UPDATE `grpgusers` SET `hospital` = '".$newhospital."', `jail` = '".$newjail."' WHERE `id` = '".$line['id']."'");

}

mysql_query("UPDATE effects SET timeleft=timeleft-1 WHERE timeleft>0");
mysql_query("UPDATE grpgusers SET bguard=bguard-1 WHERE bguard>0");
}

$result2 = mysql_query("DELETE FROM `effects` WHERE `timeleft` < 1");



//update the timer and db

$thetime = time();

$result2 = mysql_query("UPDATE `updates` SET `lastdone` = '".$thetime."' WHERE `name` = 'hospital'");

$leftovertime = $timesinceupdate - (floor($timesinceupdate / 60) * 60);

if ($leftovertime>0) {

	$newupdate =  time() - $leftovertime;

	$setleftovertime = mysql_query("UPDATE `updates` SET `lastdone` = '".$newupdate."' WHERE `name` = 'hospital'");

}



?>

Link to comment
Share on other sites

For some reason it isnt Updating in the DataBase.  If I manually go into the DB it allows me to Convert the table but it wont update on its own?

 

Can some help please? 

 

I am looking for a Coder to help me out with a few different jobs.  If you are a coder please let me know if you are interested in a Job. ;D

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.