Joined: 10 Feb 2010
|Posted: Wed Jul 14, 2010 2:53 Post subject: script to check merchant stock
|I would like to run a script that will take all of the stock of some custom merchants I am using and create a list of the items in a table with a column stating which merchant they are contained in. This should work as a reference and help me to copy the item later without having to look in every merchant one item at a time.
My function is outputing properly to a log but I find that only one row is being added to the table. I am not sure if my SQL is off.
Here is the function I am using:
//object oChest =GetObjectByTag("ss_t_chest_"+IntToString(i));
string sChestTag = "ss_t_chest_"+IntToString(nChestNum);
object oChest = GetObjectByTag(sChestTag);
while (oChest != OBJECT_INVALID)
AWA_DEBUG("awa_inc_treasure: found a CHEST called= "+GetName(oChest));
object oInv = GetFirstItemInInventory(oChest);
while (GetIsObjectValid(oInv) == TRUE)
string sItemResref = GetResRef(oInv);
string sItemTag = GetTag(oInv);
string sItemName = GetName(oInv, FALSE);
string sItemValue = IntToString(GetGoldPieceValue(oInv));
AWA_DEBUG("awa_inc_treasure: found a ITEM called= "+sItemName); //debug
SQLExecDirect("INSERT INTO `nwn`.`"+TABLE_LOOT+"` (`"+LOOT_CHEST_TAG+"`,`"+LOOT_ITEM_REF+"`,`"+LOOT_ITEM_TAG+"`,`"+LOOT_ITEM_NAME+"`,`"+LOOT_ITEM_VALUE+"`) VALUES ('"+sChestTag+"','"+sItemResref+"','"+sItemTag+"','"+sItemName+"','"+sItemValue+"');");
oInv = GetNextItemInInventory(oChest);
if (oInv == OBJECT_INVALID) AWA_DEBUG("awa_inc_treasure: ITEM INVALID");
//if (nChestNum > MAX_num_TABLES) return; //quick finish
AWA_DEBUG("AWA_INC_TREASURE: finished primeing Treasure Table by Chest.");
the sql statement I am using is
All the variables seem to be working properly as the first line is updating.