• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

AAC Undelet character option

bpm91

Advanced OT User
Joined
May 23, 2019
Messages
1,046
Solutions
7
Reaction score
180
Location
Brazil
YouTube
caruniawikibr
Hello, I would like to know if anyone has already done this or also has this doubt about how to add time to delete the character. example 7 days. and the option to cancel the deletion if the person opts out within 7 days.
Myaac
PHP:
<?php
/**
 * Delete character
 *
 * @package   MyAAC
 * @author    Gesior <[email protected]>
 * @author    Slawkens <[email protected]>
 * @copyright 2019 MyAAC
 * @link      https://my-aac.org
 */
defined('MYAAC') or die('Direct access not allowed!');

$player_name = isset($_POST['delete_name']) ? stripslashes($_POST['delete_name']) : NULL;
$password_verify = isset($_POST['delete_password']) ? $_POST['delete_password'] : NULL;
$password_verify = encrypt(($config_salt_enabled ? $account_logged->getCustomField('salt') : '') . $password_verify);
if(isset($_POST['deletecharactersave']) && $_POST['deletecharactersave'] == 1) {
    if(!empty($player_name) && !empty($password_verify)) {
        if(Validator::characterName($player_name)) {
            $player = new OTS_Player();
            $player->find($player_name);
            if($player->isLoaded()) {
                $player_account = $player->getAccount();
                if($account_logged->getId() == $player_account->getId()) {
                    if($password_verify == $account_logged->getPassword()) {
                        if(!$player->isOnline()) {
                            if(!$player->isDeleted()) {
                                if(fieldExist('id', 'houses')) {
                                    $house = $db->query('SELECT `id` FROM `houses` WHERE `owner` = '.$player->getId());
                                    if($house->rowCount() > 0) {
                                        $errors[] = 'You cannot delete a character when they own a home.';
                                    }
                                }

                                $ownerid = 'ownerid';
                                if($db->hasColumn('guilds', 'owner_id'))
                                    $ownerid = 'owner_id';
                                $guild = $db->query('SELECT `name` FROM `guilds` WHERE `' . $ownerid . '` = '.$player->getId());
                                if($guild->rowCount() > 0) {
                                    $errors[] = 'You cannot delete a character when they own a guild.';
                                }

                                if(empty($errors)) {
                                    //dont show table "delete character" again
                                    $show_form = false;
                                    //delete player
                                    if ($db->hasColumn('players', 'deletion'))
                                        $player->setCustomField('deletion', 1);
                                    else
                                        $player->setCustomField('deleted', 1);
                                    $account_logged->logAction('Deleted character <b>' . $player->getName() . '</b>.');
                                    $twig->display('success.html.twig', array(
                                        'title' => 'Character Deleted',
                                        'description' => 'The character <b>' . $player_name . '</b> has been deleted.'
                                    ));
                                }
                            }
                            else {
                                $errors[] = 'This player has been already deleted.';
                            }
                        }
                        else {
                            $errors[] = 'This character is online.';
                        }
                    }
                    else {
                        $errors[] = 'Wrong password to account.';
                    }
                }
                else {
                    $errors[] = 'Character <b>'.$player_name.'</b> is not on your account.';
                }
            }
            else {
                $errors[] = 'Character with this name doesn\'t exist.';
            }
        }
        else {
            $errors[] = 'Name contain illegal characters.';
        }
    }
    else {
        $errors[] = 'Character name or/and password is empty. Please fill in form.';
    }
}
if($show_form) {
    if(!empty($errors)) {
        $twig->display('error_box.html.twig', array('errors' => $errors));
    }
    $twig->display('account.delete_character.html.twig');
}

Twig.
PHP:
To delete a character enter the name of the character and your password.<br/><br/>
<form action="{{ getLink('account/character/delete') }}" method="post">
    <input type="hidden" name="deletecharactersave" value="1"/>
    <div class="TableContainer">
        <table class="Table1" cellpadding="0" cellspacing="0" >
            <div class="CaptionContainer">
                <div class="CaptionInnerContainer">
                    <span class="CaptionEdgeLeftTop" style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);"></span>
                    <span class="CaptionEdgeRightTop" style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);"></span>
                    <span class="CaptionBorderTop" style="background-image:url({{ template_path }}/images/content/table-headline-border.gif);"></span>
                    <span class="CaptionVerticalLeft" style="background-image:url({{ template_path }}/images/content/box-frame-vertical.gif);"></span>
                    <div class="Text" >Delete Character</div>
                    <span class="CaptionVerticalRight" style="background-image:url({{ template_path }}/images/content/box-frame-vertical.gif);"></span>
                    <span class="CaptionBorderBottom" style="background-image:url({{ template_path }}/images/content/table-headline-border.gif);"></span>
                    <span class="CaptionEdgeLeftBottom" style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);"></span>
                    <span class="CaptionEdgeRightBottom" style="background-image:url({{ template_path }}/images/content/box-frame-edge.gif);"></span>
                </div>
            </div>
            <tr>
                <td>
                    <div class="InnerTableContainer">
                        <table style="width:100%;">
                            <tr>
                                <td class="LabelV" ><span>Character Name:</span></td>
                                <td style="width:90%;">
                                    <input name="delete_name" value="" size="30" maxlength="29"/>
                                </td>
                            </tr>
                            <tr>
                                <td class="LabelV" ><span>Password:</span></td>
                                <td>
                                    <input type="password" name="delete_password" size="30" maxlength="29"/>
                                </td>
                            </tr>
                        </table>
                    </div>
                </td>
            </tr>
        </table>
    </div>
    <br/>
    <table style="width:100%">
        <tr align="center">
            <td>
                <table border="0" cellspacing="0" cellpadding="0">
                    <tr>
                        <td style="border:0px;">
                            {{ include('buttons.submit.html.twig') }}
                        </td>
                    <tr>
</form>
                </table>
            </td>
            <td>
                <table border="0" cellspacing="0" cellpadding="0">
                    <form action="{{ getLink('account/manage') }}" method="post">
                        <tr>
                            <td style="border:0px;">
                                {{ include('buttons.back.html.twig') }}
                            </td>
                        </tr>
                    </form>
                </table>
            </td>
        </tr>
    </table>
 
Back
Top