hahaha yah tonight someone succeeded in robbing the bank. He bought 5 of them and used them trying. I had it set to 10%. but, becuse he robbed it, I changed the code a bit. If you fail, it will now take all your money and then some, give you 100 neg karma and take away all your items. This will prevent people from stockpiling ROB THE BANK items and trying all night long, even though it's HELLA expensive to buy one. Here's my updated code (still the PM isn't quite right):
<?php
/**********************************************\
| SMFSHOP (Shop MOD for Simple Machines Forum) |
| (c) 2005 DanSoft Australia |
| http://www.dansoftaustralia.com/ |
\**********************************************/
//File: RobTheBank.php
// % chance to steal from all members in the bank
// on success, awards robber between 20 and 80% of the sum of all bank accounts
// and reduces bank accounts accordingly and gives 10 negative karma.
// On failure, gives -100 karma and sets money and bank money to 0 for robber.
//VERSION: 1.0 (Build 1)
//DATE: Sep 26th, 2006
// $Id: RobTheBank.php chadk $
class item_RobTheBank extends itemTemplate {
function getItemDetails() {
$this->name = "Rob the bank!";
$this->desc = "You can try to ROB THE BANK! This gives you a CHANCE to steal a portion of the money from EVERYONES bank account! Note: Karma is NOT BLIND! Even if you rob the bank, there may be consequences!";
$this->price = 1000;
$this->require_input = false;
$this->can_use_item = true;
}
//see AddToPostCount.php for more infos
function getAddInput() {
return "Probability of successful robbery: <input type='text' name='info1' value='10'>%";
}
function onUse() {
global $db_prefix, $ID_MEMBER, $item_info, $user;
$pmfrom = array(
'id' => 1,
'name' => 'Chad',
'username' => 'Chad'
);
$pmto = array(
'to' => array(1),
'bcc' => array()
);
//get a random number between 0 and 100
$try = mt_rand(0, 100);
//if successfull
if ($try < $item_info[1]) {
//get stealee's money count
$result = db_query("SELECT sum(moneyBank) as vault
FROM {$db_prefix}members", __FILE__, __LINE__);
$row = mysql_fetch_array($result, MYSQL_ASSOC);
//get random amount between 0 and amount of money stealee has
$steal_amount = 1-(mt_rand(10,60)/100);
//take this money away from stealee...
$result = db_query("UPDATE {$db_prefix}members
SET moneyBank = moneyBank * {$steal_amount}", __FILE__, __LINE__);
//...and give to stealer (robber)
$steal_amount = ($steal_amount-1) * -1 * $row['vault'];
$result = db_query("UPDATE {$db_prefix}members
SET money = money + {$steal_amount}, karmaBad = karmaBad + 10
WHERE ID_MEMBER = {$ID_MEMBER}
LIMIT 1", __FILE__, __LINE__);
sendpm($pmto, 'Bank Robbed!', "{$user} Robbed the bank for {$steal_amount}", 0, $pmfrom);
return "You ROBBED THE BANK for $steal_amount! Thief! Your Karma is STILL reduced by 10! (Karma isn't blind!)";
} else {
//if reducing Karma doesn't work, replace
//'karmaBad = karmaBad + 10' with 'karmaGood = karmaGood - 10'
$result = db_query("UPDATE {$db_prefix}members
SET karmaBad = karmaBad + 100,
money = -100, moneyBank = -500
WHERE ID_MEMBER = {$ID_MEMBER}",
__FILE__, __LINE__);
$result = db_query("DELETE FROM {$db_prefix}shop_inventory
WHERE ownerid = {$ID_MEMBER}",
__FILE__, __LINE__);
sendpm($pmto, 'Bank Robbery Foiled!', "{$user} was BUSTED!", 0, $pmfrom);
return "Steal <b>unsuccessful!</b> You Karma is now reduced by 100!";
}
}
}
?>