//===== 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;
}