viewing paste AFK Script v1.2b | 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
//===== eAthena Script ============================================
//= AFK script
//===== By: =======================================================
//= ~AnnieRuru~
//===== Current Version: ==========================================
//= 1.2b
//===== Compatible With: ==========================================
//= eAthena 14828 Trunk TXT/SQL
//===== Description: ==============================================
//= warp AFK players in BG maps to SavePoint, leave current team
//=================================================================
 
-   script  afk_script  -1,{
// Config
OnInit:
    set .sleeploop, 1000; // every 1 second
    set .afk, 180; // loop 180 times of 1 second = 3 minutes to execute
    setarray .@map$,
        "bat_a01", "bat_a02", "bat_b01", "bat_b02", "bat_c01", "bat_c02", "bat_c03"; // battlegrounds
    
    set .@size, getarraysize(.@map$);
    set .map$, ":";
    for ( set .@i, 0; .@i < .@size; set .@i, .@i +1 ) {
        setmapflag .@map$[.@i], mf_loadevent;
        set .map$, .map$ + .@map$[.@i] + ":";
    }
    end;
 
// what to do when triggered
L_trigger:
    // dispbottom "you have afk for "+ .@afk * .sleeploop / 1000 +" seconds";
    if ( getcharid(4) )
        bg_leave;
    warp "SavePoint", 0,0;
    end;
 
OnPCLoadMapEvent:
    if ( @afk_startcount ) end;
    set @afk_startcount, 1;
    while(1) {
        getmapxy .@map$, .@x, .@y, 0;
        if ( compare( .map$, ":"+ .@map$ +":" ) ) {
            if ( .@map$ == .@afkmap$ && .@x == .@afkx && .@y == .@afky ) {
                set .@afk, .@afk +1 ;
                // dispbottom "[Debug] afk for "+ .@afk * .sleeploop / 1000 +" second(s)";
                if ( .@afk == .afk ) {
                    set @afk_startcount, 0;
                    goto L_trigger;
                }
            }
            else 
                set .@afk, 0;
            set .@afkmap$, .@map$; set .@afkx, .@x; set .@afky, .@y;
            sleep2 .sleeploop;
        }
        else
            break;
    }
    set @afk_startcount, 0;
    end;
}
Viewed 1070 times, submitted by Guest.