Jump to content
  • 0

How to get random 1 item from the list


Dolphin86

Question


  • Group:  Members
  • Topic Count:  255
  • Topics Per Day:  0.06
  • Content Count:  706
  • Reputation:   16
  • Joined:  01/07/12
  • Last Seen:  

hello rathena, i need help on how should i turn this part of script from getting all of the item to random 1 item from the list.

Spoiler
setarray(.crafting_recipe_p1_t2_products, 40101, 1,40102, 1,40103, 1,40104, 1,40105, 1);

 

 

Link to comment
Share on other sites

1 answer to this question

Recommended Posts

  • 0

  • Group:  Members
  • Topic Count:  1
  • Topics Per Day:  0.00
  • Content Count:  232
  • Reputation:   86
  • Joined:  06/30/18
  • Last Seen:  

// Change
setarray(.crafting_recipe_p1_t2_products, 40101, 1,40102, 1,40103, 1,40104, 1,40105, 1);
// to
setarray(.crafting_recipe_p1_t2_products, 40101, 40102, 40103, 40104, 40105);
setarray(.crafting_recipe_p1_t2_amounts,  1,  1, 1, 1, 1);

// To handout 1 random item you do it like this:
.@item_index = rand(getarraysize(.crafting_recipe_p1_t2_products));
getitem(.crafting_recipe_p1_t2_products[.@item_index], .crafting_recipe_p1_t2_amounts[.@item_ind//sex]);

// To handout all items you do it like this:
for(.@i = 0; .@i < getarraysize(.crafting_recipe_p1_t2_products); .@i++) {
	getitem(.crafting_recipe_p1_t2_products[.@i], .crafting_recipe_p1_t2_amounts[.@i]);
}

 

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