Jump to content

Idle command


Capuche

Recommended Posts


  • Group:  Developer
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  2407
  • Reputation:   613
  • Joined:  07/05/12
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

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?

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  17
  • Topics Per Day:  0.00
  • Content Count:  754
  • Reputation:   186
  • Joined:  05/22/12
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  6
  • Topics Per Day:  0.00
  • Content Count:  134
  • Reputation:   35
  • Joined:  02/27/12
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  17
  • Topics Per Day:  0.00
  • Content Count:  754
  • Reputation:   186
  • Joined:  05/22/12
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  75
  • Topics Per Day:  0.02
  • Content Count:  2223
  • Reputation:   593
  • Joined:  10/26/11
  • Last Seen:  

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
Link to comment
Share on other sites

  • 3 weeks later...

  • Group:  Members
  • Topic Count:  18
  • Topics Per Day:  0.00
  • Content Count:  2044
  • Reputation:   682
  • Joined:  10/09/12
  • Last Seen:  

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
Link to comment
Share on other sites


  • Group:  Development Manager
  • Topic Count:  56
  • Topics Per Day:  0.01
  • Content Count:  732
  • Reputation:   525
  • Joined:  12/13/11
  • Last Seen:  

I'll check this out.

  • Upvote 2
Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  72
  • Topics Per Day:  0.02
  • Content Count:  2997
  • Reputation:   1130
  • Joined:  05/27/12
  • Last Seen:  

Implemented by Aleos in r17126 and documented in r17127.

  • Upvote 1
Link to comment
Share on other sites

×
×
  • Create New...