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

Solved Characters injection doesn't work.

Pete Doherty

New Member
Joined
Sep 12, 2008
Messages
60
Reaction score
0
Solved. It was the hide_char value that was set to NULL when infact it was needed to be set to 0 or 1.

Code:
UPDATE players SET hide_char = 0 WHERE hide_char IS NULL;

Code:
ALTER TABLE players MODIFY hide_char INT(11) DEFAULT 0;


Thank you Chris!

---------

Ok, this is the original code from the latest Modern AAC. I don't know if any others have this problem, but anyways, it seems that the query doesn't find my characters and hence doesn't load. If I remove "if(!empty($characters))" the title "Characters" appear, thus proving that the injection itself loads. I've made sure my account have plenty of characters but still the "Characters" does not appear when viewing characters.

So my quess is that the query is faulty or perhaps my database. Any ideas?

Code:
<?PHP

        // Reject any unwanted access.
        if ( !defined( 'BASEPATH' ) ) exit( 'No direct script access allowed' );
        
        $player = $GLOBALS['player'];
        $config = $GLOBALS['config'];
        $SQL = POT::getInstance()->getDBHandle();
        
        $characters = $SQL->query( 'SELECT `c`.`name`, `c`.`vocation`, `c`.`world_id` FROM `players` AS `c` LEFT JOIN `players` AS `p` ON `p`.`account_id` = `c`.`account_id` AND c.deleted = 0 AND c.hide_char = 0 AND p.hide_char = 0 WHERE `p`.`id` = '.$player->getId( ).' AND `c`.`id` != '.$player->getId( ).';' )->fetchAll();
        if(!empty($characters))
        echo '<div class="title">Characters</div>';
        foreach( $characters as $character )
        {
                ?>
                <table style="width: 100%;">
                        <tr>
                                <td style="width: 40%;"><a href="<?PHP echo WEBSITE; ?>/index.php/character/view/<?PHP echo $character['name']; ?>"><b><?PHP echo $character['name']; ?></b></a></td>
                        </tr>
                </table>
				<br />
                <?PHP
        }
?>

I have also tried this code without success.
Code:
<?PHP

        // Reject any unwanted access.
        if ( !defined( 'BASEPATH' ) ) exit( 'No direct script access allowed' );
        
        $player = $GLOBALS['player'];
        $config = $GLOBALS['config'];
        $SQL = POT::getInstance()->getDBHandle();
        
        $characters = $SQL->query( 'SELECT `c`.`name`, `c`.`vocation`, `c`.`world_id` FROM `players` AS `c` LEFT JOIN `players` AS `p` ON `p`.`account_id` = `c`.`account_id` AND c.deleted = 0 AND c.hide_char = 0 AND p.hide_char = 0 WHERE `p`.`id` = '.$player->getId( ).' AND `c`.`id` != '.$player->getId( ).';' )->fetchAll();
        if(!empty($characters))
        echo '<div class="bar">Characters</div>';
        foreach( $characters as $character )
        {
                ?>
                <table style="width: 100%;">
                        <tr>
                                <td style="width: 40%;"><?PHP echo $character['name']; ?></td>
                                <td style="width: 25%;"><?PHP echo $config['server_vocations'][$character['vocation']]; ?></td>
                                <td style="width: 25%;"><?PHP echo $config['worlds'][$character['world_id']]; ?></td>
                                <td style="width: 10%;"><a href="<?PHP echo WEBSITE; ?>/index.php/character/view/<?PHP echo $character['name']; ?>"><strong>View</strong></a></td>
                        </tr>
                </table>
                <?PHP
        }
?>
 
Last edited:
If you add the following code below the <?PHP tag at the very top of the document, what does it show you?
PHP:
var_dump($GLOBALS['player']);
 
It shows me exactly what you'd expect, information of the player from the database, in a pretty messed up way. :)

Code:
object(OTS_Player)#16 (3) { >["data":"OTS_Player":private]= array(99) { >["id"]= string(2) "13" >[0]= string(2) "13" >["name"]= string(10) "Playername" >[1]= string(10) "Playername" >["account_id"]= string(1) "4" >[2]= string(1) "4" >["group_id"]= string(1) "1" >[3]= string(1) "1" >["sex"]= string(1) "1" >[4]= string(1) "1" >["vocation"]= string(1) "3" >[5]= string(1) "3" >["experience"]= string(8).

That's a little part of what's showing.
 
Try changing
PHP:
$characters = $SQL->query( 'SELECT `c`.`name`, `c`.`vocation`, `c`.`world_id` FROM `players` AS `c` LEFT JOIN `players` AS `p` ON `p`.`account_id` = `c`.`account_id` AND c.deleted = 0 AND c.hide_char = 0 AND p.hide_char = 0 WHERE `p`.`id` = '.$player->getId( ).' AND `c`.`id` != '.$player->getId( ).';' )->fetchAll();
to
PHP:
$characters = $SQL->query('SELECT c.name, c.vocation, c.world_id FROM players AS c WHERE c.account_id = ' . (int) $player->getAccountId() . ' AND c.id != ' . (int) $player->getId() . ' AND c.deleted = 0 AND c.hide_char = 0')->fetchAll();
 
Try changing
PHP:
$characters = $SQL->query( 'SELECT `c`.`name`, `c`.`vocation`, `c`.`world_id` FROM `players` AS `c` LEFT JOIN `players` AS `p` ON `p`.`account_id` = `c`.`account_id` AND c.deleted = 0 AND c.hide_char = 0 AND p.hide_char = 0 WHERE `p`.`id` = '.$player->getId( ).' AND `c`.`id` != '.$player->getId( ).';' )->fetchAll();
to
PHP:
$characters = $SQL->query('SELECT c.name, c.vocation, c.world_id FROM players AS c WHERE c.account_id = ' . (int) $player->getAccountId() . ' AND c.id != ' . (int) $player->getId() . ' AND c.deleted = 0 AND c.hide_char = 0')->fetchAll();

First off, thank you so much for trying to help me.

This happens:
Code:
Fatal error: Call to undefined method OTS_Player::getAccountId() in X:\UniServer\www\injections\character_view\characters\injection.php on line 10
 
Don't worry about, it is my absolute pleasure to do so.

Anyway, seeing as I have been out of the game for a while, the method is apparently called getAccount and not getAccountId. So basically switch to this line;
PHP:
$characters = $SQL->query('SELECT c.name, c.vocation, c.world_id FROM players AS c WHERE c.account_id = ' . (int) $player->getAccount() . ' AND c.id != ' . (int) $player->getId() . ' AND c.deleted = 0 AND c.hide_char = 0')->fetchAll();
 
Don't worry about, it is my absolute pleasure to do so.

Anyway, seeing as I have been out of the game for a while, the method is apparently called getAccount and not getAccountId. So basically switch to this line;
PHP:
$characters = $SQL->query('SELECT c.name, c.vocation, c.world_id FROM players AS c WHERE c.account_id = ' . (int) $player->getAccount() . ' AND c.id != ' . (int) $player->getId() . ' AND c.deleted = 0 AND c.hide_char = 0')->fetchAll();

Ok, almost there!

Code:
Account Manager	None	MyWorld	View
Rook Sample	None	MyWorld	View
Sorcerer Sample	Sorcerer	MyWorld	View
Druid Sample	Druid	MyWorld	View
Paladin Sample	Paladin	MyWorld	View
Knight Sample	Knight	MyWorld	View
 
Hm, what's not working properly? Do you wish to hide Account Manager and the Samples? Is that it?
 
The problem is that instead of the characters of the account, the sample characters appear, aswell as the account manager.

That is, the Sample characters are showing on all characters of the server, and is not a apart of any "active" account.
 
PHP:
$characters = $SQL->query('SELECT c.name, c.vocation, c.world_id FROM players AS c WHERE c.account_id = ' . (int) $player->getAccount() . ' AND c.id != ' . (int) $player->getId() . ' AND c.deleted = 0 AND c.hide_char = 0 AND c.name NOT IN("Account Manager", "Druid Sample", "Rook Sample", "Sorcerer Sample", "Paladin Sample", "Knight Sample")')->fetchAll();
Give that a go and let me know how it all works out for you. :)
 
PHP:
$characters = $SQL->query('SELECT c.name, c.vocation, c.world_id FROM players AS c WHERE c.account_id = ' . (int) $player->getAccount() . ' AND c.id != ' . (int) $player->getId() . ' AND c.deleted = 0 AND c.hide_char = 0 AND c.name NOT IN("Account Manager", "Druid Sample", "Rook Sample", "Sorcerer Sample", "Paladin Sample", "Knight Sample")')->fetchAll();
Give that a go and let me know how it all works out for you. :)

With this nothing shows. :-/

Ok, maybe I wasn't explaining myself clearly before, but the only characters that was showing was the sample characters. The real characters of the account did not. And one weird thing: I just changed the account_id on a custom made character to the same of the sample characters (which was 1) and still that character wasn't loaded with the other sample characters. If you understand what I mean. :)

EDIT: Also, I just tried to changed the ID of a sample character to something obscenely high, instead of the numbers between 1-6 that all the characters that are loaded have, still it was loaded. So it doesn't depend on the ID. However, I just changed the account_id on Account Manager from 1 to 7, and now he doesn't appear anymore.

EDIT2: Hm, I don't know if I did something wrong the first time, but now I changed the account_id on a custom character to 1, the same of the sample characters, and now it appears. (Excuse my feeble mind).

So to summerize, the code loads all the characters with account_id 1.

EDIT3: Ok seriously! Everything seems to be very arbitrary. I tried changing another player to account_id 1, and this one does not show. Also, I can see the first custom player on ALL player sites, EXCEPT the one of the actual player I added.
 
Last edited:
If you run this through phpMyAdmin or whatever database tool you use, what characters show up? The samples?
SQL:
SELECT name FROM players WHERE account_id = 4;
 
No, those of "my" account which happens to have account_id 4

If I run:
Code:
SELECT name FROM players WHERE account_id = 1;

The sample characters appear + the ones that I changed to that account_id, but still doesn't show on the injection..
 
PHP:
$characters = $SQL->query("SELECT name, vocation, world_id FROM players WHERE account_id = {$player->getAccount()} AND id <> {$player->getId()} AND deleted = 0 AND hide_char = 0;")->fetchAll();
 
PHP:
$characters = $SQL->query("SELECT name, vocation, world_id FROM players WHERE account_id = {$player->getAccount()} AND id <> {$player->getId()} AND deleted = 0 AND hide_char = 0;")->fetchAll();

Ok, on my account I have about 10 characters, (not HIDE on anyone), and the one on top (lowest ID-number, lets call him Player1) displays nothing on view, however, all my other characters show Player1 (only!) on their injection. I want all my characters to be shown, even if that is the one player you are viewing.

EDIT: OK, I think I now the problem: When I hide a player, and then unhide it, it starts to show. It's as if the standard setting for a character is hide, even though it is not checked as "hidden" on my homapge.

Yes, all characters have the value = NULL on hide_char, when infact it should be a zero. How do I change this?
 
Last edited:
Hmpf. Either I am extremely stupid, or something is extremely messed up. I couldn't even tell the difference right now to be frank with you... This would all be a lot easier over TeamViewer, if you have the ability to download that and send me your TeamViewer credentials through a private message, I could help you out more efficiently.
 
Hmpf. Either I am extremely stupid, or something is extremely messed up. I couldn't even tell the difference right now to be frank with you... This would all be a lot easier over TeamViewer, if you have the ability to download that and send me your TeamViewer credentials through a private message, I could help you out more efficiently.

I don't know if you perhaps overlooked my latest edit, so I'll post it again to make sure.

EDIT: OK, I think I now the problem: When I hide a player, and then unhide it, it starts to show. It's as if the standard setting for a character is hide, even though it is not checked as "hidden" on my homapge.

Yes, all characters have the value = NULL on hide_char, when infact it should be a zero. How do I change this?
 
Ah! Was driving me nuts haha. Should of have been correct.

Run this in phpMyAdmin;
SQL:
UPDATE players SET hide = 0 WHERE hide IS NULL;

EDIT:
Might also have to change the default value (could easily do so by editing the hide field through the Structures tab) in phpMyAdmin.
 
Thanks, it's hide_char though. :)

However, when I create a new character, he gets hide_char = NULL... :-/

Somewhere in controller/character.php under "function create_character($ajax = 0) {" I guess...? Something like $player->sethide_char(0);
 
Back
Top