Jump to content
  • 0
lphz

callfunc "F_Rand",

Question

// Returns a random argument.
// -- callfunc "F_Rand",arg0,arg1,...
// Example:
//    // You can use it to pick a random number from a list:
//    set @itemIDfromList, callfunc("F_Rand",1129,1222,1163,1357,1360,1522,1811,1410);
//////////////////////////////////////////////////////////////////////////////////
function    script    F_Rand    {
    return getarg(rand(getargcount()));
}

Please help to customize this function.
I want to be able to set the amount and percent of each piece,
Example :-
ItemID , Percent , Amount
callfunc("F_Rand",1129,100,10,1222,90,5,1163,80,20,1357,70,8);

Link to comment
Share on other sites

2 answers to this question

Recommended Posts

  • 0
//callfunc("RENAME_ME",501,50,30,502,5,20,503,10,30);
//ITEM ID, AMOUNT, WEIGHT
function	script	RENAME_ME	{
	for([email protected] = 0; [email protected] < getargcount(); [email protected] += 3){
		[email protected][[email protected]/3] = getarg([email protected]);
		[email protected][[email protected]/3] = getarg([email protected]+1);
		[email protected] += getarg([email protected]+2);
		for([email protected] = 0; [email protected] < getarg([email protected]+2); [email protected]++)
			[email protected][getarraysize([email protected])] = getarg([email protected]);
	}
	[email protected] = [email protected][rand([email protected])];
	getitem [email protected],[email protected][inarray([email protected],[email protected])];
	return;
}

 

Link to comment
Share on other sites

  • 0

Thank you bro,

But there are times when the item is not received.

Out of 50 open tests, 36 items were obtained, 14 were missing.

 

Video 2022-04-07 11-06-56.mkv

 

317115784_2.png.8cefc6326b268695d280c5089ed6035c.png

  - Id: 1110000
    AegisName: Char_Zeros_Bag_1
    Name: Char Zeros Bag 1
    Type: Usable
    Buy: 1
    Weight: 10
    NoUse:
      Sitting: true
    Trade:
      NoDrop: true
      NoTrade: true
      NoSell: true
      NoCart: true
      NoStorage: true
      NoGuildStorage: true
      NoMail: true
      NoAuction: true
    Script: |
      callfunc("RENAME_ME",1110100,1,100,1110101,1,100,1110102,1,80,1110103,1,80,1110104,1,60);

 

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