Emistry

[RO] Hourly Point - Stop when Vending Chat AFK

May 21st, 2017
546
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.17 KB | None | 0 0
  1. // https://rathena.org/board/topic/110719-hourly-vending-timer-stop/#comment-324042
  2.  
  3. - script hourly_point_main -1,{
  4.  
  5. OnInit:
  6. .duration = 3600;
  7. .vip_multi = 2;
  8. .npc_name$ = strnpcinfo(3);
  9. .delay = 1000; //Delay for idle re-check check. ( Default: 1000 [ = 1 Second ] )
  10. .idle = 60*1; //Player is idle after not moving for this many seconds. ( Default: 60*5 [ = 5 Minutes ] )
  11. set .2cpoint_amt, 20; //Points gained for consecutive time online.
  12. set .3cpoint_amt, 30; //Points gained for consecutive time online.
  13. set .4cpoint_amt, 40; //Points gained for consecutive time online.
  14. set .5cpoint_amt, 50; //Points gained for consecutive time online.
  15. set .6cpoint_amt, 60; //Points gained for consecutive time online.
  16. set .7cpoint_amt, 70; //Points gained for consecutive time online.
  17. set .8cpoint_amt, 80; //Points gained for consecutive time online.
  18. set .point_amt, 10; //Normal points gained.
  19. bindatcmd "reward", .npc_name$ + "::OnCheck";
  20. end;
  21.  
  22. OnUpdate:
  23. //Check for idle.
  24. if (@hourly_point_stopped || checkvending() >= 1 || checkchatting() == 1 || checkidle() >= .idle) {
  25. @hourly_point_stopped = 1;
  26. dispbottom "The hourly points event stopped because you were vending, chatting, or idle!";
  27. end;
  28. }
  29. set #HourlyPoints, #HourlyPoints + .point_amt * 1 * ( vip_status(1) ? .vip_multi : 1 );
  30. dispbottom "You received "+.point_amt+" Reward Hourly Points by staying ingame for 1 hour";
  31. dispbottom "Current Balance = "+#HourlyPoints+" Reward Hourly Points";
  32. set @consecutive_hour, @consecutive_hour + 1;
  33.  
  34. //Check for 2 hours consecutive
  35. if(@consecutive_hour == 2) {
  36. set #HourlyPoints, #HourlyPoints + .2cpoint_amt * 1 * ( vip_status(1) ? .vip_multi : 1 );
  37. dispbottom "You received "+.2cpoint_amt+" Reward Hourly Points due to playing for 2 consecutive hours";
  38. dispbottom "Current Balance = "+#HourlyPoints+" Reward Hourly Points";
  39. }
  40.  
  41. //Check for 3 hours consecutive
  42. else if(@consecutive_hour == 3) {
  43. set #HourlyPoints, #HourlyPoints + .3cpoint_amt * 1 * ( vip_status(1) ? .vip_multi : 1 );
  44. dispbottom "You received "+.3cpoint_amt+" Reward Hourly Points due to playing for 3 consecutive hours";
  45. dispbottom "Current Balance = "+#HourlyPoints+" Reward Hourly Points";
  46. }
  47.  
  48. //Check for 4 hours consecutive
  49. else if(@consecutive_hour == 4) {
  50. set #HourlyPoints, #HourlyPoints + .4cpoint_amt * 1 * ( vip_status(1) ? .vip_multi : 1 );
  51. dispbottom "You received "+.4cpoint_amt+" Reward Hourly Points due to playing for 4 consecutive hours";
  52. dispbottom "Current Balance = "+#HourlyPoints+" Reward Hourly Points";
  53. }
  54.  
  55. //Check for 5 hours consecutive
  56. else if(@consecutive_hour == 5) {
  57. set #HourlyPoints, #HourlyPoints + .5cpoint_amt * 1 * ( vip_status(1) ? .vip_multi : 1 );
  58. dispbottom "You received "+.5cpoint_amt+" Reward Hourly Points due to playing for 5 consecutive hours";
  59. dispbottom "Current Balance = "+#HourlyPoints+" Reward Hourly Points";
  60. }
  61.  
  62. //Check for 6 hours consecutive
  63. else if(@consecutive_hour == 6) {
  64. set #HourlyPoints, #HourlyPoints + .6cpoint_amt * 1 * ( vip_status(1) ? .vip_multi : 1 );
  65. dispbottom "You received "+.6cpoint_amt+" Reward Hourly Points due to playing for 6 consecutive hours";
  66. dispbottom "Current Balance = "+#HourlyPoints+" Reward Hourly Points";
  67. }
  68.  
  69. //Check for 7 hours consecutive
  70. else if(@consecutive_hour == 7) {
  71. set #HourlyPoints, #HourlyPoints + .7cpoint_amt * 1 * ( vip_status(1) ? .vip_multi : 1 );
  72. dispbottom "You received "+.7cpoint_amt+" Reward Hourly Points due to playing for 7 consecutive hours";
  73. dispbottom "Current Balance = "+#HourlyPoints+" Reward Hourly Points";
  74. }
  75.  
  76. //Check for 8 hours consecutive
  77. else if(@consecutive_hour == 8) {
  78. set @consecutive_hour,0;
  79. set #HourlyPoints, #HourlyPoints + .8cpoint_amt * 1 * ( vip_status(1) ? .vip_multi : 1 );
  80. dispbottom "You received "+.8cpoint_amt+" Reward Hourly Points due to playing for 8 consecutive hours";
  81. dispbottom "Current Balance = "+#HourlyPoints+" Reward Hourly Points";
  82. }
  83. @timer = gettimetick(2) + .duration;
  84. addtimer ( .duration * 1000 ), .npc_name$+"::OnUpdate";
  85. end;
  86.  
  87. OnPCLoginEvent:
  88. atcommand "@refresh "+strcharinfo(0);
  89. @timer = gettimetick(2) + .duration;
  90. addtimer ( .duration * 1000 ), .npc_name$+"::OnUpdate";
  91. dispbottom "Hourly Rewards have been started for this character.";
  92. end;
  93.  
  94. OnCheck:
  95. .@min = (@timer - gettimetick(2))/60;
  96. .@sec = (@timer - gettimetick(2))%60;
  97. dispbottom "War Server",0x9ae2d7;
  98. dispbottom "Total Hours Online " +@consecutive_hour+ "",0x9ae2d7;
  99. dispbottom "Reward Hourly Points : ^FF0000[ "+#HourlyPoints+" ]^000000",0x9ae2d7;
  100. if ( @hourly_point_stopped ) {
  101. dispbottom "The hourly points event stopped because you were previously vending, chatting, or idle!";
  102. }
  103. else {
  104. dispbottom "[ Hourly Rewards ] Your next reward will be achieved in " +
  105. ((.@min)? "[ " + .@min + " ] minute" + ((.@min > 1)?"s":""):"") +
  106. ((.@min && .@sec)? " and ":"") +
  107. ((.@sec)? "[ " + .@sec + " ] second" + ((.@sec > 1)?"s":""):"") +
  108. "!",0x9ae2d7;
  109. }
  110. end;
  111. }
Advertisement
Add Comment
Please, Sign In to add comment