Code:
[DEFNAME VendorsEconomy]
VendorMaxSell 50 // Missing value
Funny, everyone congratulated you on your script but didn't notice it is missing a key element. *smh*
What is the relevance of this tag on the vendor for every purchase but not the one item type in general?
If argn1 > <VendorMaxSell> which you check for.. why are you testing if they are equal?
Also... your tag relies on the sale of any item and doesn't record that item being sold; just a total in general. So he/she will only buy 'x' of ANY item and that is it. Was this desired?
Plus I am finding your script contradictory. I am working on a rework now.
Here is the rework:
Code:
[defname vendorseconomy]
sellstockdelay 3600 //delay in seconds to "restock" the vendor.
vendormaxsell 500 // Max Items
[events e_playersell]
on=@ItemSell
local.maxamount=<eval (<serv.vendormaxsell> - <argo.tag0.sellstock>)>
// vendor cannot hold anymore items. we shall not buy the items and exit from code.
if (<argn1> > <local.maxamount>) && (<local.maxamount> == 0)
argo.say Sorry <name>, my stock of items is full and I can't take anything more with me.
return 1
endif
// vendor can hold more items, but the players is selling more than the vendor can hold.
if (<local.maxamount> != 0) && (<argn1> > <local.maxamount>)
argo.say Sorry <name>, I don't want to buy all of these items. Give me <local.maxamount> and we both will be satisfied!
return 1
endif
argo.tag0.sellstock += <argn1>
argo.timerf <ddef.sellstockdelay>, sellrestock <argn1>
[function sellrestock]
tag.sellstock -= <argn>
Now in the above script I am sticking to your vendor only buying "x" items. I see where you are coming from with that to a point. I fixed all of your redundancies and contradictions as well. ARGS wasn't needed in the function; just ARGN since it was storing a #. I chose to use two different IF statements to try and exit the code as fast as possible without parsing the extras. If the purchase goes through it will add to the tag0.sellstock.
Before you argue you tested this... there is no way you tested the (==) parsing you did above. If the player was selling wares == to what the vendor could hold, then the sale would be successful. Also there was no reason to check what the max items the vendor can hold from the def. That is pointless if he was only able to carry say 50 from the local. Telling the player they could for instance sell 500 from the def would have left them confused and complaining about a bug.
Also I'd like to note this is firing on EVERY item sold. Not just the entire lot at once. ACT is the item in question. Just so you know how often this is actually firing.