Jump to content
MakeWebGames

(Request) Donation Temple


Recommended Posts

Hello, I would like to request a feature be made for my project, It's mccodes v2.0.5b.

What it does:

  • The user clicks on the link in explore and it takes them to a temple page.
  • On this page they will be told they can donate their energy to a god, The more energy they donate the better reward they will get from the gods.
  • They can input anything above 1 energy to a max of 100 energy.
  • If the user donates 1 to 14 of his energy, They will receive a small reward.
  • If the user donates energy between 15 and 25 they will get a medium reward
  • if the users donates something between 26 and 50 they will get a better reward.
  • if they donate between 51 and 75 energy the reward will be even better
  • if they donate between 76 and 100 energy the reward will be epic!
  • Rewards can, be money, crystals, items so on...
  • They can only do this 1 time per day.

 

I'm willing to pay someone to make this.

Let me know the price, Thank you.

Link to comment
Share on other sites

Ok here goes :)

You will need to change the ids in the arrays to match the items you wish to give the users same with the crystals and money.

MySQL

CREATE TABLE `claimed` (
`user` int(20) NOT NULL default 0,
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

 

dtemple.php

<?php

/* Module Name: Donation Temple
* Module Version: v1.00
* Module Price: $0
* Module Support: [email protected]
*/

include(__DIR__.'/globals.php');

$_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? strtolower(trim($_GET['action'])) : null;
switch($_GET['action']) {
case 'check': check_amount(); break;
default: temple(); break;
}

function temple() {
global $h;
echo "<h2>Donation Temple</h2><hr width='50%'>";
echo "<i>Here you can spend your energy on rewards the more energy you donate the better the reward.</i>";
echo "Enter the amount of energy you wish to trade for a reward.<br />
<form method='post' action='dtemple.php?action=check'>
	<input type='text' name='amt' value='1' maxsize='3' title='Insert the energy you wish to trade' />
	<button>Swap Energy For Rewards</button>	
</form>";
$h->endpage();
}

function check_amount() {
global $db,$ir,$h;
$_POST['amount'] = isset($_POST['amount']) && ctype_digit($_POST['amount']) ? abs(intval($_POST['amount'])) : 0;
if(empty($_POST['amt'])) {
	echo "Thats not right?<br /><a href='dtemple.php'>Back</a>";
	$h->endpage();
	exit;
}
$check = $db->query("SELECT `user` FROM `claimed` WHERE `user` = {$ir['userid']}");
if($db->num_rows($check)) {
	echo "You have already done your daily trade.";
	$h->endpage();
	exit;
}
if($_POST['amt'] > 100) {
	echo "Sorry 100 energy is the max you can trade.";
	$h->endpage();
	exit;
}
if($ir['energy'] < $_POST['amt']) {
	echo "Sorry but you don't have that much energy.";
	$h->endpage();
	exit;
}
else {
	if($_POST['amt'] >= 1 && $_POST['amt'] < 15) {
		$chance = mt_rand(1,3);
		if($chance == 1) {
			$reward = mt_rand(100,5000);
			echo "You got ".money_formatter($reward)." for trading ".$_POST['amt']." energy";
			$db->query("UPDATE `users` SET `energy` = `energy` - ".$_POST['amt'].",`money` = `money` + '$reward' WHERE `userid` = {$ir['userid']}");
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
		if($chance == 2) {
			$reward = mt_rand(1,10);
			echo "You have gained ".$reward." crystals for trading ".$_POST['amt']." energy";
			$db->query("UPDATE `users` SET `energy` = `energy` - ".$_POST['amt'].",`crystals` = `crystals` + '$reward' WHERE `userid` = {$ir['userid']}");
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
		if($chance == 3) {
			# Add the items to the array that you want to show.
			$items = array_unique(array(1,3,4));
			$itm = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` IN(".implode(',',$items).") ORDER BY RAND() LIMIT 1");
			$ret = $db->fetch_row($itm);
			echo "You got a {$ret['itmname']} for trading ".$_POST['amt']." energy";
			item_add($ir['userid'],$ret['itmid'],1);
			$db->query("INSERT INTO `claimed` ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
	}
	else if($_POST['amt'] >= 15 && $_POST['amt'] < 26) {
		$chance = mt_rand(1,3);
		if($chance == 1) {
			$reward = mt_rand(5000,15000);
			echo "You got ".money_formatter($reward)." for trading ".$_POST['amt']." energy";
			$db->query("UPDATE `users` SET `energy` = `energy` - ".$_POST['amt'].",`money` = `money` + '$reward' WHERE `userid` = {$ir['userid']}");
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
		if($chance == 2) {
			$reward = mt_rand(10,25);
			echo "You have gained ".$reward." crystals for trading ".$_POST['amt']." energy";
			$db->query("UPDATE `users` SET `energy` = `energy` - ".$_POST['amt'].",`crystals` = `crystals` + '$reward' WHERE `userid` = {$ir['userid']}");
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
		if($chance == 3) {
			# Add the items to the array that you want to show.
			$items = array_unique(array(1,3,4));
			$itm = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` IN(".implode(',',$items).") ORDER BY RAND() LIMIT 1");
			$ret = $db->fetch_row($itm);
			echo "You got a {$ret['itmname']} for trading ".$_POST['amt']." energy";
			item_add($ir['userid'],$ret['itmid'],1);
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
	}
	else if($_POST['amt'] >= 26 && $_POST['amt'] < 51) {
		$chance = mt_rand(1,3);
		if($chance == 1) {
			$reward = mt_rand(15000,45000);
			echo "You got ".money_formatter($reward)." for trading ".$_POST['amt']." energy";
			$db->query("UPDATE `users` SET `energy` = `energy` - ".$_POST['amt'].",`money` = `money` + '$reward' WHERE `userid` = {$ir['userid']}");
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
		if($chance == 2) {
			$reward = mt_rand(25,35);
			echo "You have gained ".$reward." crystals for trading ".$_POST['amt']." energy";
			$db->query("UPDATE `users` SET `energy` = `energy` - ".$_POST['amt'].",`crystals` = `crystals` + '$reward' WHERE `userid` = {$ir['userid']}");
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
		if($chance == 3) {
			# Add the items to the array that you want to show.
			$items = array_unique(array(1,3,4));
			$itm = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` IN(".implode(',',$items).") ORDER BY RAND() LIMIT 1");
			$ret = $db->fetch_row($itm);
			echo "You got a {$ret['itmname']} for trading ".$_POST['amt']." energy";
			item_add($ir['userid'],$ret['itmid'],1);
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
	}
	else if($_POST['amt'] >= 51 && $_POST['amt'] < 76) {
		$chance = mt_rand(1,3);
		if($chance == 1) {
			$reward = mt_rand(45000,65000);
			echo "You got ".money_formatter($reward)." for trading ".$_POST['amt']." energy";
			$db->query("UPDATE `users` SET `energy` = `energy` - ".$_POST['amt'].",`money` = `money` + '$reward' WHERE `userid` = {$ir['userid']}");
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
		if($chance == 2) {
			$reward = mt_rand(35,50);
			echo "You have gained ".$reward." crystals for trading ".$_POST['amt']." energy";
			$db->query("UPDATE `users` SET `energy` = `energy` - ".$_POST['amt'].",`crystals` = `crystals` + '$reward' WHERE `userid` = {$ir['userid']}");
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
		if($chance == 3) {
			# Add the items to the array that you want to show.
			$items = array_unique(array(1,3,4));
			$itm = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` IN(".implode(',',$items).") ORDER BY RAND() LIMIT 1");
			$ret = $db->fetch_row($itm);
			echo "You got a {$ret['itmname']} for trading ".$_POST['amt']." energy";
			item_add($ir['userid'],$ret['itmid'],1);
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
	}
	else if($_POST['amt'] >= 76 && $_POST['amt'] < 101) {
		$chance = mt_rand(1,3);
		if($chance == 1) {
			$reward = mt_rand(65000,85000);
			echo "You got ".money_formatter($reward)." for trading ".$_POST['amt']." energy";
			$db->query("UPDATE `users` SET `energy` = `energy` - ".$_POST['amt'].",`money` = `money` + '$reward' WHERE `userid` = {$ir['userid']}");
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
		if($chance == 2) {
			$reward = mt_rand(50,60);
			echo "You have gained ".$reward." crystals for trading ".$_POST['amt']." energy";
			$db->query("UPDATE `users` SET `energy` = `energy` - ".$_POST['amt'].",`crystals` = `crystals` + '$reward' WHERE `userid` = {$ir['userid']}");
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
		if($chance == 3) {
			# Add the items to the array that you want to show.
			$items = array_unique(array(1,3,4));
			$itm = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` IN(".implode(',',$items).") ORDER BY RAND() LIMIT 1");
			$ret = $db->fetch_row($itm);
			echo "You got a {$ret['itmname']} for trading ".$_POST['amt']." energy";
			item_add($ir['userid'],$ret['itmid'],1);
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
	}
}
}
?>

 

and last add this to your daily cron

 

$db->query("TRUNCATE TABLE `claimed`");

 

Edit: i have not fully tested the module but any issues post em

Edited by NonStopCoding
Link to comment
Share on other sites

Ok here goes :)

You will need to change the ids in the arrays to match the items you wish to give the users same with the crystals and money.

MySQL

CREATE TABLE `claimed` (
`user` int(20) NOT NULL default 0,
) ENGINE=MyISAM DEFAULT CHARSET=latin1 COLLATE=latin1_general_ci;

 

dtemple.php

<?php

/* Module Name: Donation Temple
* Module Version: v1.00
* Module Price: $0
* Module Support: [email protected]
*/

include(__DIR__.'/globals.php');

$_GET['action'] = isset($_GET['action']) && ctype_alpha($_GET['action']) ? strtolower(trim($_GET['action'])) : null;
switch($_GET['action']) {
case 'check': check_amount(); break;
default: temple(); break;
}

function temple() {
global $h;
echo "<h2>Donation Temple</h2><hr width='50%'>";
echo "<i>Here you can spend your energy on rewards the more energy you donate the better the reward.</i>";
echo "Enter the amount of energy you wish to trade for a reward.<br />
<form method='post' action='dtemple.php?action=check'>
	<input type='text' name='amt' value='1' maxsize='3' title='Insert the energy you wish to trade' />
	<button>Swap Energy For Rewards</button>	
</form>";
$h->endpage();
}

function check_amount() {
global $db,$ir,$h;
$_POST['amount'] = isset($_POST['amount']) && ctype_digit($_POST['amount']) ? abs(intval($_POST['amount'])) : 0;
if(empty($_POST['amt'])) {
	echo "Thats not right?<br /><a href='dtemple.php'>Back</a>";
	$h->endpage();
	exit;
}
$check = $db->query("SELECT `user` FROM `claimed` WHERE `user` = {$ir['userid']}");
if($db->num_rows($check)) {
	echo "You have already done your daily trade.";
	$h->endpage();
	exit;
}
if($_POST['amt'] > 100) {
	echo "Sorry 100 energy is the max you can trade.";
	$h->endpage();
	exit;
}
if($ir['energy'] < $_POST['amt']) {
	echo "Sorry but you don't have that much energy.";
	$h->endpage();
	exit;
}
else {
	if($_POST['amt'] >= 1 && $_POST['amt'] < 15) {
		$chance = mt_rand(1,3);
		if($chance == 1) {
			$reward = mt_rand(100,5000);
			echo "You got ".money_formatter($reward)." for trading ".$_POST['amt']." energy";
			$db->query("UPDATE `users` SET `energy` = `energy` - ".$_POST['amt'].",`money` = `money` + '$reward' WHERE `userid` = {$ir['userid']}");
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
		if($chance == 2) {
			$reward = mt_rand(1,10);
			echo "You have gained ".$reward." crystals for trading ".$_POST['amt']." energy";
			$db->query("UPDATE `users` SET `energy` = `energy` - ".$_POST['amt'].",`crystals` = `crystals` + '$reward' WHERE `userid` = {$ir['userid']}");
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
		if($chance == 3) {
			# Add the items to the array that you want to show.
			$items = array_unique(array(1,3,4));
			$itm = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` IN(".implode(',',$items).") ORDER BY RAND() LIMIT 1");
			$ret = $db->fetch_row($itm);
			echo "You got a {$ret['itmname']} for trading ".$_POST['amt']." energy";
			item_add($ir['userid'],$ret['itmid'],1);
			$db->query("INSERT INTO `claimed` ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
	}
	else if($_POST['amt'] >= 15 && $_POST['amt'] < 26) {
		$chance = mt_rand(1,3);
		if($chance == 1) {
			$reward = mt_rand(5000,15000);
			echo "You got ".money_formatter($reward)." for trading ".$_POST['amt']." energy";
			$db->query("UPDATE `users` SET `energy` = `energy` - ".$_POST['amt'].",`money` = `money` + '$reward' WHERE `userid` = {$ir['userid']}");
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
		if($chance == 2) {
			$reward = mt_rand(10,25);
			echo "You have gained ".$reward." crystals for trading ".$_POST['amt']." energy";
			$db->query("UPDATE `users` SET `energy` = `energy` - ".$_POST['amt'].",`crystals` = `crystals` + '$reward' WHERE `userid` = {$ir['userid']}");
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
		if($chance == 3) {
			# Add the items to the array that you want to show.
			$items = array_unique(array(1,3,4));
			$itm = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` IN(".implode(',',$items).") ORDER BY RAND() LIMIT 1");
			$ret = $db->fetch_row($itm);
			echo "You got a {$ret['itmname']} for trading ".$_POST['amt']." energy";
			item_add($ir['userid'],$ret['itmid'],1);
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
	}
	else if($_POST['amt'] >= 26 && $_POST['amt'] < 51) {
		$chance = mt_rand(1,3);
		if($chance == 1) {
			$reward = mt_rand(15000,45000);
			echo "You got ".money_formatter($reward)." for trading ".$_POST['amt']." energy";
			$db->query("UPDATE `users` SET `energy` = `energy` - ".$_POST['amt'].",`money` = `money` + '$reward' WHERE `userid` = {$ir['userid']}");
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
		if($chance == 2) {
			$reward = mt_rand(25,35);
			echo "You have gained ".$reward." crystals for trading ".$_POST['amt']." energy";
			$db->query("UPDATE `users` SET `energy` = `energy` - ".$_POST['amt'].",`crystals` = `crystals` + '$reward' WHERE `userid` = {$ir['userid']}");
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
		if($chance == 3) {
			# Add the items to the array that you want to show.
			$items = array_unique(array(1,3,4));
			$itm = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` IN(".implode(',',$items).") ORDER BY RAND() LIMIT 1");
			$ret = $db->fetch_row($itm);
			echo "You got a {$ret['itmname']} for trading ".$_POST['amt']." energy";
			item_add($ir['userid'],$ret['itmid'],1);
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
	}
	else if($_POST['amt'] >= 51 && $_POST['amt'] < 76) {
		$chance = mt_rand(1,3);
		if($chance == 1) {
			$reward = mt_rand(45000,65000);
			echo "You got ".money_formatter($reward)." for trading ".$_POST['amt']." energy";
			$db->query("UPDATE `users` SET `energy` = `energy` - ".$_POST['amt'].",`money` = `money` + '$reward' WHERE `userid` = {$ir['userid']}");
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
		if($chance == 2) {
			$reward = mt_rand(35,50);
			echo "You have gained ".$reward." crystals for trading ".$_POST['amt']." energy";
			$db->query("UPDATE `users` SET `energy` = `energy` - ".$_POST['amt'].",`crystals` = `crystals` + '$reward' WHERE `userid` = {$ir['userid']}");
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
		if($chance == 3) {
			# Add the items to the array that you want to show.
			$items = array_unique(array(1,3,4));
			$itm = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` IN(".implode(',',$items).") ORDER BY RAND() LIMIT 1");
			$ret = $db->fetch_row($itm);
			echo "You got a {$ret['itmname']} for trading ".$_POST['amt']." energy";
			item_add($ir['userid'],$ret['itmid'],1);
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
	}
	else if($_POST['amt'] >= 76 && $_POST['amt'] < 101) {
		$chance = mt_rand(1,3);
		if($chance == 1) {
			$reward = mt_rand(65000,85000);
			echo "You got ".money_formatter($reward)." for trading ".$_POST['amt']." energy";
			$db->query("UPDATE `users` SET `energy` = `energy` - ".$_POST['amt'].",`money` = `money` + '$reward' WHERE `userid` = {$ir['userid']}");
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
		if($chance == 2) {
			$reward = mt_rand(50,60);
			echo "You have gained ".$reward." crystals for trading ".$_POST['amt']." energy";
			$db->query("UPDATE `users` SET `energy` = `energy` - ".$_POST['amt'].",`crystals` = `crystals` + '$reward' WHERE `userid` = {$ir['userid']}");
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
		if($chance == 3) {
			# Add the items to the array that you want to show.
			$items = array_unique(array(1,3,4));
			$itm = $db->query("SELECT `itmid`,`itmname` FROM `items` WHERE `itmid` IN(".implode(',',$items).") ORDER BY RAND() LIMIT 1");
			$ret = $db->fetch_row($itm);
			echo "You got a {$ret['itmname']} for trading ".$_POST['amt']." energy";
			item_add($ir['userid'],$ret['itmid'],1);
			$db->query("INSERT INTO `claimed` VALUES ('".$ir['userid']."')");
			$h->endpage();
			exit;
		}
	}
}
}
?>

 

and last add this to your daily cron

 

$db->query("TRUNCATE TABLE `claimed`");

 

Edit: i have not fully tested the module but any issues post em

Thank you for this, It works perfect! :)

Link to comment
Share on other sites

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.   Paste as plain text instead

  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...