Hi all. I've been working on some new code for my forums and I'm close to done. I just finished testing my latest addition and it is working, but I was hoping to get some suggestions on it.
PHP Code:
$find_monster = $test->db->query_first("SELECT m_equipment FROM test_monster where m_enc_loc='{$test->user['current_place']}'");
$find_equipment = $find_monster['m_equipment'];
$first_token = strtok($find_equipment, '{');
$second_token = strtok('}');
$full_equipment = explode(";", $second_token);
$equipment_head = $full_equipment[1];
$equipment_chest = $full_equipment[3];
$equipment_lhand = $full_equipment[5]; //shield
$equipment_rhand = $full_equipment[7]; //weapon
$equipment_feet = $full_equipment[9];
if ($equipment_lhand == 's:1:"8"') { $current_shield = "Wooden Shield"; $level_shield = 1; $cost_shield = "MAX"; }
// ##########################################################################
if ($test->input['do'] == 'guard_shield') {
if ($equipment_lhand == 's:1:"0"') {
$full_equipment[5] = 's:1:"8"';
$rebuild_equipment = array($full_equipment[0], $full_equipment[1], $full_equipment[2], $full_equipment[3], $full_equipment[4], $full_equipment[5], $full_equipment[6], $full_equipment[7], $full_equipment[8], $full_equipment[9]);
$rebuild_mid = implode(";", $rebuild_equipment);
$rebuild_done = 'a:5:{' . $rebuild_mid . ';}';
$test->db->query_write("update test_monster set m_equipment='{$rebuild_done}' where m_enc_loc='{$test->user['current_place']}'");
}
$test->redirect($test->lang['purchased_land'], 'test.php?' . $test->system->systemvars['session'] . 'do=place&id=' . $test->user['current_place']);
}
I know it probably isn't the best way to accomplish my goals, but like I said...it does work. I'm just wondering if anyone can make suggestions on how I can make it better. I still have to add more if statements depending on many different variables.
Thanks!