Advertisement
Guest User

Untitled

a guest
Jul 9th, 2015
278
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.02 KB | None | 0 0
  1. // Leave this alone...
  2. - shop PvPPoint_Shop -1,512:100
  3.  
  4.  
  5. prontera,150,150,5 script PvP Shop 623,{
  6. function ShopSettings;
  7. function ValidateCost;
  8. function CurrencyInfo;
  9. function ClearData;
  10. function ValueConvert;
  11. function ErrorNotice;
  12.  
  13.  
  14. mes "[PvP Shop]";
  15. //next;
  16. // Menu Selection
  17. select("PvP Shop");
  18.  
  19. ClearData();
  20. ShopSettings( @menu );
  21. npcshopitem "PvPPoint_Shop",512,100;
  22. npcshopdelitem "PvPPoint_Shop",512;
  23. for(set .@i,0; .@i < getarraysize( @ItemLists ); set .@i,.@i+1)
  24. npcshopadditem "PvPPoint_Shop",@ItemLists[.@i],@ItemCost[.@i];
  25. mes "Okay...wait awhile";
  26. mes "^00FF00____________________________^000000";
  27. CurrencyInfo( @Currency$ );
  28. mes "^00FF00____________________________^000000";
  29. callshop "PvPPoint_Shop",1;
  30. npcshopattach "PvPPoint_Shop";
  31. end;
  32.  
  33.  
  34. function ShopSettings {
  35. switch( getarg(0) ){
  36. case 1:
  37. // Currency [ Item ID / Variable Name ]
  38. set @Currency$,"#PvPPoint";
  39. // Item ID Lists // PUT YOUR CUSTOM ITEM ID's
  40. setarray @ItemLists[0],501,502,503,504,505;
  41. // Item Price // PUT YOUR CUSTOM ITEM Price
  42. setarray @ItemCost[0],1,2,3,4,5;
  43. break;
  44. // Case 4,5,6.....etc...
  45. default:
  46. ErrorNotice( "Invalid Menu Selection for Menu "+@menu+"." );
  47. close;
  48. }
  49.  
  50. if( @Currency$ == "" )
  51. ErrorNotice( "Invalid Currency Setting in Menu "+@menu+" ." );
  52. if( getarraysize( @ItemCost ) != getarraysize( @ItemLists ) || getarraysize( @ItemLists ) != getarraysize( @ItemCost ) )
  53. ErrorNotice( "Missing or Extra Value of Item or Cost Settings in Menu "+@menu+" ." );
  54. return;
  55. }
  56.  
  57. function ErrorNotice {
  58. mes "^FF0000ERROR^000000 - "+getarg(0);
  59. mes "^00FF00____________________________^000000";
  60. mes "Inform this Message to ^0000FFGame Staffs^000000 immediately !";
  61. close;
  62. }
  63.  
  64. function CurrencyInfo {
  65. if( getitemname( atoi( getarg(0) ) ) != "null" ){
  66. mes "Item Currency : ^FF0000"+getitemname( atoi( getarg(0) ) )+"^000000";
  67. mes "Available Amount : ^0000FF"+ValueConvert( countitem( atoi( getarg(0) ) ) )+"^000000";
  68. }else if( getitemname( atoi( getarg(0) ) ) == "null" ){
  69. mes "Variable Currency : ^FF0000"+getarg(0)+"^000000";
  70. mes "Available Amount : ^0000FF"+ValueConvert( getd( getarg(0) ) )+"^000000";
  71. }
  72. return;
  73. }
  74.  
  75. function ValidateCost {
  76. if( getitemname( atoi( getarg(0) ) ) != "null" ){
  77. if( countitem( atoi( getarg(0) ) ) < getarg(1) ) return 1;
  78. }else{
  79. if( getd( getarg(0) ) < getarg(1) ) return 1;
  80. }
  81. return 0;
  82. }
  83.  
  84. function ClearData {
  85. set @Currency$,"";
  86. set @TotalCost,0;
  87. deletearray @bought_nameid[0],getarraysize( @bought_nameid );
  88. deletearray @bought_quantity[0],getarraysize( @bought_quantity );
  89. deletearray @ItemLists[0],getarraysize( @ItemLists );
  90. deletearray @ItemCost[0],getarraysize( @ItemCost );
  91. return;
  92. }
  93.  
  94. function ValueConvert {
  95. set .@num, atoi(""+getarg(0));
  96. if ( .@num == 0 || .@num >= 2147483647 ) return getarg(0);
  97. set .@l, getstrlen(""+.@num);
  98. for ( set .@i,0; .@i < .@l; set .@i, .@i + 1 ) {
  99. set .@num$, .@num % pow(10,.@i+1) / pow(10,.@i) + .@num$;
  100. if ( (.@i+1) % 3 == 0 && .@i+1 != .@l ) set .@num$, ","+ .@num$;
  101. }
  102. return .@num$;
  103. }
  104.  
  105. OnBuyItem:
  106. ShopSettings( @menu );
  107. for(set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1)
  108. for(set @j,0; @j < getarraysize( @ItemLists ); set @j,@j+1)
  109. if( @ItemLists[@j] == @bought_nameid[@i] )
  110. set @TotalCost,@TotalCost + ( @ItemCost[@j] * @bought_quantity[@i] );
  111. mes "^FF0000 BILLING LIST^000000";
  112. mes "^00FF00____________________________^000000";
  113. for( set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1 )
  114. mes "^FF0000"+@bought_quantity[@i]+" x ^0000FF"+getitemname( @bought_nameid[@i] )+"^000000";
  115. mes "^00FF00____________________________^000000";
  116.  
  117. if( getitemname( atoi( @Currency$ ) ) != "null" )
  118. mes "Total Cost : ^0000FF"+ValueConvert( @TotalCost )+" x "+getitemname( atoi( @Currency$ ) )+"^000000";
  119. else if( getitemname( atoi( @Currency$ ) ) == "null" ){
  120. mes "Total Cost : ^0000FF"+ValueConvert( @TotalCost )+" "+@Currency$+"^000000";
  121. }
  122.  
  123. mes "^00FF00____________________________^000000";
  124. if( ValidateCost( @Currency$,@TotalCost ) ){
  125. if( getitemname( atoi( @Currency$ ) ) != "null" )
  126. mes "[ ^FF0000X^000000 ] Insufficient ^0000FF"+getitemname( atoi( @Currency$ ) )+"^000000";
  127. else{
  128. mes "[ ^FF0000X^000000 ] Insufficient ^0000FF"+@Currency$+"^000000";
  129. }
  130. }else{
  131. if( select( "^0000FFPurchase^000000:Cancel" ) == 1 ){
  132. if( getitemname( atoi( @Currency$ ) ) != "null" )
  133. delitem atoi( @Currency$ ),@TotalCost;
  134. else{
  135. set getd( @Currency$ ),getd( @Currency$ ) - @TotalCost;
  136. }
  137. for(set @i,0; @i < getarraysize( @bought_nameid ); set @i,@i+1)
  138. getitem @bought_nameid[@i],@bought_quantity[@i];
  139. message strcharinfo(0),"Purchased "+getarraysize( @bought_nameid )+" Items.";
  140. // announce "["+strcharinfo(0)+"] has purchase a ["+ getitemname(@bought_nameid) +"] from the Event Shop!", 0;
  141. mes "Thank you for shopping.";
  142. }
  143. }
  144. ClearData();
  145. close;
  146. OnInit:
  147. do {
  148. delwaitingroom;
  149. waitingroom "Check Me~!!",0;
  150. sleep 3000; // Evites super infinity loop
  151. } while(1); // End Loop
  152. end;
  153. }
  154. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement