Jump to content
  • 0

How to get random 1 item from the list


Question

Posted

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);

 

 

1 answer to this question

Recommended Posts

  • 0
Posted
// 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]);
}

 

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.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...