viewing paste WOE Waitingroom Timer v1.02 | 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
//https://rathena.org/board/topic/110562-woe-countdown-timer/
//Skormie's WOE Waitingroom Timer v1.02
//Should natively work with Euphy's WOE Controller.
prontera,150,150,5  script  Woe Time    100,{
end;
OnInit:
    function s;
    function woe_update;
    
    .@Euphy_Len = getarraysize( $WOE_CONTROL );
    
    if( .@Euphy_Len ) {
        for( .@i = 0; .@i < .@Euphy_Len; .@i += 4 ) {
            .woe_day[ getarraysize( .woe_day ) ] = $WOE_CONTROL[.@i];
            .woe_hour[ getarraysize( .woe_hour ) ] = $WOE_CONTROL[.@i+1];
        }
    } else {
        setarray .woe_day, 5, 4; //Day of the week WOE Starts on. (0 for Sunday, 6 is Saturday)
        setarray .woe_hour, 16, 20; //rAthena works on a 24 hour clock.
    }
    
    woe_update();
 
    while ( 1 ) {
        .@woe_tick = .woe_time[.current] - gettimetick(2);
        .@day  = .@woe_tick / 86400;
        .@hour = .@woe_tick % 86400 / 3600;
        .@min  = .@woe_tick % 3600 / 60;
        .@sec  = .@woe_tick % 60;
        .@mes$ = ( .@day  ? .@day  +" day"+    s( .@day )    : "" ) +
                 ( .@hour ? .@hour +" hour"+   s( .@hour )   : "" ) +
                 ( .@min  ? .@min  +" minute"+ s( .@min )    : "" ) +
                 ( .@sec  ? .@sec  +" second"+ s( .@sec, 1 ) : "" );
        delwaitingroom strnpcinfo(0);
        waitingroom agitcheck() ? "WOE is Active!" : .@mes$, 0;
        sleep 1000;
    }
    end;
    
    OnAgitEnd:
        woe_update();
        end;
    
    function s {
        return ( getarg(0) > 1 ? "s" : "" ) + ( getarg(1,0) ? "" : " " );
    }
    function woe_update {
        .@woe_len = getarraysize( .woe_day );
        for( .@a = 0; .@a < .@woe_len; .@a++ ) {
            .@woe_day[.@a] = ( .woe_day[.@a] - gettime(4) + 7 ) % 7 * 86400;
            .@woe_hour[.@a] = ( .woe_hour[.@a] * 3600 ) - gettimetick(1);
            .woe_time[.@a] = gettimetick(2) + .@woe_day[.@a] + .@woe_hour[.@a];
            if(gettimetick(2) > .woe_time[.@a])
                .woe_time[.@a] = .woe_time[.@a] + 7 * 86400;
            if( .woe_time[.@a] <= .woe_time[.current] )
                .current = .@a;
        }
    }
}
Viewed 2035 times, submitted by Skorm.