SRL Archive - Reflection Help

Get Interface-Child-Component.ID


Cstrike

2010-10-16 15:52:40

So far it seems that we can only get the model ID's from interface components… but not children components

I tried playing around with the code but it just caused a FATAL ERROR all the time

This is what I tried:

function GetModelCompID(ParentI, ChildI, CompI: Integer): Integer;
var
Text, Child, Comp: Integer;
begin
Child := GetInterface(ParentI, ChildI);
Comp := SmartGetFieldArrayObject(Child, hook_interface_GetChildren, compI); //Getting the children components of the Child component
Result := SmartGetFieldInt(CompI, hook_interface_GetModelID); // This is probably the bad spot
SmartFreeObject(Child);
SmartFreeObject(Comp);
end;

When I run the above I get this:
FATAL ERROR in native method: Bad JNI oop argument


Is there any way for me to grab that number? It would not only help with randoms but also allow much more advanced banking functions that we just can't do right now.


This is the original function:
{*******************************************************************************
Function GetModelID(ParentI, ChildI: Integer): Integer;
By: Drags111
Description: Returns the model ID of the interface.
*******************************************************************************}
function GetModelID(ParentI, ChildI: Integer): Integer;
var
Child: Integer;
begin
Child := GetInterface(ParentI, ChildI);
Result := SmartGetFieldInt(Child, hook_interface_GetModelID);
SmartFreeObject(Child);
end;

And I want to get the component ID of
Interface 763, Child 93, Component 6 when I open the bank. I think it's child 93… either way, when I debugged the interface with RSBot, I was running the correct numbers for sure.


EDIT:
This apparently is closer to working (Zephyrs' procedure I borrowed):
function GetComponentID(ParentI, ChildI, CompI: Integer): Integer;
var
Text, Child, Comp: Integer;
begin
Child := GetInterface(ParentI, ChildI);
Comp := SmartGetFieldArrayObject(Child, hook_interface_GetChildren, compI); //Getting the children components of the Child component
Text := SmartGetFieldObject(Comp, hook_interface_GetModelID);
Result := Text;
SmartFreeObject(Text);
SmartFreeObject(Comp);
SmartFreeObject(Child);
end;
EDIT2: Now I'm getting this result: 140877408
How can I change that to a useable number? I probably need to do some java integer conversion code but I don't know how to.
It's supposed to return something like 331.

EDIT3: When I change it to this:
function GetComponentID(ParentI, ChildI, CompI: Integer): Integer;
var
Text, Child, Comp: Integer;
begin
Child := GetInterface(ParentI, ChildI);
Comp := SmartGetFieldArrayObject(Child, hook_interface_GetChildren, compI); //Getting the children components of the Child component
Text := SmartGetFieldInt(Comp, hook_interface_GetModelID);
Result := Text;
SmartFreeObject(Text);
SmartFreeObject(Comp);
SmartFreeObject(Child);
end;
My result is now 0.

EDIT4: Heres the image:

pyroryan

2010-10-16 16:40:31

Why hook_interface_GetModelID when you're trying to find the ComponentID?

Cstrike

2010-10-16 17:35:08

From: pyroryan
Why hook_interface_GetModelID when you're trying to find the ComponentID?


Good point XD

I took this hook
hook_interface_GetID = 'Kb'; //623 //actually GetComponentID/GetItemID we need to change this
And made a new one of this
    hook_interface_GetComponentID = 'Kb'; // EDIT  


Then I ran this:
function GetComponentID(ParentI, ChildI, CompI: Integer): Integer;
var
Text, Child, Comp: Integer;
begin
Child := GetInterface(ParentI, ChildI);
Comp := SmartGetFieldArrayObject(Child, hook_interface_GetChildren, compI); //Getting the children components of the Child component
Text := SmartGetFieldInt(Comp, hook_interface_GetComponentID);
Result := Text;
SmartFreeObject(Text);
SmartFreeObject(Comp);
SmartFreeObject(Child);
end;
But it crashed :(
Do we need more hooks/definitions?

Also using
Text := SmartGetFieldInt(Comp, hook_interface_GetID);
Crashes it as well

pyroryan

2010-10-16 17:39:46

Well if one crashes so will the other. Its just names referring to the same hooks. On a lighter note, in response to the PMs, I just fixed up GetInteractableAt so you can use it. GetID2 is no longer needed.
Shouldn't hook_interface_GetChildren be hook_interface_GetComponents?

Cstrike

2010-10-16 18:19:40

From: pyroryan
Well if one crashes so will the other. Its just names referring to the same hooks. On a lighter note, in response to the PMs, I just fixed up GetInteractableAt so you can use it. GetID2 is no longer needed.
Shouldn't hook_interface_GetChildren be hook_interface_GetComponents?

Awesome :) I will try it out tonight (today is a busy day!)


I also put in the hook_interface_GetChildren just to test it and no luck. Unfortunately when it comes to hooks and handling smart, I'm not too useful :(

ZephyrsFury

2010-10-18 19:38:24

From: cstrike
Awesome :) I will try it out tonight (today is a busy day!)


I also put in the hook_interface_GetChildren just to test it and no luck. Unfortunately when it comes to hooks and handling smart, I'm not too useful :(


Try:


function GetComponentID(ParentI, ChildI, CompI: Integer): Integer;
var
Text, Child, Comp: Integer;
begin
Child := GetInterface(ParentI, ChildI);
Comp := SmartGetFieldArrayObject(Child, hook_interface_GetChildren, compI); //Getting the children components of the Child component
Text := SmartGetFieldInt(Comp, hook_interface_GetComponentID);
Result := Text;
SmartFreeObject(Comp);
SmartFreeObject(Child);
end;

I removed the SmartFreeObject(Text) line because Text is an int not an object (because you used SmartGetFieldInt). This should solve your crash issues and, provided the hooks are all ok, should give you what you want. ;)