From 170eaec9b04567b31f081e1201858621e067f8e2 Mon Sep 17 00:00:00 2001 From: slawkens1 Date: Fri, 19 May 2017 03:31:29 +0200 Subject: [PATCH] added option to change character sex for premium points --- config.php | 2 + .../buttons/_sbutton_change_name.gif | Bin images/buttons/_sbutton_change_sex.gif | Bin 0 -> 1541 bytes system/pages/accountmanagement.php | 121 ++++++++++++++++-- .../images/buttons/_sbutton_change_name.gif | Bin 545 -> 0 bytes 5 files changed, 113 insertions(+), 10 deletions(-) rename {templates/kathrine/images => images}/buttons/_sbutton_change_name.gif (100%) create mode 100644 images/buttons/_sbutton_change_sex.gif delete mode 100644 templates/tibiacom/images/buttons/_sbutton_change_name.gif 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 0000000000000000000000000000000000000000..01b371ecc0a27ccf187484a730b8805a5043b08f GIT binary patch literal 1541 zcmcK4i93`D0LSt79pk=+F&cyB9p_}p87j4dFyqKMj7c$!Az_^%gJF^}jAJaKaT^=j zawKQFj-0t7M^aHwE8Dh@j%^>$vzvYW5&L~U|HAL*LUFb|$;bmVfSoM>4g>)N2udIj zNC}vPBn&AbC5e=lLdr->%F0N|$x6%1Nh`?9D9Xz!Daa}-%A=IzRg_^0swf5YAw`U; z5(cfTj#fT`Mqx214VbzL4t7LE6RWDFf!4;U9mT2PHDMUM76v+`PS8?^wABf)qv|?G zkLbeiSUo&e7sBd68u}1UpP*qtz!7ycjr6pPiTLA0yy-E>{5zPAg)!l@74eMqF~?KK z9qo=goiTMeYexRw+?8bEYH#80XyxH(<>_SY=8q+AJhjSX>+3w2Kn zKcCF75ekofhSD?TT+&v|oC(9~%}!Wyktw#8R{3{Ie4Sa}sGeiF9rv zJwNr5AU#CDW)!hQ1R0^l8H`d+n2-}*#$lFoSruGXWo|@eZe&$%L{;A9Tf8U{FRCX0 zN=-p@ePK+kAf`?bT`!1fERJn1i4&K`|0IlWDNDFlmC|)9ty2WM)+I{ou1W8zP4B5o ze^AHnYslzt%e0>ZiK^|1>Nk_O-cHrLofiFesAgxT zW@onc-E7^vx!T>iy4|_@-{PU zP&~WsJL*TcGH9cqsg8!RJe01hh}_vYUVycX+MMca znkgnZmLkKtf{^m>R&$dH_Xp5)GV(m1jZZK^4~@x=GvE z4WBixU(Zsy_N@V^HW}Id0nsc>71P?e5q8VnL7tx$@Es-;BUN3D9B~IAjgkC~KCHdU zVvIbI29lb$MHGO^9ZrkUF7czCmHCu!{D}6(CleV+RyDQmb5b?a3eq1j1B4bXXj>G7 z;Tv@kOTgB59kRZ_yU-1Li1k;4TKnyfNM$^<$MAFz-WQ~KAcp5`{QRez1B{5HvoE;UDI zC>mX8m<_B?=souPJfj_`E!rDZJP4cC
-
+
+ + + + + + '; + } + if($config['account_change_character_sex']) { + echo ' + + + + + @@ -697,14 +712,14 @@ Please enter your account name and your password.
+



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 026844d1c71aebe906231e86f0ca2e09dd6e908d..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 545 zcmZ?wbhEHbY-f;UXc1)q0!Bt4Vq^j$CPro^CKhHUR#ukxmzI3EwB-HeB_BX&>Bq}U zK3-n>{>su1R~CP`vgE^+r5~>>`FLgNe?ma_f1m*>dH6WO$dZ=3v% zT_U_0+?*M^4l5l?bV=B7NJ+TB|3Xoe$9mf z3}RgdicHdtfj2z3+fo=?+xdU~^!8ZleXzNdWnVFeprU!wf0m7v2MQh?6Uv#dCi9@# zM@4AT%WElfI2}|^D+OFpnItLDY1d=R*dTJyO;mmQPp_<)TOT4snR!Kg7MHj1dT=_d zR*QUYz^SNV5Y4uC*46vFJu?nTF*-N|iU+E-%HEnX_0g7)XBU<@sfTG#**Ur5)>iJ+ z^%B$S`c!TPpW~NL>k@u0xMfD+lhdD0^}bXT={2dF?Oc5BsOy$YMRWhvac6gJeSLjH M^67cLN-PZ40B%0>rT_o{