The code isFATAL ERROR: Failed to update player data granary=111111111,loft=0,treasury='' for user #1!
You have completed the transaction. Results:
Gave 1,111 runes.
code: Select all
<?
include("header.php");
//is officer?
$officer = 0;
if($users[num] == $stockpile[founder] || $users[num] == $stockpile[asst] || $users[num] == $stockpile[fa1] || $users[num] == $stockpile[fa2]) {
$officer = 1;
}
// Mods for how much food/cash/or runes
$cash_mod = 200; // net * what = limit;
$food_mod = 150/$config[food]; // net * what = limit;
$rune_mod = $food_mod; // net * what = limit;
// Find the total net of stockpile.
$totalnet = sqleval("SELECT sum(networth) FROM $stockpiledb WHERE land>0 AND disabled != 2 AND stockpile=$users[stockpile];");
// Limits
$limit_food = $food_mod * 1000000;
$limit_cash = 1000000 * $cash_mod;
$limit_rune = 1000000 * $rune_mod;
$show_limit_food = $limit_food;
$show_limit_cash = $limit_cash;
$show_limit_rune = $limit_rune;
if($limit_food < $stockpile[granary])
$limit_food = $stockpile[granary];
if($limit_cash < $stockpile[stockpile])
$limit_cash = $stockpile[stockpile];
if($limit_rune < $stockpile[loft])
$limit_rune = $stockpile[loft];
$ucglimit = min($users[cash], $limit_cash-$stockpile[stockpile]);
$ufglimit = min($users[food], $limit_food-$stockpile[granary]);
$urglimit = min($users[runes], $limit_rune-$stockpile[loft]);
$uctlimit = $stockpile[stockpile];
$uftlimit = $stockpile[granary];
$urtlimit = $stockpile[loft];
if($stok_ch_open) {
$stok = $stockpile['stok_open'];
if($stok)
$stok = 0;
else
$stok = 1;
$stockpile['stok_open'] = $stok;
savestockpileData($stockpile, "stok_open");
}
if($do_transaction) {
// Fix our Input(s)
//echo "Cash T: $cash_take";
fixInputNum($food_take);
fixInputNum($food_give);
fixInputNum($rune_take);
fixInputNum($rune_give);
fixInputNum($cash_take);
fixInputNum($cash_give);
//echo "Cash T: $cash_take";
if(!empty($_POST['ctmax'])) $cash_take = $uctlimit;
if(!empty($_POST['ftmax'])) $food_take = $uftlimit;
if(!empty($_POST['rtmax'])) $rune_take = $urtlimit;
if(!empty($_POST['cgmax'])) $cash_give = $ucglimit;
if(!empty($_POST['fgmax'])) $food_give = $ufglimit;
if(!empty($_POST['rgmax'])) $rune_give = $urglimit;
if($cash_give - $cash_take == 0 &&
$food_give - $food_take == 0 &&
$rune_give - $rune_take == 0)
TheEnd("You're not doing anything in that transaction!");
// Negative number?
if($cash_take < 0 || $cash_give < 0 || $rune_take < 0 || $rune_give < 0 || $food_take < 0 || $food_give < 0)
TheEnd("You may not take or give a negative amount");
// Giving too much?
if($cash_give > $users[cash] || $rune_give > $users[runes] || $food_give > $users[food])
TheEnd("You don't have enough to deposit");
// Taking too much?
if($cash_take > $stockpile[stockpile] || $rune_take > $stockpile[loft] || $food_take > $stockpile[granary])
TheEnd("You can't take that much.");
// Give to user
$users[food] += $food_take;
$stockpile[granary] -= $food_take;
$users[cash] += $cash_take;
$stockpile[stockpile] -= $cash_take;
$users[runes] += $rune_take;
$stockpile[loft] -= $rune_take;
// Give to stockpile
$users[food] -= $food_give;
$stockpile[granary] += $food_give;
$users[cash] -= $cash_give;
$stockpile[stockpile] += $cash_give;
$users[runes] -= $rune_give;
$stockpile[loft] += $rune_give;
// Safety checks... incase I've missed it somewhere else
if($stockpile[loft] < 0 || $stockpile[stockpile] < 0 || $stockpile[granary] < 0)
TheEnd("You can't take that much.");
if($users[runes] < 0 || $users[cash] < 0 || $users[food] < 0)
TheEnd("You can't give that much.");
// Over the limit?
if($stockpile[granary] > $limit_food || $stockpile[stockpile] > $limit_cash || $stockpile[loft] > $limit_rune)
TheEnd("You can't give that much.");
if($stockpile['stok_open'] == 0 && $officer == 0) {
if($cash_take > 0 || $rune_take > 0 || $food_take > 0)
TheEnd("Sorry, only the stockpile officers may take from the stockpile stockpile at this time!");
}
// Save up data
saveUserDataNet($users, "food cash runes networth");
saveUserData($users, "granary loft treasury");
// Output
$transaction = "";
if($cash_give > 0) $transaction .= "Gave \$" . commas($cash_give) . ". \n<br>";
if($cash_take > 0) $transaction .= "Took \$" . commas($cash_take) . ". \n<br>";
if($food_give > 0) $transaction .= "Gave " . commas($food_give) . " food. \n<br>";
if($food_take > 0) $transaction .= "Took " . commas($food_take) . " food. \n<br>";
if($rune_give > 0) $transaction .= "Gave " . commas($rune_give) . " runes. \n<br>";
if($rune_take > 0) $transaction .= "Took " . commas($rune_take) . " runes. \n<br>";
{
if($member[num] != $users[num] )
addNews(501, array(stockpile1=>$users[stockpile], id1=>$member[num], id2=>$users[num], food1=>($food_give-$food_take),
cash1=>($cash_give-$cash_take),
runes1=>($rune_give-$rune_take)));
//News to members
if($member[num] == $users[num] )
addNews(502, array(stockpile1=>$users[stockpile], id1=>$users[num], food1=>($food_give-$food_take),
cash1=>($cash_give-$cash_take),
runes1=>($rune_give-$rune_take)));
//News to self
}
$tpl->assign("trans", $transaction);
// Send to stockpile leader? Store in table?
}
$co = 'Open';
$nco = 'Open';
if($stockpile['stok_open']) {
$co = 'Open';
$nco = 'Open';
}
// Assign to template.
$tpl->assign('limit_food', commas($show_limit_food));
$tpl->assign('limit_rune', commas($show_limit_rune));
$tpl->assign('limit_cash', commas($show_limit_cash));
$tpl->assign('officer', $officer);
$tpl->assign('stok_open', $co);
$tpl->assign('nco', $nco);
$tpl->assign('curr_food', commas($stockpile[granary]));
$tpl->assign('curr_rune', commas($stockpile[loft]));
$tpl->assign('curr_cash', commas($stockpile[stockpile]));
$tpl->assign('stockpile_name', $stockpile[name]);
if($transaction != "") $tpl->assign('trans', $transaction);
$tpl->display('stockpile.html');
echo "<hr>";
include("stok-news.php");
TheEnd('');
?>
I would be greatful if anyone could help out.
~Slasher

