Sarcoth
08-02-2007, 07:14 PM
Can you find any reason why this code would occasionally remove double the money from the user?
if ($test->input['do'] == 'ownedby') {
$Location = $test->db->query_first("select p_legend, ownedby from test_place where pid='{$test->user['current_place']}'");
if ($Location['p_legend'] == 7) { $Land_Cost = 2; $Land_Tier = 1; }
if ($Location['p_legend'] == 8) { $Land_Cost = 4; $Land_Tier = 2; }
if ($Location['p_legend'] == 9) { $Land_Cost = 6; $Land_Tier = 3; }
if ($Location['p_legend'] == 10) { $Land_Cost = 8; $Land_Tier = 4; }
if ($Location['p_legend'] == 11) { $Land_Cost = 10; $Land_Tier = 5; }
if ($Location['p_legend'] == 12) { $Land_Cost = 12; $Land_Tier = 6; }
if ($Location['p_legend'] == 14) { $Land_Cost = 14; $Land_Tier = 7; }
if ($test->user['money'] < $Land_Cost) {
$test->error($test->parse_lang($test->lang['not_enough_money_for_ts'], $test->lang['money']));
}
if ($Land_Cost > 0) {
$test->db->query("update test_user set money=money-'{$Land_Cost}' where uid='{$test->user['uid']}'");
$result = $test->db->query("SELECT uid, current_place FROM test_user where current_place='{$test->user['current_place']}'");
while($row = $test->db->fetch_array($result)) {
if ($test->user['uid'] != $row['uid']) {
$test->db->query_write("update test_user set current_place='60' where uid='{$row['uid']}'");
}
}
$test->db->query("update test_place set ownedby='{$test->user['uid']}' where pid='{$test->user['current_place']}'");
}
$test->redirect($test->lang['purchased_land'], 'test.php?' . $test->system->systemvars['session'] . 'do=place&id=' . $test->user['current_place']);
}
I'll do my best to explain if you have any questions. I've been working on this for a couple days now and everything I try still causes it to occur twice now and then.
Thanks.
if ($test->input['do'] == 'ownedby') {
$Location = $test->db->query_first("select p_legend, ownedby from test_place where pid='{$test->user['current_place']}'");
if ($Location['p_legend'] == 7) { $Land_Cost = 2; $Land_Tier = 1; }
if ($Location['p_legend'] == 8) { $Land_Cost = 4; $Land_Tier = 2; }
if ($Location['p_legend'] == 9) { $Land_Cost = 6; $Land_Tier = 3; }
if ($Location['p_legend'] == 10) { $Land_Cost = 8; $Land_Tier = 4; }
if ($Location['p_legend'] == 11) { $Land_Cost = 10; $Land_Tier = 5; }
if ($Location['p_legend'] == 12) { $Land_Cost = 12; $Land_Tier = 6; }
if ($Location['p_legend'] == 14) { $Land_Cost = 14; $Land_Tier = 7; }
if ($test->user['money'] < $Land_Cost) {
$test->error($test->parse_lang($test->lang['not_enough_money_for_ts'], $test->lang['money']));
}
if ($Land_Cost > 0) {
$test->db->query("update test_user set money=money-'{$Land_Cost}' where uid='{$test->user['uid']}'");
$result = $test->db->query("SELECT uid, current_place FROM test_user where current_place='{$test->user['current_place']}'");
while($row = $test->db->fetch_array($result)) {
if ($test->user['uid'] != $row['uid']) {
$test->db->query_write("update test_user set current_place='60' where uid='{$row['uid']}'");
}
}
$test->db->query("update test_place set ownedby='{$test->user['uid']}' where pid='{$test->user['current_place']}'");
}
$test->redirect($test->lang['purchased_land'], 'test.php?' . $test->system->systemvars['session'] . 'do=place&id=' . $test->user['current_place']);
}
I'll do my best to explain if you have any questions. I've been working on this for a couple days now and everything I try still causes it to occur twice now and then.
Thanks.