Jump to content
MakeWebGames

Exchange.php


GregFest

Recommended Posts

Number one error they all dont work but the energy refill, when trying to use ie crystals it says i dont got any

 

<?php
/*
Engine: MC V2.5 (Redux)
File: exchange.php
Author: mccodes.com
*/
if ( !defined($_CONFIG['define_code']) ) {
  echo 'This file cannot be accessed directly.';
  exit;
}
if(!$_GET['spend'])
{
echo "Welcome to the exchange!<br />
You have <b>{$ir['second']}</b> ".$set['second_currency'].".<br />
What would you like to spend your ".$set['second_currency']." on?<br />
<br />
<a href='".gen_url('exchange',true)."&spend=refill'>Energy Refill - {$set['ct_refillprice']} ".$set['second_currency']."</a><br />
<a href='".gen_url('exchange',true)."&spend=IQ'>IQ - {$set['ct_iqpercrys']} IQ per ".substr($set['second_currency'], 0, -1)."</a><br />
<a href='".gen_url('exchange',true)."&spend=main'>".$set['main_currency']." - \$".number_format($set['ct_moneypercrys'])." per ".substr($set['second_currency'], 0, -1)."</a><br />";
}
else
{
if($_GET['spend'] == 'refill')
{
if($ir['second'] <$set['ct_refillprice'])
{
echo "You don't have enough ".$set['second_currency']."!";
}
else if($ir['energy'] == $ir['maxenergy'])
{
echo "You already have full energy.";
}
else
{
$db->query("UPDATE users SET energy=maxenergy,`second` = `second`-{$set['ct_refillprice']} WHERE userid=$userid");
echo "You have paid {$set['ct_refillprice']} ".$set['second_currency']." to refill your energy bar.";
}
}
else if($_GET['spend'] == 'IQ')
{
echo "Type in the amount of ".$set['second_currency']." you want to swap for IQ.<br />
You have <b>{$ir['second']}</b> ".$set['second_currency'].".<br />
One ".substr($set['second_currency'], 0, -1)." = {$set['ct_iqpercrys']} IQ.<form action='".gen_url('exchange',true)."&spend=IQ2' method='post'><input type='text' name='".$set['second_currency']."' /><br /><input type='submit' value='Swap' /></form>";
}
else if($_GET['spend'] == 'IQ2')
{
$_POST[$set['second_currency']]=(int) $_POST[$set['second_currency']];
if($_POST[$set['second_currency']] <= 0 || $_POST[$set['second_currency']] > $ir['second'])
{
echo "Error, you either do not have enough ".$set['second_currency']." or did not fill out the form.<br />
<a href='".gen_url('exchange',true)."&spend=IQ'>Back</a>";
}
else
{
$iqgain=$_POST[$set['second_currency']]*$set['ct_iqpercrys'];
$db->query("UPDATE users SET `second` = `second`-{$_POST[$set['second_currency']]} WHERE userid=$userid");
$db->query("UPDATE userstats SET IQ=IQ+$iqgain WHERE userid=$userid");
echo "You traded {$_POST[$set['second_currency']]} ".$set['second_currency']." for $iqgain IQ.";
}
}
else if($_GET['spend'] == 'main')
{
echo "Type in the amount of ".$set['second_currency']." you want to swap for ".$set['main_currency'].".<br />
You have <b>{$ir['second']}</b> ".$set['second_currency'].".<br />
One ".substr($set['second_currency'], 0, -1)." = \$".number_format($set['ct_moneypercrys']).".<form action='".gen_url('exchange',true)."&spend=main2' method='post'><input type='text' name='".$set['second_currency']."' /><br /><input type='submit' value='Swap' /></form>";
}
else if($_GET['spend'] == 'main2')
{
$_POST[$set['second_currency']]=(int) $_POST[$set['second_currency']];
if($_POST[$set['second_currency']] <= 0 || $_POST[$set['second_currency']] > $ir['second'])
{
echo "Error, you either do not have enough ".$set['second_currency']." or did not fill out the form.<br />
<a href='".gen_url('exchange',true)."&spend=main'>Back</a>";
}
else
{
$iqgain=$_POST[$set['second_currency']]*$set['ct_moneypercrys'];
$db->query("UPDATE users SET `second` = `second`-{$_POST[$set['second_currency']]},`main` = `main`+$iqgain WHERE userid=$userid");
echo "You traded {$_POST[$set['second_currency']]} ".$set['second_currency']." for \$".number_format($iqgain).".";
}
}
}

$h->endpage();
?>
Link to comment
Share on other sites

Seems to work for me. Reduced my energy to 0 then used whats set as my second currency to refill.

Oh and this is the second currency Paul was boasting about isnt it. Well done you made it possible to name the cash and crystal fields in the database which was already there in all previous versions.

Edited by rulerofzu
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...