diff --git a/config.php b/config.php index 48323709..165fb7ce 100644 --- a/config.php +++ b/config.php @@ -85,6 +85,8 @@ $config = array( 'account_country' => true, // user will be able to set country of origin when registering account, this information will be viewable in others places aswell 'account_change_character_name' => false, // can user change their character name for premium points? 'account_change_character_name_points' => 30, // cost of name change + 'account_change_character_sex' => false, // can user change their character sex for premium points? + 'account_change_character_sex_points' => 30, // cost of sex change 'characters_per_account' => 10, // max. number of characters per account // mail diff --git a/templates/kathrine/images/buttons/_sbutton_change_name.gif b/images/buttons/_sbutton_change_name.gif similarity index 100% rename from templates/kathrine/images/buttons/_sbutton_change_name.gif rename to images/buttons/_sbutton_change_name.gif diff --git a/images/buttons/_sbutton_change_sex.gif b/images/buttons/_sbutton_change_sex.gif new file mode 100644 index 00000000..01b371ec Binary files /dev/null and b/images/buttons/_sbutton_change_sex.gif differ diff --git a/system/pages/accountmanagement.php b/system/pages/accountmanagement.php index 3ae895bf..76d1d8ef 100644 --- a/system/pages/accountmanagement.php +++ b/system/pages/accountmanagement.php @@ -293,7 +293,22 @@ Please enter your account name and your password.
-
+
+ + + + + + '; + } + if($config['account_change_character_sex']) { + echo ' + + + + + @@ -697,14 +712,14 @@ Please enter your account name and your password.
+
Edit Character Information



Name:'.$player_name.'
Hide Account:'; if($player->getCustomField("hidden") == 1) { - echo ''; + echo ''; } else { - echo ''; + echo ''; } - echo ' check to hide your account information'; + echo ''; if((int)$player->getCustomField('group_id') > 1) echo ' (you will be also hidden on the Team page!)'; @@ -727,12 +742,11 @@ Please enter your account name and your password.
'; $name_changed = false; - $player_id = isset($_POST['player_id']) ? $_POST['player_id'] : NULL; + $player_id = isset($_POST['player_id']) ? (int)$_POST['player_id'] : NULL; $newcharname = isset($_POST['newcharname']) ? stripslashes(ucwords(strtolower($_POST['newcharname']))) : NULL; if((!$config['account_change_character_name'])) echo 'You cant change your character name'; @@ -777,10 +791,10 @@ Please enter your account name and your password.
Character Name Changed
The character '.$old_name.' name has been changed to ' . $player->getName() . '.
'; } - else - { - $errors[] = 'Character '.$player_name.' is not on your account.'; - } + } + else + { + $errors[] = 'Character '.$player_name.' is not on your account.'; } } else @@ -826,6 +840,93 @@ Please enter your account name and your password.
getCustomField('premium_points'); + if(isset($_POST['changesexsave']) && $_POST['changesexsave'] == 1) { + if($points < $config['account_change_character_sex_points']) + $errors[] = 'You need ' . $config['account_change_character_sex_points'] . ' premium points to change sex. You have '.$points.' premium points.'; + + if(empty($errors) && $new_sex != 0 && $new_sex != 1) + $errors[] = 'This sex is invalid.'; + + if(empty($errors)) { + $player = $ots->createObject('Player'); + $player->load($player_id); + if($player->isLoaded()) { + $player_account = $player->getAccount(); + if($account_logged->getId() == $player_account->getId()) { + if($player->isOnline()) { + $errors[] = 'This character is online.'; + } + + if(empty($errors) && $player->getSex() == $new_sex) + $errors[] = 'Sex cannot be same'; + + if(empty($errors)) { + $sex_changed = true; + $old_sex = $player->getSex(); + $player->setSex($new_sex); + $sexes = array(0 => 'Female', 1 => 'Male'); + $player->save(); + $account_logged->setCustomField("premium_points", $points - $config['account_change_character_name_points']); + $account_logged->logAction('Changed sex on character ' . $player->getName() . ' from ' . $sexes[$old_sex] . ' to ' . $sexes[$new_sex] . '.'); + echo '
Character Sex Changed
The character '.$player->getName().' sex has been changed to ' . $sexes[$new_sex] . '.
'; + } + } + else + { + $errors[] = 'Character '.$player_name.' is not on your account.'; + } + } + else + { + $errors[] = 'Character with this name doesn\'t exist.'; + } + } + } + + if(!$sex_changed) { + if(!empty($errors)) { + echo '
The Following Errors Have Occurred:
'; + foreach($errors as $errors) { + echo '
  • '.$errors; + } + echo '

  • '; + } + echo 'To change a sex of character select player and choose a new sex.
    + Change sex cost ' . $config['account_change_character_sex_points'] . ' premium points. You have ' . $points . ' premium points.

    Change sex
    + + + + + + + + + +
    Character: + +
    New Sex: + +
    '; + } + } + } //### DELETE character from account ### if($action == "deletecharacter") { $player_name = isset($_POST['delete_name']) ? stripslashes($_POST['delete_name']) : NULL; diff --git a/templates/tibiacom/images/buttons/_sbutton_change_name.gif b/templates/tibiacom/images/buttons/_sbutton_change_name.gif deleted file mode 100644 index 026844d1..00000000 Binary files a/templates/tibiacom/images/buttons/_sbutton_change_name.gif and /dev/null differ