Cronwerks MCCode/MCCodes Forums

Please login or register.

Login with username, password and session length

News:

Have you purchased a mod and are struggling to install it? Cronwerks now installs mods for only $3/$2.50. Message Cronus to discuss the details or purchase.


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

AuthorTopic: hourly reward - redux  (Read 270 times)

windsor

  • Basic Member
  • *
  • Reputation Power: 7
  • windsor has no influence.
  • Offline Offline
  • Posts: 13
    • View Profile
hourly reward - redux
« on: August 14, 2011, 03:34:28 PM »
SQL

ALTER TABLE  `users` ADD  `hourlyReward` INT( 3 ) NOT NULL DEFAULT  '0';

hourly.php

<?php

require_once('./Global/globals.php');
global $h,$ir;
//original mod by mark mascola August 13, 2011

if ( !defined($_CONFIG['define_code']) ) {
   echo 'This file cannot be accessed directly.';
   exit;
}

echo "<h2>Welcome to Hourly Rewards</h3>";
echo "<p>Once an hour you may come here to collect a reward</p>";

if($_POST['valid']=='yes' && isset($_POST['bet'] )){
if($ir['hourlyReward'] > 0){
echo "You cannot refresh this page.";
$h->endpage();
exit;
}
else{
$hourlyMoney = $ir['level']*rand(200,300);
$hourlyPoints = rand(10,25);

echo "You have earned $".$hourlyMoney." ,".$hourlyPoints." Points for playing this hour";
$db->query("UPDATE users SET main = main +{$hourlyMoney},second = second+{$hourlyPoints},hourlyReward = 60 WHERE userid={$ir['userid']}");
$_POST['valid']='no';
$h->endpage();
exit;
}
}
else{
if($ir['hourlyReward']==0){
echo "<p><form method='post'><input type='hidden' name='valid' value='yes' /><input type='submit' name='bet' value='Claim Your Reward' /></form></p>";
}
else{
$wait= $ir['hourlyReward'];
echo"You must wait <font color=red>".$wait."</font> minutes before you can claim your next reward.";
}
}
?>


add this to the bottom of cron_minute.php

$db->query("UPDATE users SET hourlyReward = hourlyReward - 1 WHERE hourlyReward > 0");

don't forget to link it up somewhere on your explore page and index it in the index.php that is located on the root of your site
« Last Edit: August 14, 2011, 03:40:28 PM by windsor »
Logged
insanecriminal.com

windsor

  • Basic Member
  • *
  • Reputation Power: 7
  • windsor has no influence.
  • Offline Offline
  • Posts: 13
    • View Profile
Re: hourly reward - redux
« Reply #1 on: August 14, 2011, 03:39:20 PM »
if you have any issues with this, feel free to reply
« Last Edit: August 14, 2011, 03:41:01 PM by windsor »
Logged
insanecriminal.com

newbie

  • Basic Member
  • *
  • Reputation Power: 1
  • newbie has no influence.
  • Offline Offline
  • Posts: 4
    • View Profile
    • Email
Re: hourly reward - redux
« Reply #2 on: October 02, 2011, 06:40:31 PM »
anyways to get this for v2?
Logged
 


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