Parse error: parse error, unexpected '(' in //forums/Sources/shop/items/Multiplier.php on line 49
<?php
/**********************************************\
| For the SMFShop Mod |
| (c) 2006 Matkins70 |
| http://www.matkins70.com/ |
\**********************************************/
//File: Multiplier.php
// Item
//VERSION: 2.1 (Build 9)
//DATE: 05th September 2006
// $Id: Multiplier.php 17 2006-09-05 03:05:12Z Matkins70 $
class item_Multiplier extends itemTemplate {
function getItemDetails() {
$this->name = "Multiplier";
$this->desc = "Multiply your money in your pocket between -50% and +50%";
$this->price = 500;
$this->require_input = false;
$this->can_use_item = true;
}
//See AddToPostCount.php for more information
function getAddInput() {
return "Minimum percentage: <input type='text' name='info1' value='50'><br>
Maximum percentage: <input type='text' name='info2' value='150'>";
}
function onUse() {
global $db_prefix, $ID_MEMBER, $item_info;
//simple fix for the 'number expected' errors
if (!isset($item_info[1]) || $item_info[1] == "")
$item_info[1] = 50;
if (!isset($item_info[2]) || $item_info[2] == "")
$item_info[2] = 150;
$amount = mt_rand($item_info[1], $item_info[2]);
if ($amount > 0) {
$result = db_query("UPDATE {$db_prefix}members
SET money = money * ({$amount} / 100)
WHERE ID_MEMBER = {$ID_MEMBER}",
__FILE__, __LINE__);
return "You got a percentage of "($amount)". Multiplied with your money in your pocket, you now have ".formatMoney($row['money'])."!";
}
}
}
?>
return "You got a percentage of "($amount)". Multiplied with your money in your pocket, you now have ".formatMoney($row['money'])."!";
With:return("You got a percentage of {$amount}. Multiplied with your money in your pocket, you now have ".formatMoney($row['money'])."!");
Or:return("You got a percentage of ".$amount.". Multiplied with your money in your pocket, you now have ".formatMoney($row['money'])."!");
My only idea at the moment is to use the rand feature to generate a number between 1 - 100, and then that correspondes to the percentage. So 1-40 is 0 returns, 41-60 is 100 credits, etc, all the way to 100.Yeah, that's probably the best way to get weighed results... Something like
<?php
/**********************************************\
| For the SMFShop Mod |
| (c) 2006 Matkins70 |
| http://www.matkins70.com/ |
\**********************************************/
//File: Scratchcard.php
// Item
//VERSION: 2.1 (Build 9)
//DATE: 10th September 2006
// $Id: Scratchcard.php 17 2006-09-10 14:54:12Z Matkins70 $
class item_Scratchcard extends itemTemplate {
function getItemDetails() {
$this->name = "MatkinsScratchcard";
$this->desc = "MatkinsLotto presents the MatkinsScratchcard";
$this->price = 150;
$this->require_input = false;
$this->can_use_item = true;
}
function onUse() {
global $db_prefix, $ID_MEMBER, $item_info;
$rand = mt_rand(0,100);
if ($rand < 46) {
$winnings = 0;
} elseif (45 < $rand && $rand < 66) {
$winnings = 100;
} elseif (65 < $rand && $rand < 81) {
$winnings = 200;
} elseif (80 < $rand && $rand < 91) {
$winnings = 400;
} elseif (90 < $rand && $rand < 96) {
$winnings = 1000;
} elseif (95 < $rand && $rand < 100) {
$winnings = 2000;
} elseif ($rand = 100) {
$winnings = 4000;
}
if ($winnings > 0) {
$result = db_query("UPDATE {$db_prefix}members
SET money = money + {&winnings} WHERE ID_MEMBER = {$ID_MEMBER}",
__FILE__, __LINE__);
return "You find a grubby looking coin in your pocket. You eagerly scratch off the silver foil to reveal your winnings. You won ".formatmoney($winnings).". You go back to the shop and collect your winnings and shove them in your back pocket. Remember kids, gambling can be bad for your health. If you feel it's taking over your life, walk away.";
} elseif ($winnings = 0) {
return "You find a grubby looking coin in your pocket. You eagerly scratch off the silver foil to reveal your winnings. Sadly you won 0 credits. You curse under your breath and shake your fist in anger towards the sky. Remember kids, gambling can be bad for your health. If you feel it's taking over your life, walk away.";
}
}
}
?>
$rand = mt_rand(0,100);
if ($rand < 46) {
$winnings == 0;
} elseif (45 < $rand && $rand < 66) {
$winnings == 100;
} elseif (65 < $rand && $rand < 81) {
$winnings == 200;
} elseif ($rand == 100) {
$winnings = 4000;
}
...
} elseif ($winnings == 0) {
return "You find a grubby looking coin in your pocket. You eagerly scratch off the silver foil to reveal your winnings. Sadly you won 0 credits. You curse under your breath and shake your fist in anger towards the sky. Remember kids, gambling can be bad for your health. If you feel it's taking over your life, walk away.";
}
Thanks daniel. Basil had just beaten you to it with a personal message :P
Been updating a few things with the shop, quite a fun little project. I now have it set up so if someone gets a new highscore in the arcade, then they get given 50 credits. My multiplier is up, though im not completely happy with it, but all in due course.
My next task is to make a scratchcard. I think i mentioned it before. Im trying to think of the best way to get the weighted results, so that basically, there is a 40% chance of 0, 20% of 100 credits, 5% of X credits, and so on. My only idea at the moment is to use the rand feature to generate a number between 1 - 100, and then that correspondes to the percentage. So 1-40 is 0 returns, 41-60 is 100 credits, etc, all the way to 100.
Anyone think of a better solution, as im not very trusting of the random thing, as my results see a little strnage...
What, the Scratchcard? Err, I could post up the code i suppose.
Been updating a few things with the shop, quite a fun little project. I now have it set up so if someone gets a new highscore in the arcade, then they get given 50 credits.
//player has new high score and gets to comment - winner :)
{
if($context['arcade']['submit']['looser'] == '1')
{
db_query("
UPDATE {$db_prefix}members
SET money = (money + 250)
WHERE ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
echo '',$txt['arcade_1258'],' ',$txt['arcade_1262'],' ',$context['arcade']['submit']['score'],'<br />',$txt['arcade_1264'],'<br /><strong>You have received 500',$modSettings['shopCurrencySuffix'],'!</strong><br />', implode($txt['arcade_or'],$choice), '<br />';
What, the Scratchcard? Err, I could post up the code i suppose.
if(!isset ($row_check['plays']) )
{
Add this after: db_query("
UPDATE {$db_prefix}members
SET money = (money + 50)
WHERE ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
NOTE: Change the 50 to whatever amount you want to give the member playing for submitting a score for the first time... elseif((($gameSubmitArray['highscore']==0)&&($row_check['score']< $gameSubmitArray['score'])&&($row_check['plays'] >= 1 ))||(($gameSubmitArray['highscore']==1)&&($row_check['score']> $gameSubmitArray['score'])&&($row_check['plays'] >= 1 )))
{
add this after it: db_query("
UPDATE {$db_prefix}members
SET money = (money + 250)
WHERE ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
NOTE: Change the 250 to whatever you want them to get when they get a new high score (not champ) $results = db_query($sql, __FILE__, __LINE__);
$looser = '0';
}
//player is champion
elseif((($gameSubmitArray['highscore']==1) && ($gameSubmitArray['champion_score'] < $gameSubmitArray['score'])) || (($gameSubmitArray['highscore']==0) && ($gameSubmitArray['champion_score'] < $gameSubmitArray['score'])))
{
db_query("
UPDATE {$db_prefix}members
SET money = (money + 1000)
WHERE ID_MEMBER = $ID_MEMBER", __FILE__, __LINE__);
//update score, players number of plays, time played and total plays for the game
$sql = "UPDATE {$db_prefix}games_high "
. "SET score = {$gameSubmitArray['score']} , plays = plays+1, stime = {$gameSubmitArray['timenow']}, warning = {$gameSubmitArray['warning']},ptime = {$gameSubmitArray['timenow']}, playscore = {$gameSubmitArray['score']},duration = duration+{$gameSubmitArray['duration']},ip='{$ip}' "
. "WHERE id='{$row_check['id']}' ";
$results = db_query($sql, __FILE__, __LINE__);
//set for congrats in template */
$looser = '3';
}
NOTE: Again change the 1000 to the amount you want your members to receive for becoming the champion! if($context['arcade']['submit']['looser'] == '0')
echo '</',$txt['arcade_1260'],' ',$txt['arcade_1262'],' ',$context['arcade']['submit']['score'],'<br />',$txt['arcade_1264'],'<br /><strong>You have received 50 ',$modSettings['shopCurrencySuffix'],'!</strong> Just for playing this game!<br />', implode($txt['arcade_or'],$choice), '<br />';
if($context['arcade']['submit']['looser'] == '1')
echo '',$txt['arcade_1258'],' ',$txt['arcade_1262'],' ',$context['arcade']['submit']['score'],'<br />',$txt['arcade_1264'],'<br /><strong>You have received 250',$modSettings['shopCurrencySuffix'],'!</strong><br />', implode($txt['arcade_or'],$choice), '<br />';
//player has new high score and gets to comment - winner :)
{
if($context['arcade']['submit']['looser'] == '3')
{
echo '<strong>Congratulations! You are the new champion with the score of ',$context['arcade']['submit']['score'],'!<br />You have received 1000',$modSettings['shopCurrencySuffix'],' as a prize!</strong><br />', implode($txt['arcade_or'],$choice), '<br />'; }