viewing paste Unknown #21018 | Athena

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