I'm not actually a player on Avlis, I'm working on a persistent world called SoulForge. It has been around quite some time without any changes but now I'd like to add a few things to it.
So this is a guest question, I hope that's alright. I spoke to the friendly people on Avlis IRC chat and I was informed about this topic here. I'll go ahead with my question now
My goal is to have a chest with persistent storage for items using nwnx2-linux and the odmbc plugin.
I have nwnx2 and plugins working, I have the db connection working, the table exists. I can store items in the database using this:
Code: Select all
void PersstorStoreNew(string sPlayerName, object oSource)
{
sPlayerName = SQLEncodeSpecialChars(sPlayerName);
string sSQL = "INSERT INTO persistent_storage (PlayerName, StorageName, Object) VALUES('"+sPlayerName+"', 'default', %s)";
SetLocalString(GetModule(), "NWNX!ODBC!SETSCORCOSQL", sSQL);
object oItem = GetFirstItemInInventory(oSource);
while(GetIsObjectValid(oItem))
{
StoreCampaignObject("NWNX", "-", oItem);
oItem = GetNextItemInInventory(oSource);
}
}
Now it would be nice to retrieve items again. This is what I got:
Code: Select all
void PersstorRetrieveNew(object oPC, object oDestination)
{
string sPlayerName = SQLEncodeSpecialChars(GetPCPlayerName(oPC));
string sSQL = "SELECT Object from persistent_storage WHERE PlayerName = '"+sPlayerName+"' AND StorageName = 'default'";
//SetLocalString(GetModule(), "NWNX!ODBC!SETSCORCOSQL", sSQL);
SQLExecDirect(sSQL);
object oItem = RetrieveCampaignObject("NWNX", "FETCHMODE", GetLocation(oDestination), oDestination);
while(GetIsObjectValid(oItem))
{
oItem = RetrieveCampaignObject("NWNX", "FETCHMODE", GetLocation(oDestination), oDestination);
SendMessageToPC(oPC, "valid item");
}
}
I would be happy about any pointers you can give me on this. Do you have anything for persistent item storage in place on Avlis? I don't necesarily need FETCHMODE to work, just a way to retrieve items from a sql resultset.
Thank you!