• 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 yelp namelock myaac

Mjmackan

Mapper ~ Writer
Premium User
Joined
Jul 18, 2009
Messages
1,424
Solutions
15
Reaction score
176
Location
Sweden
Using the original change name from myaac, but I wanted to add a lil spice.

The outcome I want: Characters thats in your account that is namelocked gets listed in container.
The outcome I have right now: No characters listed.

I know this might not even be remotely close, but as the logic I went with first didn't work either I tried to mess around, without success. Anyone willing to help & explain?
PHP:
            <tr>
                <td>
                    <div class="InnerTableContainer" >
                        <table style="width:100%;" >
                            <tr>
                                <td class="LabelV" ><span>Character:</span></td>
                                <td style="width:90%;" >
                                    <select name="player_id">
                                        {% for player in account_logged.getPlayersList() %}

                                       $lockedIds = mysql_select_single("SELECT `player_id` FROM `player_namelocks` WHERE `id`=  '.player.getId().'");

                                            {% if lockedIds == player.getId() %}
                                        <option value="{{ player.getId() }}">{{ player.getName() }}</option>
                                                {% endif %}
                                        {% endfor %}
                                    </select>
                                </td>
                            </tr>
 
Last edited:
Solution
OTS_Player.php:
Code:
public function isNamelocked() {
   $query = $this->db->select('player_namelocks', ['player_id' => $this->data['id']]);
   return $query !== false;
}

Then in twig:
Code:
{% for player in account_logged.getPlayersList() %}
   {% if player.isNamelocked() %}
      <option value="{{ player.getId() }}">{{ player.getName() }}</option>
   {% endif %}
{% endfor %}

You will also need additional check, to verify that only namelocked players can get renamed. If you won't add it, user will be able to send fake request with player id that in reality isn't namelocked.

in change_name.php

So, after:
Code:
if($player->isOnline()) {
   $errors[] = 'This character is online.';
}

Add:
Code:
if(!$player->isNamelocked()) {...
I figured out that you're not allowed to fetch mysql data from a .twig file, or at least it seems so. The information about this is very limited on dem webs.

However when trying to feed a fetch from a .php file it will not work either.

THIS, will work but only for the later 'or', since I do have both 41 & 42 in namelock, and only player with id 41 will show up I know that the later 'player.getId() == 41' actually works but not the first 'player.getId() == player.getPlayerNamelock()'.


twig:

Code:
                                        {% for player in account_logged.getPlayersList() %}
                                         $account_logged->getCustomField("email_new_time");
                                            {% if player.getId() == player.getPlayerNamelock() or player.getId() == 41 %}
                                                <option value="{{ player.getId() }}">{{ player.getName() }}</option>
                                             {% endif %}
                                        {% endfor %}

Php:

PHP:
    public function getPlayerNamelock($player)
    {
        $value = $this->db->query('SELECT ' . $this->db->fieldName('player_id') . ' FROM ' . $this->db->tableName('player_namelocks'));
        return $value;
    }
 
OTS_Player.php:
Code:
public function isNamelocked() {
   $query = $this->db->select('player_namelocks', ['player_id' => $this->data['id']]);
   return $query !== false;
}

Then in twig:
Code:
{% for player in account_logged.getPlayersList() %}
   {% if player.isNamelocked() %}
      <option value="{{ player.getId() }}">{{ player.getName() }}</option>
   {% endif %}
{% endfor %}

You will also need additional check, to verify that only namelocked players can get renamed. If you won't add it, user will be able to send fake request with player id that in reality isn't namelocked.

in change_name.php

So, after:
Code:
if($player->isOnline()) {
   $errors[] = 'This character is online.';
}

Add:
Code:
if(!$player->isNamelocked()) {
   $errors[] = 'This character is not namelocked and cannot be renamed.';
}
 
Solution
OTS_Player.php:
Code:
public function isNamelocked() {
   $query = $this->db->select('player_namelocks', ['player_id' => $this->data['id']]);
   return $query !== false;
}

Then in twig:
Code:
{% for player in account_logged.getPlayersList() %}
   {% if player.isNamelocked() %}
      <option value="{{ player.getId() }}">{{ player.getName() }}</option>
   {% endif %}
{% endfor %}

You will also need additional check, to verify that only namelocked players can get renamed. If you won't add it, user will be able to send fake request with player id that in reality isn't namelocked.

in change_name.php

So, after:
Code:
if($player->isOnline()) {
   $errors[] = 'This character is online.';
}

Add:
Code:
if(!$player->isNamelocked()) {
   $errors[] = 'This character is not namelocked and cannot be renamed.';
}
Oh thank you Slaw, ur such a huge contribution to OT world. <3
 
Back
Top