yuhsing

Untitled

Feb 26th, 2013
58
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.40 KB | None | 0 0
  1.  
  2.  
  3. prontera,155,161,5 script Sample 757,{
  4. .@gm_level = getgmlevel();
  5.  
  6. switch( select( "Informations",
  7. ( .@gm_level == .vip_id )?"Check Remaining Time":"",
  8. ( .@gm_level == .vip_id )?"":"Purchase VIP" ) ){
  9. Case 1:
  10. mes "This is a VIP system.";
  11. break;
  12. Case 2:
  13. mes "Your VIP Time Left :";
  14. mes " > ^0055FF"+callsub( view_vip_time,#premium_time )+"^000000";
  15. break;
  16. Case 3:
  17. mes "Purchase VIP ?";
  18. mes "Duration : ^0055FF"+callsub( view_vip_time,( .vip_duration + gettimetick(2) ) )+"^000000";
  19. if( .vip_item_size ){
  20. for( set .@i,0; .@i < .vip_item_size; set .@i,.@i+1 ){
  21. set .@amount,countitem( .vip_item[.@i] );
  22. mes " > "+( ( .@amount < .vip_amount[.@i] )?"^FF0000":"^0055FF" )+" "+callsub( value_convert,.vip_amount[.@i] )+" x "+getitemname( .vip_item[.@i] )+"^000000";
  23. if( .@amount < .vip_amount[.@i] ) set .@fail,.@fail + 1;
  24. }
  25.  
  26.  
  27. }
  28. if( .vip_zeny ){
  29. mes " >"+( ( Zeny < .vip_zeny )?"^FF0000":"^0055FF" )+" "+callsub( value_convert,.vip_zeny )+" Zeny^000000";
  30. }
  31. mes "you need these items.";
  32. if( !.@fail && Zeny >= .vip_zeny )
  33. if( select("Confirm","Cancel") == 1 ){
  34. for( set .@i,0; .@i < .vip_item_size; set .@i,.@i+1 )
  35. if( countitem( .vip_item[.@i] ) < .vip_amount[.@i] ){
  36. mes "You didnt have enough "+getitemname( .vip_item[.@i] )+".";
  37. close;
  38. }
  39. for( set .@i,0; .@i < .vip_item_size; set .@i,.@i+1 )
  40. delitem .vip_item[.@i],.vip_amount[.@i];
  41. set #premium_time,( gettimetick(2) + .vip_duration );
  42. atcommand "@adjgmlvl "+.vip_id;
  43. message strcharinfo(0),"You purchased VIP for next "+callsub( view_vip_time,#premium_time );
  44. addtimer (( #premium_time - gettimetick(2) ) * 1000 ),strnpcinfo(0)+"::OnPCLoginEvent";
  45. }
  46. default: break;
  47. }
  48. close;
  49.  
  50. view_vip_time:
  51. set .@time,( getarg(0) - gettimetick(2) );
  52.  
  53. set .@day,( .@time / ( 3600 * 24 ) );
  54. set .@hour,( .@time / 3600 % 24 );
  55. set .@min,( .@time % 3600 / 60 );
  56. set .@sec,( .@time % 60 );
  57.  
  58. set .@time$,(( .@day )? .@day+" Day ":"" ) +
  59. (( .@hour )? .@hour+" Hr ":"" ) +
  60. (( .@min )? .@min+" Min ":"" ) +
  61. (( .@sec )? .@sec+" Sec":"" );
  62.  
  63. return .@time$;
  64.  
  65. value_convert:
  66. set .@num, atoi(""+getarg(0));
  67. if ( .@num == 0 || .@num >= 2147483647 ) return getarg(0);
  68. set .@l, getstrlen(""+.@num);
  69. for ( set .@i,0; .@i < .@l; set .@i, .@i + 1 ) {
  70. set .@num$, .@num % pow(10,.@i+1) / pow(10,.@i) + .@num$;
  71. if ( (.@i+1) % 3 == 0 && .@i+1 != .@l ) set .@num$, ","+ .@num$;
  72. }
  73. return .@num$;
  74.  
  75.  
  76. OnInit:
  77. // VIP GM Lvl
  78. set .vip_id,1;
  79. // How long each purchase of VIP last ( seconds )
  80. set .vip_duration,86400;
  81. // required item + amount
  82. setarray .vip_item,607,608,512;
  83. setarray .vip_amount,1,2,3;
  84. set .vip_item_size,getarraysize( .vip_item );
  85. // required zeny
  86. set .vip_zeny,100000;
  87. end;
  88.  
  89. OnPCLoginEvent:
  90. if( #premium_time ){
  91. deltimer strnpcinfo(0)+"::OnPCLoginEvent";
  92. if( #premium_time <= gettimetick(2) ){
  93. mes "Your VIP has expired. Status removed.";
  94. set #premium_time,0;
  95. deltimer strnpcinfo(0)+"::OnPCLoginEvent";
  96. if( getgroupid() == .vip_id )
  97. atcommand "@adjgmlvl 0";
  98. close;
  99.  
  100. }else{
  101. set .@timeleft,( #premium_time - gettimetick(2) + 1 );
  102. if( .@timeleft ){
  103. mes "Your VIP Time Left :";
  104. mes " > ^0055FF"+callsub( view_vip_time,#premium_time )+"^000000";
  105. }
  106. atcommand "@adjgmlvl "+.vip_id;
  107. addtimer ( .@timeleft * 1000 ),strnpcinfo(0)+"::OnPCLoginEvent";
  108. }
  109. }
  110. close;
  111. }
Advertisement
Add Comment
Please, Sign In to add comment