Fencore Team
New Member
- Joined
- Sep 2, 2016
- Messages
- 37
- Reaction score
- 2
Hello there,
This scripts lets you change your name for premium points (The script was made by GESIOR what i have done is added FORMER name to it so on a characters profile page Characters Former name will be displayed)
Step 1.
First create a new row in your accounts structure (phpMyAdmin)
Step 2.
Create a file called changename.php in your Pages folder and Paste there this script :
Step 3.
Edit your players classes file.
Go to your classes folder in your main website directory and find player.php
Find line
and after that add 'former'
so example :
next find
after that add a new line :
SAVE THE FILE .
We are ready now just add a new column called Former name in your character profile. To do it go to characters.php in your PAGES folder and open it. Find :
after that add :
Here is an example how it looks on my website (I use bootstrap so its a bit different) :
This scripts lets you change your name for premium points (The script was made by GESIOR what i have done is added FORMER name to it so on a characters profile page Characters Former name will be displayed)
Step 1.
First create a new row in your accounts structure (phpMyAdmin)
Step 2.
Create a file called changename.php in your Pages folder and Paste there this script :
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->setCustomField('former', $charToEdit->getName());
$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.';
Step 3.
Edit your players classes file.
Go to your classes folder in your main website directory and find player.php
Find line
PHP:
public static $fields = array('id', 'name',
and after that add 'former'
so example :
PHP:
public static $fields = array('id', 'name','former', 'group_id'.......
next find
PHP:
public function getID()
PHP:
public function getFormer(){return $this->data['former'];}
SAVE THE FILE .
We are ready now just add a new column called Former name in your character profile. To do it go to characters.php in your PAGES folder and open it. Find :
PHP:
$main_content .= '<tr bgcolor="' . $bgcolor . '"><td width="20%">Name:</td><td style="font-weight:bold;color:' . (($player->isOnline()) ? 'green' : 'red') . '">' . htmlspecialchars($player->getName()) . ' ' . $skull . ' <img src="' . $config['site']['flag_images_url'] . $account->getFlag() . $config['site']['flag_images_extension'] . '" title="Country: ' . $account->getFlag() . '" alt="' . $account->getFlag() . '" />';
if($player->isBanned() || $account->isBanned())
$main_content .= '<span style="color:red">[BANNED]</span>';
if($player->isNamelocked())
$main_content .= '<span style="color:red">[NAMELOCKED]</span>';
$main_content .= '<br /><img src="' . $config['site']['outfit_images_url'] . '?id=' . $player->getLookType() . '&addons=' . $player->getLookAddons() . '&head=' . $player->getLookHead() . '&body=' . $player->getLookBody() . '&legs=' . $player->getLookLegs() . '&feet=' . $player->getLookFeet() . '" alt="" /></td></tr>';
after that add :
PHP:
$main_content .= '<tr bgcolor="' . $bgcolor . '"><td width="20%">Former Name:</td><td >
' . htmlspecialchars($player->getFormer()) . '</td></tr>
Here is an example how it looks on my website (I use bootstrap so its a bit different) :