Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Get Dictionary values #595

Open
jorcadet009 opened this issue Jan 21, 2025 · 2 comments
Open

Get Dictionary values #595

jorcadet009 opened this issue Jan 21, 2025 · 2 comments
Labels
question A question about anything

Comments

@jorcadet009
Copy link

I'm trying to get the values of this field

// GameManager
// Token: 0x0400023C RID: 572
[Token(Token = "0x400023C")]
[FieldOffset(Offset = "0x98")]
private Dictionary<int, string> adjustConversationLevels;

It's System.Collections.Generic.Dictionary`2[System.Int32,System.String]

and this is my code

  let unityframework = Il2Cpp.domain.assembly("Assembly-CSharp");
  const GameManager = unityframework.image.class("GameManager");
  let adjustConversationLevels = GameManager.field("adjustConversationLevels");
  let OpenLevel = GameManager.method("OpenLevel");

  OpenLevel.implementation = function (this: any, level: any) {
    //trying to call adjustConversationLevels from here
    this.method(OpenLevel.name, 1).invoke(level);
  };

but there's no Il2Cpp.Dictionary so how to get those values?

@vfsfitvnm vfsfitvnm added the question A question about anything label Jan 22, 2025
@vfsfitvnm
Copy link
Owner

It's a Il2Cpp.Object. That's how I would write the script:

  const AssemblyCSharp = Il2Cpp.domain.assembly("Assembly-CSharp").image;
  const GameManager = AssemblyCSharp.class("GameManager");
  
  // @ts-ignore
  GameManager.method("OpenLevel").implementation = function (this: Il2Cpp.Object | Il2Cpp.Class, level: any): any {
    const adjustConversationLevels = this.field<Il2Cpp.Object>("adjustConversationLevels").value;
    
    // do whatever you want with adjustConversationLevels, it's a Il2Cpp.Object
    // let's print its class
    console.log(adjustConversationLevels.class);

    return this.method("OpenLevel", 1).invoke(level);
  };

@jorcadet009
Copy link
Author

It's a Il2Cpp.Object. That's how I would write the script:

const AssemblyCSharp = Il2Cpp.domain.assembly("Assembly-CSharp").image;
const GameManager = AssemblyCSharp.class("GameManager");

// @ts-ignore
GameManager.method("OpenLevel").implementation = function (this: Il2Cpp.Object | Il2Cpp.Class, level: any): any {
const adjustConversationLevels = this.field<Il2Cpp.Object>("adjustConversationLevels").value;

// do whatever you want with adjustConversationLevels, it's a Il2Cpp.Object
// let's print its class
console.log(adjustConversationLevels.class);

return this.method("OpenLevel", 1).invoke(level);

};

Thank you but I mean adjustConversationLevels contain the values I wanna get but I don't know how to get those

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question A question about anything
Projects
None yet
Development

No branches or pull requests

2 participants