Jump to content
McKay Development

User Inventory hash?


Recommended Posts

Hey. I wanted to know if there is a way to find out if the User's inventory has been changed? Without a second inventory check.
Maybe there is a way to get an inventory hash or item count?

Suppose the following situation:

  1. User uses command !CHECK
  2. The bot receives the user's inventory and gives information.
  3. User uses command !SELL
  4. The bot receives the user's inventory and and sends the trade offer.

I would like to get rid of the second inventory check and use the first (I save it).
But there may be another situation:

  1. User uses command !CHECK
  2. The bot receives the user's inventory and gives information.
  3. User receives or sells items / Inventory has been changed
  4. User uses command !SELL
  5. ?

Any ideas?
I think I can save the result with a time stamp. But I think that even here rare errors are possible.

// !check:
community.getUserInventoryContents( ... (err, inv) => {
	hisInv = [inv, Date.now()];

// !sell:
if (hisInv and hisInv[1] < Date.now() - $minute) {
	//sendtradeoffer
} else {
	community.getUserInventoryContents( ... (err, inv) => {
		//sendtradeoffer

 

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...