Player Merchant Filter
4BOLTMAIN
Member Posts: 90
I am looking for some code that will remove (destroy) X amount of items from a merchant if the inventory count is over a certain number. I have some code implemented on my server but it doesn't work all the time. The code just destroys item if their value is below the average value of all the items so I cant specify how many items to remove.
This is the code that I am using but I would like to specify how many items are removed.
This is the code that I am using but I would like to specify how many items are removed.
void main() { object oShop = OBJECT_SELF; object oTalker = GetObjectByTag("server_speaker"); int nCount = GetLocalInt(oShop, "itemcount"); int nTotalCost = 0; object oItem; if (nCount > 340) { oItem = GetFirstItemInInventory(oShop); while (GetIsObjectValid(oItem)) { nTotalCost = nTotalCost + GetGoldPieceValue(oItem); oItem = GetNextItemInInventory(oShop); } nTotalCost = nTotalCost / nCount; oItem = GetFirstItemInInventory(oShop); while (GetIsObjectValid(oItem)) { if (GetGoldPieceValue(oItem) < nTotalCost) { DestroyObject(oItem); nCount = nCount - 1; } oItem = GetNextItemInInventory(oShop); } AssignCommand (oTalker, ActionSpeakString ("\n<cúú>The PLAYER ITEMS shop inventory has been filtered. Low cost items have been removed.\n", TALKVOLUME_SHOUT)); SetLocalInt(oShop, "itemcount", nCount); } }
0
Comments
Change nRemoveCount up or down from 10 to change the 'x' number of items to remove..
This code has been tested and works as intended but now I have to figure out how to stop the filter if anyone on the server is currently browsing the shop.
This is the on open script.
I added this to the top of the script above for the on close script.
My servers been running these scripts for about 2 weeks now and it works as intended.