ROM Hack [Request] reading main file from pokemon backup

  • Thread starter Thread starter MOBSTER_X
  • Start date Start date
  • Views Views 1,676
  • Replies Replies 11

MOBSTER_X

Well-Known Member
Newcomer
Joined
Sep 5, 2015
Messages
60
Reaction score
1
Trophies
0
XP
97
Country
United States
I have been trying to code in php a way to read just the trainer name and how many pokemon caught.
I am using tubehax exploit and save manager to do this backup.

Here i was just trying to read the file into text and trying to find anything.
PHP:
$handle = @fopen("main", "r");
if ($handle) {
    while (!feof($handle)) {
        $hex = bin2hex(fread ($handle , 4 ));
    }
    fclose($handle);

}
 
Last edited by MOBSTER_X,
I wanted a server to upload the main file and display the results into a database to show how much pokemon the user has caught and trainer information. I seen that there wasn't much projects for php. Don't be get wrong the program is amazing. I love it. I don't know C or C# but i am trying to learn it. I am very good with php.
 
I am having a hard time with the checksum. In the link provided where do i find where the file is being opened?
PHP:
public function generateFromFile($pkmFile) {
            $blockA_format = "v1SPECIES/v1HeldItem/v1OrigTrainer/v1SECRETID/V1EXP/C1FRIENDSHIP/C1Ability/C1Markings/C1COUNTRY/C6EFFORTVALS/C6CS/C4RIBBONS";
            $blockB_format = "v4MoveNumber/C4MovePP/C4MovePPUps/V1SPECIAL1/C4RIBBONS/v1SPECIAL2/v1Unknown2/v1PEggLoc/v1PMet";
            $blockC_format = "H44NICKNAME/C1Unknown/C1HOMETOWN/V1Contests/V1Unknown3";
            $blockD_format = "H32OTName/C3DER/C3DM/v1DPEL/v1DPMAL/C1Pokerus/C1POKEBALL/C1SPECIAL3/C1Encounter/v1Unknown4";
            $fileHandler = fopen($pkmFile, "rb");
            $this->pkmHeader = unpack("v2PID/n1unknown/v1Checksum", fread($fileHandler, 8));
            $this->blockA = unpack($blockA_format, fread($fileHandler, 32));
            $this->blockB = unpack($blockB_format, fread($fileHandler, 32));
            $this->blockC = unpack($blockC_format, fread($fileHandler, 32));
            $this->blockD = unpack($blockD_format, fread($fileHandler, 32));
            $this->processBlocks();
            // $this->printArray();
        }
 
first four lines are defining the structure.

then the file is opened
$fileHandler = fopen($pkmFile, "rb");
file open pkmfile, read byte.

then the file is unpacked to the block object.
 
Sorry if it was confusing i was trying to convert this code to work with 6th gen. But i was wondering how pkhex opened and read these files.
 
Sorry if it was confusing i was trying to convert this code to work with 6th gen. But i was wondering how pkhex opened and read these files.
That would be done here. The input byte array is what the program uses to fill the GUI's fields.

That byte array is read in elsewhere, there's tons of ways to load files in PKHeX (drag/drop, open dialog, clicking around, etc).
 
Thanks Kaphotics it means alot.

--------------------- MERGED ---------------------------

It gets the move set. But trainer name is having and hard time.
 

Site & Scene News

Popular threads in this forum