You need couple of scripts that do communicate with each other.
1. Script that lauches 2. script and calculates time. When (if) time rans out, reacts -> player is probably AFK.
2. Script that creates and sends a macrocheck (whether is it gump or something else, is of course up to you). After player has answered sends information to 1. script.
Basic scripts, don't work as a whole, but should show the idea.
1., timeout.src
Code:
program SendMacroCheck( who )
const PATH_TO_CHECK := "check";
const ANSWERING_TIME := 120;
var proc := Start_Script(PATH_TO_CHECK, { who, GetPid() } );
var result := Wait_For_Event(ANSWERING_TIME);
if (result == 0)
// Timeout!
SysLog(who.name + " is AFK!");
// Kill's the gump off the player's screen.
proc.Kill();
else
// Answered in time, no reaction.
return 1;
endif
endprogram
2., check.src
Code:
// Using yesNo gump (gumps-package) in this test
program check( params )
var who := params[1];
var pid := params[2];
var proc := GetProcess(pid);
// Return value does not matter; only the fact that player clicked.
YesNo(who, "Are you AFK?");
// Let timer script know that player clicked.
proc.SendEvent(1);
endprogram
Now, this is in no way a complete solution! There's no error checking, nor do the scripts even compile; but that should give you some ideas.