Jump to content
  • 0

About Custom box using function


shinz

Question


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  10
  • Reputation:   0
  • Joined:  03/07/12
  • Last Seen:  

hello, sorry for asking help again :)

 

i search on forum how to create a custom box (like obb), and i read about using function to create it.

 

what i gonna ask is, is it possible to get random item on same percentage?

 

i've implement this function (script) on my server :

 

function script PrizeBox {
setarray .BoxItems[0],501,502,503,504;


set .rand, rand(100);

if (.rand <= 5){
getitem .BoxItems[0],1;}
if (.rand <= 10 && .rand > 5){
getitem .BoxItems[1],1;}
if (.rand <= 25 && .rand > 10){
getitem .BoxItems[2],1;}
if (.rand > 25){
getitem .BoxItems[3],1;
getitem .BoxItems[2],1;}
end;
}

in this function, i just can get only one item (like red potion). how about if i want to get random item on same percentage? for example, if .rand <= 5 , i have a chance to get random item like red potion, aloe leaflet, mastela fruit?

i've try to add 1 more line , (the red font) but it just give me two item together X_X.

 
thank you before
 
best regards,
 
Liu
Edited by shinz
Link to comment
Share on other sites

2 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  50
  • Topics Per Day:  0.01
  • Content Count:  1702
  • Reputation:   238
  • Joined:  09/05/12
  • Last Seen:  


function script PrizeBox {

      setarray .BoxItems[0],501,502,503,504;

      if ( rand( 100 ) < 5 ) 

          getitem .BoxItems[ rand( getarraysize( .BoxItems ) ) ], 1;

      return;

}

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1131
  • Joined:  05/27/12
  • Last Seen:  

Consider taking a look at db/re/item_package.txt, a relatively new database that should suit your purpose. There's documentation for it in doc/item_group.txt.

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