• 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!

[GESIOR 2012] Change name for premium points

Gesior.pl

Mega Noob&LOL 2012
Senator
Joined
Sep 18, 2007
Messages
2,965
Solutions
99
Reaction score
3,375
Location
Poland
GitHub
gesior
Very simple script to change name of player for premium points (like in old acc. maker Shop).
wEOKZ.png

1. Create file changename.php in folder pages
2. Paste into it:
PHP:
<?php
if(!defined('INITIALIZED'))
    exit;

$changeNameCost = 600;

if($logged)
{
    if($account_logged->getCustomField('premium_points') >= $changeNameCost)
    {
        if($action == "")
        {
            echo '<span style="color:red;font-weight:bold">CHANGE NAME COSTS ' . $changeNameCost . ' PREMIUM POINTS!</span><br />';
            echo '<form action="" mathod="post">';
            echo '<input type="hidden" name="subtopic" value="changename" />';
            echo '<input type="hidden" name="action" value="change" />';
            echo '<b>Select player: </b><select name="player_id">';
            $account_players = $account_logged->getPlayersList();
            foreach($account_players as $player)
            {
                echo '<option value="' . $player->getID() . '">' . htmlspecialchars($player->getName()) . '</option>';
            }
            echo '</select><br />';
            echo '<b>New name: </b><input type="text" name="new_name" value="" /><br />';
            echo '<input type="submit" value="Change name" />';
            echo '</form>';
        }
        elseif($action == "change")
        {
            $newchar_errors = array();
            $newchar_name = ucwords(strtolower(trim($_REQUEST['new_name'])));
            if(empty($newchar_name))
                $newchar_errors[] = 'Please enter a new name for your character!';
            if(!check_name_new_char($newchar_name))
                $newchar_errors[] = 'This name contains invalid letters, words or format. Please use only a-Z, - , \' and space.';
            $check_name_in_database = new Player();
            $check_name_in_database->find($newchar_name);
            if($check_name_in_database->isLoaded())
                $newchar_errors[] = 'This name is already used. Please choose another name!';

            $charToEdit = new Player($_REQUEST['player_id']);
            if(!$charToEdit->isLoaded())
                $newchar_errors[] = 'This player does not exist.';
            if($charToEdit->isOnline())
                $newchar_errors[] = 'This player is ONLINE. Logout first.';
            elseif($account_logged->getID() != $charToEdit->getAccountID())
                $newchar_errors[] = 'This player is not on your account.';

            if(empty($newchar_errors))
            {
                echo 'Name of character <b>' . htmlspecialchars($charToEdit->getName()) . '</b> changed to <b>' . htmlspecialchars($newchar_name) . '</b>';
                $charToEdit->setName($newchar_name);
                $charToEdit->save();
                $account_logged->setCustomField('premium_points', $account_logged->getCustomField('premium_points') - $changeNameCost);
            }
            else
            {
                echo 'Some errors occured:<br />';
                foreach($newchar_errors as $e)
                {
                    echo '<li>' . $e . '</li>';
                }
                echo '<br /><a href="?subtopic=changename"><b>BACK</b></a>';
            }
        }
    }
    else
        echo 'You don\'t have premium points. You need ' . $changeNameCost . '.';
}
else
    echo 'You must login first.';
3. In your layout add link to page: index.php?subtopic=changename (do not ask me how)

EDIT:
Fixed problem with online players. Character must be offline when you change it's name.
 
Last edited:
3. In your layout add link to page: index.php?subtopic=changename (do not ask me how)

How do I add that?





Joking <3, thanks needed this
WibbenZ
 
Finally found this :) thanks man!
Also could you add "Former name" like in rl tibia website? So it will display previous nickname in characters page
 
Finally found this :) thanks man!
Also could you add "Former name" like in rl tibia website? So it will display previous nickname in characters page
It's possible for TFS 0.3.6 and 0.4, but some other TFSes (0.2 and 1.0) would be not compatible with it (in TFS 0.3.6/0.4 there is table player_namelocks that store old names, in 1.0 in this table is list of active name locks).

#topic

Someone reported me problem [button 'Change' did not work on his PC] with this script. You need to change line:
PHP:
echo '<form action="" mathod="post">';

With:
PHP:
echo '<form action="?r=' . rand(0,10000) . '" method="post">';
 
It's possible for TFS 0.3.6 and 0.4, but some other TFSes (0.2 and 1.0) would be not compatible with it (in TFS 0.3.6/0.4 there is table player_namelocks that store old names, in 1.0 in this table is list of active name locks).
Is there a way to make it work with PHP? Like get & store last username, alter namelocks table with old_name or something and then insert old name to this table.
 
Can Any One Help Me To Make Steep 3 In your layout add link to page: index.php?subtopic=changename (do not ask me how)
Pliz Put Video How To Make Steep 3 Or Say To Me
 
Can Any One Help Me To Make Steep 3 In your layout add link to page: index.php?subtopic=changename (do not ask me how)
Pliz Put Video How To Make Steep 3 Or Say To Me
if u dont know how to do simple html / tiny bit of php, then you shouldnt start with OT...
 
When Your Mother Bear You You Was Know All Things At Web Site? I Want Learn How To make Step 3
 
Back
Top