Guest User

Untitled

a guest
Jan 19th, 2019
88
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.24 KB | None | 0 0
  1. // Settings :
  2. // - Only required to edit the ShopSetting() Function
  3. // Notes : You may also add / remove Menu ( If any )
  4. // - Shop Currency can be either ItemID or Variable Name, but must write within Quotation Marks ( "" )
  5. // Ex. of Variable. -> Zeny , #CASHPOINTS , #KAFRAPOINTS , CustomVariable , #CustomVariable
  6. // - ERROR Message are used to show Invalid Settings in your NPC.
  7.  
  8.  
  9. // Leave this alone...
  10. - shop Emistry_Shop -1,512:100
  11.  
  12.  
  13. prontera,171,158,5 script Active Points Trader#1 828,{
  14. function ShopSettings;
  15. function ValidateCost;
  16. function CurrencyInfo;
  17. function ClearData;
  18. function ValueConvert;
  19. function ErrorNotice;
  20.  
  21. mes "[Active Points Trader]";
  22. mes "^00FF00____________________________^000000";
  23. mes "Select Open to open the shop";
  24. next;
  25. // Menu Selection
  26. select("Open");
  27.  
  28. ClearData();
  29. ShopSettings( @menu );
  30. npcshopitem "Emistry_Shop",512,100;
  31. npcshopdelitem "Emistry_Shop",512;
  32. for(set .@i,0; .@i < getarraysize( @ItemLists ); set .@i,.@i+1)
  33. npcshopadditem "Emistry_Shop",@ItemLists[.@i],@ItemCost[.@i];
  34. mes "Okay...wait awhile";
  35. mes "^00FF00____________________________^000000";
  36. CurrencyInfo( @Currency$ );
  37. mes "^00FF00____________________________^000000";
  38. callshop "Emistry_Shop",1;
  39. npcshopattach "Emistry_Shop";
  40. end;
  41.  
  42.  
  43. function ShopSettings {
  44. switch( getarg(0) ){
  45. Case 1:
  46. // Currency [ Item ID / Variable Name ]
  47. set @Currency$,"#KAFRAPOINTS";
  48. // Item ID Lists
  49. setarray @ItemLists[0],29981,29979,29925,30100,30101,30102,30103,30104,30105,30106;
  50. // Item Price
  51. setarray @ItemCost[0],5000,1000,3000,3000,3000,3000,3000,3000,3000,3000;
  52. break;
  53. default:
  54. ErrorNotice( "Invalid Menu Selection for Menu "+@menu+"." );
  55. close;
  56. }
  57.  
  58.  
  59. if( @Currency$ == "" )
  60. ErrorNotice( "Invalid Currency Setting in Menu "+@menu+" ." );
  61. if( getarraysize( @ItemCost ) != getarraysize( @ItemLists ) || getarraysize( @ItemLists ) != getarraysize( @ItemCost ) )
  62. ErrorNotice( "Missing or Extra Value of Item or Cost Settings in Menu "+@menu+" ." );
  63. return;
  64. }
  65.  
  66. function ErrorNotice {
  67. mes "^FF0000ERROR^000000 - "+getarg(0);
  68. mes "^00FF00____________________________^000000";
  69. mes "Inform this Message to ^0000FFGame Staffs^000000 immediately !";
  70. close;
  71. }
  72.  
  73. function CurrencyInfo {
  74. if( getitemname( atoi( getarg(0) ) ) != "null" ){
  75. mes "Item Currency : ^FF0000"+getitemname( atoi( getarg(0) ) )+"^000000";
  76. mes "Available Amount : ^0000FF"+ValueConvert( countitem( atoi( getarg(0) ) ) )+"^000000";
  77. }else if( getitemname( atoi( getarg(0) ) ) == "null" ){
  78. mes "Variable Currency : ^FF0000"+getarg(0)+"^000000";
  79. mes "Available Amount : ^0000FF"+ValueConvert( getd( getarg(0) ) )+"^000000";
  80. }
  81. return;
  82. }
  83.  
  84. function ValidateCost {
  85. if( getitemname( atoi( getarg(0) ) ) != "null" ){
  86. if( countitem( atoi( getarg(0) ) ) < getarg(1) ) return 1;
  87. }else{
  88. if( getd( getarg(0) ) < getarg(1) ) return 1;
  89. }
  90. return 0;
  91. }
  92.  
  93. function ClearData {
  94. set @Currency$,"";
  95. set @TotalCost,0;
  96. deletearray @bought_nameid[0],getarraysize( @bought_nameid );
  97. deletearray @bought_quantity[0],getarraysize( @bought_quantity );
  98. deletearray @ItemLists[0],getarraysize( @ItemLists );
  99. deletearray @ItemCost[0],getarraysize( @ItemCost );
  100. return;
  101. }
  102.  
  103. function ValueConvert {
  104. set .@num, atoi(""+getarg(0));
  105. if ( .@num == 0 || .@num >= 2147483647 ) return getarg(0);
  106. set .@l, getstrlen(""+.@num);
  107. for ( set .@i,0; .@i < .@l; set .@i, .@i + 1 ) {
  108. set .@num$, .@num % pow(10,.@i+1) / pow(10,.@i) + .@num$;
  109. if ( (.@i+1) % 3 == 0 && .@i+1 != .@l ) set .@num$, ","+ .@num$;
  110. }
  111. return .@num$;
  112. }
  113.  
  114. OnBuyItem:
  115. ShopSettings( @menu );
  116. for(set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1)
  117. for(set @j,0; @j < getarraysize( @ItemLists ); set @j,@j+1)
  118. if( @ItemLists[@j] == @bought_nameid[@i] )
  119. set @TotalCost,@TotalCost + ( @ItemCost[@j] * @bought_quantity[@i] );
  120. mes "^FF0000 BILLING LIST^000000";
  121. mes "^00FF00____________________________^000000";
  122. for( set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1 )
  123. mes "^FF0000"+@bought_quantity[@i]+" x ^0000FF"+getitemname( @bought_nameid[@i] )+"^000000";
  124. mes "^00FF00____________________________^000000";
  125.  
  126. if( getitemname( atoi( @Currency$ ) ) != "null" )
  127. mes "Total Cost : ^0000FF"+ValueConvert( @TotalCost )+" x "+getitemname( atoi( @Currency$ ) )+"^000000";
  128. else if( getitemname( atoi( @Currency$ ) ) == "null" ){
  129. mes "Total Cost : ^0000FF"+ValueConvert( @TotalCost )+" "+@Currency$+"^000000";
  130. }
  131.  
  132. mes "^00FF00____________________________^000000";
  133. if( ValidateCost( @Currency$,@TotalCost ) ){
  134. if( getitemname( atoi( @Currency$ ) ) != "null" )
  135. mes "[ ^FF0000X^000000 ] Insufficient ^0000FF"+getitemname( atoi( @Currency$ ) )+"^000000";
  136. else{
  137. mes "[ ^FF0000X^000000 ] Insufficient ^0000FF"+@Currency$+"^000000";
  138. }
  139. }else{
  140. if( select( "^0000FFPurchase^000000:Cancel" ) == 1 ){
  141. if( getitemname( atoi( @Currency$ ) ) != "null" )
  142. delitem atoi( @Currency$ ),@TotalCost;
  143. else{
  144. set getd( @Currency$ ),getd( @Currency$ ) - @TotalCost;
  145. }
  146. for(set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1)
  147. getitem @bought_nameid[@i],@bought_quantity[@i];
  148. message strcharinfo(0),"Purchased "+getarraysize( @bought_nameid )+" Items.";
  149. mes "Thank you for shopping.";
  150. }
  151. }
  152. ClearData();
  153. close;
  154.  
  155. }
Add Comment
Please, Sign In to add comment