Jump to content
  • 0

kick idle players


Freyr

Question


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  38
  • Reputation:   7
  • Joined:  01/11/13
  • Last Seen:  

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;

 

Link to comment
Share on other sites

5 answers to this question

Recommended Posts


  • Group:  Members
  • Topic Count:  5
  • Topics Per Day:  0.00
  • Content Count:  341
  • Reputation:   43
  • Joined:  01/10/12
  • Last Seen:  


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


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

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


  • Group:  Members
  • Topic Count:  50
  • Topics Per Day:  0.01
  • Content Count:  1702
  • Reputation:   238
  • Joined:  09/05/12
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Forum Moderator
  • Topic Count:  33
  • Topics Per Day:  0.01
  • Content Count:  1268
  • Reputation:   382
  • Joined:  02/03/12
  • Last Seen:  

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.

Link to comment
Share on other sites


  • Group:  Members
  • Topic Count:  10
  • Topics Per Day:  0.00
  • Content Count:  38
  • Reputation:   7
  • Joined:  01/11/13
  • Last Seen:  

thanks everyone! Joseph script works great :D

Thank you guys :)

Link to comment
Share on other sites

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.

×
×
  • Create New...