Advertisement
Emistry

[RO] Exchanger - Item to Item - Rand

Jan 7th, 2017
306
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. prontera,155,181,5 script Sample#item_rand_item 757,{
  2.  
  3. mes "Pay "+.amount+"x "+getitemname( .itemid )+" and get random items.";
  4.  
  5. while ( countitem( .itemid ) >= .amount ) {
  6. if ( select( "Pay","Cancel" ) == 2 ) break;
  7. delitem .itemid,.amount;
  8. do {
  9. .@index = rand( .item_size );
  10. } while( rand( .total_rate ) > .rate[.@index] );
  11. getitem .item[.@index],1;
  12. announce "<Random Item> '"+strcharinfo(0)+"' gained "+getitemname( .item[.@index] )+" at "+.rate[.@index]+"%. Gratz.",bc_all;
  13. }
  14. close;
  15.  
  16. OnInit:
  17. .itemid = 512;
  18. .amount = 100;
  19.  
  20. setarray .item,501,502,503,504,505,506,507;
  21. setarray .rate, 10, 10, 20, 30, 30, 40, 50;
  22.  
  23. .item_size = getarraysize( .item );
  24. for ( .@i = 0; .@i < .item_size; .@i++ )
  25. .total_rate += .rate[.@i];
  26. end;
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement