Jump to content
  • 0

kick idle players


Question

Posted

Hello, I'm trying to kick idle players but it's not working.

Well, when player logins it creates a timer (of 5 seconds lol, that's for testing) when timer is over should compare the player position and if the player didn't move it kicks.

I'm having trouble attaching the RID to OnKick event

here's the script

 

OnPCLoginEvent:
query_sql "SELECT `last_map`,`last_x`,`last_y` FROM `char` WHERE `char_id` = "+getcharid(0), @map$, @x, @y;
addtimer ( 5000 ),strnpcinfo(0)+"::OnKick";
end;

	


OnKick:
query_sql "SELECT `last_map`,`last_x`,`last_y` FROM `char` WHERE `char_id` = "+getcharid(0), @map2$, @x2, @y2;
	if (@map$ == @map2$
	&&  @x == @x2
	&&  @y == @y2) 
	{
		atcommand "@kick "+strcharinfo(0);
		deltimer strnpcinfo(0)+"::OnKick";	
		end;
	}

}
addtimer ( 5000 ),strnpcinfo(0)+"::OnKick";
end;

 

5 answers to this question

Recommended Posts

Posted


- scrript SayNoToAFK -1,{

OnPCLoginEvent:

sleep2 5000; // Check for every 5 seconds

if (checkidle(strchrinfo(0)) >= 5) // Idle for 5 seconds

atcommand "@kick "+strcharinfo(0);

goto OnPCLoginEvent;

}

  • Upvote 1
Posted (edited)
-	script	AFKER	-1,{
OnPCLoginEvent:
	getmapxy(@map$,@x,@y,0);
	setnpctimer 0; attachnpctimer(strcharinfo(0)); startnpctimer;
	end;


OnTimer5000:
	getmapxy(@map2$,@x2,@y2,0);
		if (@map$ == @map2$
		&&  @x == @x2
		&&  @y == @y2) 
		{
			atcommand "@kick "+strcharinfo(0);
			stopnpctimer;
			end;
		}

	}
	stopnpctimer;
	end;
}

 

I wouldn't use the SQL query because it updates really slow. Attaching an npc timer works the same as addtimer.

 

If you want it to loop like that for the duration of the online player change the last stopnpctimer; to setnpctimer 0;

 

Edit: I don't even have a checkidle command... need to update my trunk.

Edited by Skorm
Posted

Well attaching a timer is a hard approach for this since checkidle() command is already existing. So Joseph approach is more suitable in this thread.

It's easy to assume, perhaps the client was looking for something similar to the original, or maybe, he's running a lower version of rAthena in which case the command wouldn't exist.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

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