Jump to content
  • 0

Add one item to everyone's storage


michaelsoftman

Question


  • Group:  Members
  • Topic Count:  48
  • Topics Per Day:  0.01
  • Content Count:  410
  • Reputation:   29
  • Joined:  04/04/12
  • Last Seen:  

I can't think of a clean way to do this.  Is there a way to add one item to everyone's storage (unless the storage is at max capacity already.) using an NPC?

 

Or hey, even using SQL directly would be ok.  But I can't think of a way to do it simply.  A loop would have to determine the current storage (Example - 100 items out of 600 stored) then add the chosen item as 101.  But it would have to do this for every single account.

 

 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  182
  • Reputation:   36
  • Joined:  01/26/12
  • Last Seen:  

If you use NPCs or you even let all the job only to MySQL, resulting code will be tricky. First one becouse you'll have to loop over data and queries (remember arrays in scripting have up to 128 positions) and using only one SQL query will put you in need to do a subquery which returns two columns (account_id and amount of storage used). I'd suggest to use a PHP script with password protection, run it once and then delete it.

 

Decide whatever you decide (NPC or PHP, but remember to loop if you use the NPC), there is the first query you need (edit the number 600 to the value of the max storage):

SELECT `account_id`, COUNT(1) as `count` FROM `storage` WHERE `count` < 600

 

I assumed every account has at least 1 storage space used for this. You don't need to have the count column but you need to calculate the number of spaces they have used. Then you save the account IDs in an array and launch another SQL query with the inserts while you go through the available IDs.

 

Or well, you can send them all an email with the item... which is surprisingly easier.

 

P.S.: Whoa! I've spent more than an hour trying to make an one-query reply without succeeding.

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.

Guest
Answer this question...

×   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.

×
×
  • Create New...