Advertisement
Winterfox

Untitled

Jul 6th, 2015
212
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.34 KB | None | 0 0
  1. //======Name========================================
  2. // Daily Login Rewards
  3. //======Version=====================================
  4. // 1.1
  5. // Author: Sandbox, Winterfox
  6. //======Comments====================================
  7. // Updated outdated Syntax-
  8. // Made slight optimizations.
  9. // Added a delay of 3 hours before the player is
  10. // able to claim his reward and only if he has
  11. // not been idle longer than 5 minutes in this
  12. // time frame.
  13. //==================================================
  14.  
  15. - script DailyLoginRewards -1,{
  16. OnInit:
  17. //Set to your server name
  18. .Serv_Name$ = "Your Server";
  19.  
  20. //Set to desired item prizes
  21. setarray( .D_Prize, 501, 502, 503, 607, 608 );
  22.  
  23. //Amount of prize to be given
  24. setarray( .D_Amt, 1, 2, 3, 2, 1 );
  25. end;
  26. OnPCLoginEvent:
  27. if( gettimetick( 2 ) < #ClaimDelay ) {
  28. dispbottom( "Daily Login Activated. You allready got your daily login reward. " );
  29. end;
  30. }
  31.  
  32. // Show notice about the Daily Login Rewards
  33. dispbottom( "Daily Login Activated. Please be Online for 3 hours without being idle for more than 5 minutes to receive daily login reward. " );
  34.  
  35. // Start a timer after 1 minute to sum up idle time
  36. addtimer( 60000, strnpcinfo(3 ) + "::IdleCheck" );
  37.  
  38. // Start a timer to clam the daily reward after 3 hours
  39. addtimer( 10800000, strnpcinfo(3) + "::StartClaim" );
  40. end;
  41. IdleCheck:
  42. // Add the current idle time to the idle time counter.
  43. #idleTime += checkidle();
  44.  
  45. // Set a new timer to recheck after 1 minute.
  46. addtimer( 60000, strnpcinfo( 3 ) + "::IdleCheck" );
  47. end;
  48. StartClaim:
  49. // If the idle time was more than 5 minutes in the last 3 hours reset to check if the person is the next 3 hours less idle than 5 minutes.
  50. if( #idleTime > 300 ) {
  51. #idleTime = 0;
  52.  
  53. // Start a timer to clam the daily reward after 3 hours
  54. addtimer( 10800000, strnpcinfo(3) + "::StartClaim" );
  55.  
  56. end;
  57. }
  58.  
  59. deltimer( strnpcinfo(3 ) + "::IdleCheck" );
  60.  
  61. // If the streak was broken reset the streak count.
  62. if( gettimetick( 2 ) > #StreakDelay ) #LogStreak = 0;
  63.  
  64. // If the rewards reached their end, reset them.
  65. if( #RewardStreak > getarraysize( .D_Prize ) ) #RewardStreak = 0;
  66.  
  67. if( #RewardStreak == 0 )
  68. dispbottom( "Welcome to " + .Serv_Name$ + "! You've received " + .D_Amt[ #RewardStreak ] + " " + getitemname( .D_Prize[ #RewardStreak ] )+" for logging in! Visit us daily to get more prize! When you've managed to play with us for 5 consecutive days, you will receive bonus prizes!" );
  69.  
  70. if( #RewardStreak > 0 )
  71. dispbottom( "Welcome back to " + .Serv_Name$ + "! You've received " + .D_Amt[ #RewardStreak ] + " " + getitemname( .D_Prize[ #RewardStreak ] ) + " for logging in! Visit us daily to get more prize! When you've managed to play with us for 5 consecutive days, you will receive bonus prizes!" );
  72.  
  73. getitem( .D_Prize[ #RewardStreak ], .D_Amt[ #RewardStreak ]);
  74.  
  75. #RewardStreak += 1;
  76. #LogStreak += 1;
  77. #ClaimDelay = gettimetick( 2 ) + 86400;
  78. #StreakDelay = gettimetick( 2 ) + 172800;
  79.  
  80. if( #LogStreak == 5 ) {
  81. for( .@i = 0; .@i < getarraysize( .D_Prize ); set .@i, .@i++ )
  82. getitem( .D_Prize[.@i], .D_Amt[.@i] );
  83.  
  84. dispbottom( "Congratulations! You've received all the daily rewards for logging in 5 consecutive days!" );
  85. #LogStreak = 0;
  86. }
  87. end;
  88. OnPCLogoutEvent:
  89. // Reset idle time on logout.
  90. #idleTime = 0;
  91. end;
  92. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement