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

TFS 1.X+ Optimized Forgottenserver - how to get around blob items saved in database and read it on website?

thesxw

Active Member
Joined
Sep 19, 2015
Messages
64
Reaction score
45
i cant figureout what im missing here...
its from optimized forgottenserver from sayan guy, that uses blob's in database for items etc.

PHP:
function getAttrib($attr, $otsBuffer)
{
    echo "(attr:" . $attr . ")<br>";
    switch ($attr) {
        // empty just skip
        case 23:
            return "container";
            break;

        case 6:
        case 19:
        case 7:
        case 24:
        case 25:
        case 26:
            $otsBuffer->getString();
        break;

        case 15:
        case 12:
        case 32:
        case 33:
        case 14: //Door class
            $otsBuffer->getChar();
        break;

        case 4:
        case 5:
        case 22:
        case 17:
        case 10: //Depot class
            $otsBuffer->getShort();
        break;

        case 18:
        case 16:
        case 20:
        case 21:
        case 31:
        case 27:
        case 28:
        case 29:
        case 30:
            $otsBuffer->getLong();
        break;

        case 8: //Teleport class
            // not sure about this order but we dont do anything with it so whatever...
            $otsBuffer->getLong();
            $otsBuffer->getChar();
        break;
       
        case 34:
            $arraySize = $otsBuffer->getLongLong();
            for($i = 0; $i < $arraySize; $i++){
                $otsBuffer->getString();
            }
        break;

        default:
            return "null";
    }
    if ($attr == 22) {
        $otsBuffer->getChar(); // for some reason its required... for amulet of loss...
    }
    return "";
}
and actual code from characters.php

PHP:
$eq_sql = $db->query('SELECT `items` FROM players WHERE id = '.$player->getId().'');
foreach ($eq_sql as $eq) {
    if (isset($eq['items'])) {
        $otsBuffer = new OTS_Buffer($eq['items']);
        while ($otsBuffer->getPos() < $otsBuffer->getSize()) {
            echo $otsBuffer->getPos() . " - " . $otsBuffer->getSize() . " | ";

            echo $otsBuffer->getLong() . " | ";
            echo $otsBuffer->getShort();
            $attr = $otsBuffer->getChar();

            $ret = getAttrib($attr, $otsBuffer);
            $wasContainer = $ret == "container";
            if ($wasContainer) {
                while ($ret == "container") {
                    $getId = $otsBuffer->getShort();
                    echo "container: " . $otsBuffer->getShort() . "<br>";
                    $ret = getAttrib($attr, $otsBuffer);
                }

                $otsBuffer->getChar(); // end attrib
            }
        }

    }
}

looks like im missing something with container staff... propably something trivial tbh...
but i cant wrap my head around it and i need to go to work in few min. so i hoped someone could have this figured out...

how website views it
how server views it
 
Last edited:
Back
Top