Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

Have you purchased a mod and lost your copy? Just file a support ticket through your "My Mods" page.


This forum is now closed and has moved to a new location! Click here to find out why.

AuthorTopic: Delete From Cmarket After a Set Time  (Read 356 times)

JoshuaDams

  • Active Member
  • **
  • Reputation Power: 129
  • JoshuaDams is working their way up.JoshuaDams is working their way up.JoshuaDams is working their way up.
  • Offline Offline
  • Posts: 240
    • MSN Messenger - immortalthug4ever@hotmail.com
    • View Profile
    • WWW
Delete From Cmarket After a Set Time
« on: February 13, 2010, 02:43:07 PM »
Another Basic request.

Basically Just deletes Entries and Returns to the user after 7 Days.

Keeps Cmarket from cluttering up :)

First Add this SQL

ALTER TABLE `crystalmarket` ADD `timer` INT(11) NOT NULL DEFAULT 0;

Next Add This to cron_day.php

Code: [Select]
$db->query("UPDATE `crystalmarket` SET `timer`=`timer`+1");

Go to the bottom of cron_day and right above ?>
Add the Following
Code: [Select]
$remove = $db->query("SELECT `cmID`,`cmADDER`,`cmQTY` FROM `crystalmarket` WHERE `timer`>7");
while($take = $db->fetch_row($remove))
{
$db->query("UPDATE `users` SET `crystals`=`crystals`+{$take['cmQTY']} WHERE `userid`={$take['cmADDER']}");
$db->query("DELETE FROM `crystalmarket` WHERE `cmID`={$take['cmID']}");
}


Next you are going to want to open up cmarket.php

Find the query Where it inserts the values into crystalmarket table
Will look something like this.

Code: [Select]
$db->query("INSERT INTO crystalmarket VALUES ('', {$_POST['crystals']}, $userid, {$_POST['price']})");

Change to

Code: [Select]
$db->query("INSERT INTO crystalmarket VALUES ('', {$_POST['crystals']}, $userid, {$_POST['price']}), 0");

Save, Close.

This should be it, any problems post here.

Jordan

  • Active Member
  • **
  • Reputation Power: 55
  • Jordan has no influence.
  • Offline Offline
  • Posts: 102
  • Website Developer for hire;
    • MSN Messenger - Pudda2008@hotmail.co.uk
    • View Profile
    • WWW
    • Email
Re: Delete From Cmarket After a Set Time
« Reply #1 on: February 14, 2010, 07:39:54 AM »
Did this a while back, Good work ^_^ although I wouldn't use the ''idea'' :)
Logged
Contact me
MakeWebGames.com
 


This forum is now closed and has moved to a new location! Click here to find out why.