Jump to content

Recommended Posts

Posted

In many script, it's useful to check if a player is idle.

checkchatting() and checkvending() exist, is it possible to add checkidle command ? Just an idea~

  • Upvote 1
Posted

There are currently two conf settings to check if a player is idle. Since they are both off by default, such a command would introduce a forced timer on every character -- not necessarily a bad thing, but it makes the implementation a bigger deal than it may initially seem.

Another question to consider: would the command take a time argument, or would the time be predefined/defined in conf?

Posted

Currently, actions are monitored within the source even if those settings are off. I have something in mind that will utilize that monitoring(which I think is best for this). I will come up with something later if no one takes this.

  • Upvote 1
Posted

Currently, actions are monitored within the source even if those settings are off(w/c i think is . I have something in mind that will utilize that monitoring(which I think is best for this). I will come up with something later if no one takes this.

Yep, everytime an user walks, uses item, skill, atk, the idletime var is changed.(maybe it should update on sit down/stand up too?)

It'd not add a performance issue to just check it with the current implementation.

Posted

yeah, updating idle_time var when the character sits/stands, and chat would be great. :)

Hmmm..

Using this script for testing..

-<TAB>script<TAB>idle_test<TAB>-1,{
OnPCLoginEvent:
@idlecheck = isidle(5);
dispbottom "You are "+(@idlecheck?"idle for "+@idlecheck+" seconds.":"not idle.");
sleep2 5000;
goto OnPCLoginEvent;
end;
}

30mlc37.jpg

moving this line would be more accurate :D

clif.c

@@ -9861,7 +9861,6 @@
	 }

	 pc_delinvincibletimer(sd);
-		sd->idletime = last_tick;
	 unit_attack(&sd->bl, target_id, action_type != 0);
 break;
 case 0x02: // sitdown
@@ -9900,6 +9899,7 @@
	 clif_standing(&sd->bl);
 break;
 }
+	sd->idletime = last_tick;
}

  • Upvote 1
Posted (edited)

http://www.eathena.w...howtopic=273306

me and toasty already did it in the past :blink:

checkidle() ... somehow I feel its not necessary though

OnPCIdleEvent seems more practical

like in battleground script

OnPCIdleEvent:
if ( getcharid(4) )
bg_leave;

like this


perhaps we should do ...

OnPCCheckIdleEvent:

execute every time the player move, use skill, use item ... etc

and push another variable @idle_timer which was the gettimetick(2) of the time when the player last action

usage

<npc>,{
   dispbottom "you have idle for "+( gettimetick(2) - @idle_timer )+" seconds";
   end;

OnPCCheckIdleEvent:
   if ( !getcharid(4) ) end;
   deltimer strnpcinfo(0)+"::OnIdle";
   addtimer 300000, strnpcinfo(0)+"::OnIdle";
   end;

OnIdle:
   dispbottom "you have idle for 5 minutes !";
   bg_leave;
   end;
}


all right, I have fun with this lol

OnPCIdleEvent_17092.diff

prontera,155,186,5    script    kdjhfksjfss    100,{
   dispbottom "you have idle for "+( gettimetick(2) - @last_action_timer )+" seconds";
   end;

OnPCIdleEvent:
   deltimer strnpcinfo(0)+"::OnIdle";
   addtimer 5000, strnpcinfo(0)+"::OnIdle";
   end;
OnIdle:
   dispbottom "Oooii! wake up !";
   end;
}

EDIT:

somehow OnPCIdleEvent is very resource intensive ...

is there other methods that's more resource friendly ?

Edited by AnnieRuru
Posted

In many script, it's useful to check if a player is idle.

I support this suggestion. Since sd->idletime already exists, it would be easy to expose that data to a script command and @command.

Here's an example from a past server. GMs could do #idle PlayerName

to see how long an Alchemist had been AFK with their homunculus:

/*==========================================
* @idle
*------------------------------------------*/
int atcommand_idle(const int fd, struct map_session_data* sd, const char* command, const char* message)
{
memset(atcmd_output, '\0', sizeof(atcmd_output));
nullpo_retr(-1, sd);

if (sd->idletime)
	sprintf(atcmd_output, "%s has been idle for %s. %s %s", sd->status.name, txt_time(DIFF_TICK(last_tick, sd->idletime)), (DIFF_TICK(last_tick, sd->idletime) >= battle_config.idle_no_autoloot)?"IDLE_no_autoloot":"", pc_isidle(sd)?" & IDLE_no_share":"");
else
	sprintf(atcmd_output, "%s has been idle since %s logged in!", sd->status.name, (sd->status.sex)?"he":"she");
clif_displaymessage(fd, atcmd_output);

return 0;
}

yeah, updating sd->idletime when the character sits/stands, and chat would be great. :)

I agree.

  • Upvote 2
  • 3 weeks later...
Posted

BUILDIN_FUNC(checkidle) {
TBL_PC *sd;
if ( script_hasdata(st,2) ) {
	if ( data_isstring( script_getdata(st,2) ) )
		sd = map_nick2sd( script_getstr(st,2) );
	else
		sd = map_id2sd( script_getnum(st,2) );
} else
	sd = script_rid2sd(st);
if ( sd )
	script_pushint( st, DIFF_TICK(last_tick, sd->idletime) );
else
	script_pushint(st,0);
return 0;
}

BUILDIN_DEF(checkidle, "?"),

wonder whats taking this so long ...

  • Upvote 1
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...