[Request] reading main file from pokemon backup

Discussion in '3DS - ROM Hacking, Translations and Utilities' started by MOBSTER_X, Sep 5, 2015.

  1. MOBSTER_X
    OP

    MOBSTER_X Advanced Member

    Newcomer
    58
    1
    Sep 5, 2015
    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 ));
        }
        
    fclose($handle);

    }
     
    Last edited by MOBSTER_X, Sep 5, 2015
  2. SciresM

    SciresM GBAtemp Advanced Fan

    Member
    597
    1,866
    Mar 21, 2014
    United States
    Why not just use PKHeX?
     
    Something whatever likes this.
  3. MOBSTER_X
    OP

    MOBSTER_X Advanced Member

    Newcomer
    58
    1
    Sep 5, 2015
    United States
    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.
     
  4. MOBSTER_X
    OP

    MOBSTER_X Advanced Member

    Newcomer
    58
    1
    Sep 5, 2015
    United States
  5. suloku

    suloku GBAtemp Advanced Fan

    Member
    866
    491
    Apr 28, 2008
  6. MOBSTER_X
    OP

    MOBSTER_X Advanced Member

    Newcomer
    58
    1
    Sep 5, 2015
    United States
    Thanks to both of you. The help is appreciated.
     
  7. MOBSTER_X
    OP

    MOBSTER_X Advanced Member

    Newcomer
    58
    1
    Sep 5, 2015
    United States
    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($fileHandler8));
                
    $this->blockA unpack($blockA_formatfread($fileHandler32));
                
    $this->blockB unpack($blockB_formatfread($fileHandler32));
                
    $this->blockC unpack($blockC_formatfread($fileHandler32));
                
    $this->blockD unpack($blockD_formatfread($fileHandler32));
                
    $this->processBlocks();
                
    // $this->printArray();
            
    }
     
  8. Kaphotics

    Kaphotics badc0ded

    Member
    611
    460
    Sep 10, 2010
    United States
    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.
     
  9. MOBSTER_X
    OP

    MOBSTER_X Advanced Member

    Newcomer
    58
    1
    Sep 5, 2015
    United States
    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.
     
  10. Kaphotics

    Kaphotics badc0ded

    Member
    611
    460
    Sep 10, 2010
    United States
    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).
     
  11. MOBSTER_X
    OP

    MOBSTER_X Advanced Member

    Newcomer
    58
    1
    Sep 5, 2015
    United States
    Thanks Kaphotics it means alot.

    — Posts automatically merged - Please don't double post! —

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

    MOBSTER_X Advanced Member

    Newcomer
    58
    1
    Sep 5, 2015
    United States