Jump to content

OBSE plugin - finding the players gold


severs64

Recommended Posts

OK, so I'm writing an OBSE plugin to send values (Attributes, Skills, etc) to an Android app. Not using an actual script, just the dll. It's working really well, except I'm having a bit of a struggle with the gold. I'm using the following code in the load game:

 

ExtraContainerChanges* exCont = NULL;
ExtraContainerChanges::EntryData *entry = NULL;
TESForm *gold;

void MessageHandler(OBSEMessagingInterface::Message* msg)
{
switch (msg->type)
{
case OBSEMessagingInterface::kMessage_LoadGame:
player = *g_thePlayer;
if (player != NULL)
{
basedata = (TESActorBaseData *)Oblivion_DynamicCast(player->baseForm, 0, RTTI_TESForm, RTTI_TESActorBaseData, 0);
player_class = player->GetPlayerClass();
player_name = player->GetFullName();
exCont = static_cast <ExtraContainerChanges *>(player->baseExtraList.GetByType(kExtraData_ContainerChanges));
OR
exCont = ExtraContainerChanges::GetForRef(player);
gold = GetGoldForm();
}

Then in my GetValues function:

 

if (exCont)
{
entry = exCont->GetByType(gold);
if (entry)
values->gold = entry->countDelta;
}

 

TESForm *GetGoldForm()

{
int i = 0;

TESForm *frm = player->GetInventoryItem(i++, false);
while (frm)
{
if (frm->refID == 15)
return frm;
frm = player->GetInventoryItem(i++, false);
};
return NULL;
}

This works fine, except that sometimes when loading a different save ingame, I get a crash. The data variable in exCont gets trashed somehow, and I get an access violation.

 

So, a couple of questions:

1. Is this the best way to find the players gold amount? Again, not using a script.

2. Am I using the ExtraContainerChanges wrongly? If so, what's the right way?

 

Thanks for any help...

 

Here's a pic of my Xoom running the app in case anyone is curious...

 

 

Link to comment
Share on other sites

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...