yuhsing

Untitled

Apr 14th, 2013
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.67 KB | None | 0 0
  1.  
  2. - shop Emistry_Shop2 -1,512:100
  3.  
  4. prontera,155,181,5 script Sample 757,{
  5. .@gmlevel = getgmlevel();
  6.  
  7. mes "How can i help you ?";
  8. next;
  9. switch( select( "View Shop",
  10. ( .@gmlevel < .gm_level )?"":"[GM] Add Item",
  11. ( .@gmlevel < .gm_level )?"":"[GM] Delete Item",
  12. ( .@gmlevel < .gm_level )?"":"[GM] Change Currency" )){
  13.  
  14. Case 1:
  15. if( $shop_size2 < 1 ){
  16. mes "No items for sales right now.";
  17. }else if( getarraysize( $shop_currency2$ ) != 2 ){
  18. mes "Currency isnt selected.";
  19. }else{
  20. mes "Currency : "+$shop_currency2$[0];
  21. npcshopitem "Emistry_Shop2",512,100;
  22. npcshopdelitem "Emistry_Shop2",512;
  23. .@i = 0;
  24. while( .@i < $shop_size2 ){
  25. npcshopadditem "Emistry_Shop2",$shop_item2[.@i],$shop_cost2[.@i];
  26. .@i++;
  27. }
  28. deletearray @bought_nameid;
  29. deletearray @bought_quantity;
  30. callshop "Emistry_Shop2",1;
  31. npcshopattach "Emistry_Shop2";
  32. end;
  33. }
  34. break;
  35. Case 2:
  36. if( getarraysize( $shop_currency2$ ) != 2 ){
  37. mes "Please edit the Currency first.";
  38. }else if( $shop_size2 >= .max_item ){
  39. mes "Only allow Max. of "+.max_item+" items in shop.";
  40. }else{
  41. mes "Enter Item ID :";
  42. do{
  43. input .@item,0,32767;
  44. if( !.@item ) close;
  45.  
  46. .@i = 0;
  47. while( .@i < $shop_size2 ){
  48. if( $shop_item2[.@i] == .@item ){
  49. message strcharinfo(0),"Cant add 2 same items.";
  50. .@item = 1;
  51. break;
  52. }
  53. .@i++;
  54. }
  55.  
  56. }while( getitemname( .@item ) == "null" );
  57. mes "Enter Amount per purchase :";
  58. input .@amount,1,30000;
  59. mes "Enter Cost per purchase :";
  60. do{
  61. input .@cost$;
  62. .@cost = atoi( .@cost$ );
  63. }while( !.@cost );
  64. if( .@cost && .@amount ){
  65. next;
  66. mes "Item : "+getitemname( .@item );
  67. mes "Amount : "+.@amount;
  68. mes "Cost : "+.@cost+" x "+$shop_currency2$[0];
  69. if( select( "Cancel","Confirm" ) == 2 ){
  70. $shop_item2_name$[ $shop_size2 ] = getitemname( .@item );
  71. $shop_item2[ $shop_size2 ] = .@item;
  72. $shop_amount2[ $shop_size2 ] = .@amount;
  73. $shop_cost2[ $shop_size2 ] = .@cost;
  74. $shop_size2 = getarraysize( $shop_item2 );
  75. }
  76. }else{
  77. mes "Cancelled.";
  78. }
  79. }
  80. break;
  81. Case 3:
  82. if( $shop_size2 < 1 ){
  83. mes "No items in the shop list.";
  84. }else{
  85. mes "Select an item to remove from shop list.";
  86. .@i = select( implode( $shop_item2_name$,":" ) ) - 1;
  87. mes "Remove "+$shop_item2_name$[.@i]+" from shop ?";
  88. if( select( "Cancel","Confirm" ) == 2 ){
  89. mes "Done";
  90. deletearray $shop_item2_name$[.@i],1;
  91. deletearray $shop_item2[.@i],1;
  92. deletearray $shop_amount2[.@i],1;
  93. deletearray $shop_cost2[.@i],1;
  94. $shop_size2 = getarraysize( $shop_item2 );
  95. }
  96. }
  97. break;
  98. Case 4:
  99. mes "Enter your shop Currency.";
  100. mes "^FF0000ItemID or Variables^000000.";
  101. input .@currency$;
  102. if( getitemname( atoi( .@currency$ ) ) != "null" ){
  103. .@currency_name$ = getitemname( atoi( .@currency$ ) );
  104. }else{
  105. mes "Enter a Name for Currency";
  106. input .@currency_name$;
  107. }
  108. next;
  109. mes "Your New Currency :";
  110. mes "Name : "+.@currency_name$;
  111. mes "Currency : "+.@currency$;
  112. if( select( "Cancel","Confirm" ) == 2 ){
  113. setarray $shop_currency2$,.@currency_name$,.@currency$;
  114. }
  115. default: break;
  116. }
  117. close;
  118.  
  119. OnInit:
  120. // Min. GM Level to access GM Menu
  121. .gm_level = 99;
  122. // Max Items in Shop
  123. .max_item = 30;
  124. end;
  125.  
  126. OnBuyItem:
  127. if( !checkweight2( @bought_nameid,@bought_quantity ) ){
  128. mes "You will Overweight for that much of items.";
  129. }else{
  130. mes "You selected :";
  131. .@total_cost = .@x = .@y = 0;
  132. while( .@x < getarraysize( @bought_nameid ) ){
  133. mes "^FF0000"+@bought_quantity[.@x]+" x ^0000FF"+getitemname( @bought_nameid[.@x] )+"^000000";
  134. while( .@y < $shop_size2 ){
  135. if( @bought_nameid[.@x] == $shop_item2[.@y] ){
  136. .@total_cost = .@total_cost + ( $shop_cost2[.@y] * @bought_quantity[.@x] );
  137. break;
  138. }
  139. .@y++;
  140. }
  141. .@x++;
  142. }
  143. mes " ";
  144. mes "Total Cost : "+.@total_cost+" x "+$shop_currency2$[0];
  145. next;
  146. if( select( "Buy","Cancel" ) == 1 ){
  147. .@item_currency = atoi( $shop_currency2$[1] );
  148. if( getitemname( .@item_currency ) != "null" ){
  149. if( countitem( .@item_currency ) >= .@total_cost ){
  150. delitem .@item_currency,.@total_cost;
  151. }else{
  152. mes "Not enough items.";
  153. close;
  154. }
  155. }else{
  156. if( getd( $shop_currency2$[1] ) >= .@total_cost ){
  157. setd( $shop_currency2$[1] ),( getd( $shop_currency2$[1] ) - .@total_cost );
  158. }else{
  159. mes "Not enough Currency";
  160. close;
  161. }
  162. }
  163. mes "DONE purchased "+getarraysize( @bought_nameid )+" Items using "+.@total_cost+" x "+$shop_currency2$[0];
  164. for( .@i = 0; .@i < getarraysize( @bought_nameid ); .@i++ )
  165. getitem @bought_nameid[.@i],@bought_quantity[.@i];
  166. }
  167. }
  168. close;
  169. }
Advertisement
Add Comment
Please, Sign In to add comment