The following warnings occurred:
Warning [2] Use of undefined constant SAPI_NAME - assumed 'SAPI_NAME' (this will throw an Error in a future version of PHP) - Line: 3388 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3388 errorHandler->error
/showthread.php 116 build_archive_link
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/inc/functions.php 3324 build_forum_breadcrumb
/showthread.php 195 build_forum_breadcrumb
Warning [2] Use of undefined constant IN_ARCHIVE - assumed 'IN_ARCHIVE' (this will throw an Error in a future version of PHP) - Line: 3331 - File: inc/functions.php PHP 7.4.33-nmm7 (Linux)
File Line Function
/inc/functions.php 3331 errorHandler->error
/showthread.php 195 build_forum_breadcrumb






Post Reply 
 
Thread Rating:
  • 2 Votes - 4.5 Average
  • 1
  • 2
  • 3
  • 4
  • 5
NPC buy limit
Author Message
Khaos
Master
**

Posts: 595
Likes Given: 166
Likes Received: 83 in 51 posts
Joined: Mar 2012
Reputation: 11



Post: #4
RE: NPC buy limit
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*

Code:
tag0.sellstock

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.
(This post was last modified: 11-28-2013 05:25 PM by Khaos.)
11-28-2013 04:31 PM
Find all posts by this user Like Post Quote this message in a reply
Post Reply 


Messages In This Thread
NPC buy limit - Staff_Stanic - 11-28-2013, 01:27 AM
RE: NPC buy limit - amonvangrell - 11-28-2013, 05:22 AM
RE: NPC buy limit - XuN - 11-28-2013, 07:50 AM
RE: NPC buy limit - Khaos - 11-28-2013 04:31 PM
RE: NPC buy limit - Staff_Stanic - 11-29-2013, 03:01 AM
RE: NPC buy limit - Khaos - 11-29-2013, 07:56 AM
RE: NPC buy limit - Khaos - 11-30-2013, 12:26 PM
RE: NPC buy limit - amonvangrell - 01-19-2014, 10:23 AM
RE: NPC buy limit - kn4tseb - 09-19-2014, 04:27 AM
RE: NPC buy limit - Extreme - 09-19-2014, 06:34 AM
RE: NPC buy limit - kn4tseb - 09-19-2014, 08:19 AM
RE: NPC buy limit - Extreme - 09-19-2014, 08:38 AM
RE: NPC buy limit - kn4tseb - 09-19-2014, 08:41 AM
RE: NPC buy limit - chrono - 01-18-2022, 07:07 PM

Forum Jump:


User(s) browsing this thread: 1 Guest(s)