Renegade Public Forums
C&C: Renegade --> Dying since 2003™, resurrected in 2024!
Home » Renegade Discussions » Mod Release Forum » [SSGM+BRenBot Plugin] AFK Detector v2.0
[SSGM+BRenBot Plugin] AFK Detector v2.0 [message #450218] Wed, 27 July 2011 17:27 Go to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
This plugin is an AFK detector for SSGM, with a plugin for BRenBot (although other bots using renlog can be made to support it). It checks whether someone is AFK via both their score and their position. Inside afk_detection.ini you can configure the waiting time (interval) before a new AFK check and the amount of score that needs to be gained in between check intervals for a player not to be marked as AFK (this is the 'score_threshold' setting).

The plugin doesn't do anything when there's only one player in-game. There's an option to disable checking score if Power Plant and/or Refinery is down. And an option to PM a player if he's marked AFK (but it won't do any kicking).

The plugin marks a player AFK during a check when first:

-He hasn't gained points (with the threshold logic taken in account and the option to disable checking points when PP/Ref is destroyed).
-When his position hasn't changed within a small renefeet threshold.
-If his facing hasn't changed.

And if he doesn't do any of the following:
-When he hasn't fired any shots.
-Doesn't speak.
-Doesn't enter or exit a vehicle.
-Doesn't purchase anything.

The plugin outputs the following at most to renlog (the BRenBot plugin relays this to the admin channel), this is what's shown when EVERYTHING hasn't changed:

[AFK] PLAYER's score(X, count: X) position(count: X, near BUILDING) shots fired with infantry(count: X) facing(count X) hasn't changed.

Another example:

[AFK] PLAYER's position(count: X, near Power Plant) score (X, count: X) facing(count: X) shots fired(count: X) hasn't changed.

Where 'PLAYER' is a player name, 'count' is the count of consecutive times that score or position haven't changed (this means they get reset if position/score change appropriately). 'BUILDING' is the name or acronym of the building they're closest too, if it's the same team as the player. And where 'X' is a number.

Installation:

1. Edit afk_detector.ini to your liking.
2. Place afk_detector.ini and afk_detector.dll inside your FDS folder (where SSGM is located in).
3. Edit SSGM.ini and add an entry for 'afk_detector' under the [Plugins] section of that file.

Optionally, to add BRenBot support:

4. Place afk_detector.xml and afk_detector.pm inside the BRenBot\plugins folder.

Credits:

Reborn (the guy) - The 'closest building to player' logic is taken from his commander plugin.
(gen)Blacky - Based the BRenBot plugin on something similar he made.
zunnie - Helped me find a scripts.dll function I needed.


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases

[Updated on: Thu, 25 August 2011 18:18]

Report message to a moderator

Re: [SSGM+BRenBot Plugin] AFK Detector [message #450222 is a reply to message #450218] Wed, 27 July 2011 22:32 Go to previous messageGo to next message
NACHO-ARG is currently offline  NACHO-ARG
Messages: 397
Registered: October 2010
Karma: 0
Commander
sounds very interesting, i am sure jelly ppl can do some use of it.
Re: [SSGM+BRenBot Plugin] AFK Detector [message #450233 is a reply to message #450222] Thu, 28 July 2011 11:19 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3811
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
Check facing as well as position, also keep in mind if you alt tab you can keep moving without actually being in game. So maybe you should use a combination of seeing if they are moving and turning (comparisons between old facing and new, if they matched it'd return true); if position and facing remain constant with each other those remain constant (true && true || false && false || false && true || true && false) for an extended period of time they are afk. (By combining facing and moving you can figure out if they alt tabbed out pushing 'W' and 'A' or something while in a vehicle).

Also score and ammo count are probably bad ideas to decide AFK on beings they could alt tab while repairing a PT or something... But then, they could be in game repairing a PT and get counted for AFK...

Damn it, shame renegade keeps sending the key press held message when you alt tab, otherwise AFK would be as simple as checking for key presses.


Re: [SSGM+BRenBot Plugin] AFK Detector [message #450235 is a reply to message #450218] Thu, 28 July 2011 12:44 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
Thanks for the suggestion, I didn't think about using facing. I appreciate the feedback, three issues with them though:

1. Ssometimes when you alt+tab out, you keep rotating.

2. The size of the AFK detection message sent to IRC/written to Renlog, when score and positioned haven't changed and the guy is standing near a building, the message already is quite big imo.

3. I'm not sure if it's effective at all, when walking while alt+tabbed isn't an issue, when someone is standing still for 5-10 minutes it's likely he's AFK (especially if you get another AFK message for the guy during the next check). It's reasonable that someone is AFK repairing if their position doesn't change but their score does and they're located near the same building every check.

I'm not using ammo count, however the engine keeps a count of shots fired, I could keep track of that info (and the facing) too, I'll have to refactor the AFK detection messages output to be more concise, any suggestions? I'm also thinking about checking if a player's credits have decreased if their score hasn't. Anything else that would be wise to check?

For the AFK detection messages, what about (with all of these being optional):

[AFK] PLAYER's score(X, count: X) position(count: X, near BUILDING) shots fired(count: X) facing(count X) credits decreased(count X) changed.


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases

[Updated on: Thu, 28 July 2011 13:00]

Report message to a moderator

Re: [SSGM+BRenBot Plugin] AFK Detector [message #450271 is a reply to message #450218] Fri, 29 July 2011 04:17 Go to previous messageGo to next message
danpaul88 is currently offline  danpaul88
Messages: 5795
Registered: June 2004
Location: England
Karma: 0
General (5 Stars)
I thought SSGM already had an AFK kick mechanism?

http://steamsignature.com/card/1/76561197975867233.png
Re: [SSGM+BRenBot Plugin] AFK Detector [message #450281 is a reply to message #450218] Fri, 29 July 2011 08:09 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
This one doesn't kick, has support for BRenBot and uses different methods.

Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases
Re: [SSGM+BRenBot Plugin] AFK Detector [message #450296 is a reply to message #450281] Fri, 29 July 2011 11:32 Go to previous messageGo to next message
Gen_Blacky is currently offline  Gen_Blacky
Messages: 3250
Registered: September 2006
Karma: 1
General (3 Stars)


Points are a bad way to detect if someone afk with 100 point threshold.

Games where each side only has a power plant or a ref. You could spend 15 mins fighting with free chars and not get 100 points.

If the player score hasn't changed at all after so long check afk and then check again.

Its rather hard to detect afk people because when people alt tab they could being pressing a button , running , spinning.

I like your ideas.


http://s18.postimage.org/jc6qbn4k9/bricks3.png

[Updated on: Fri, 29 July 2011 11:38]

Report message to a moderator

Re: [SSGM+BRenBot Plugin] AFK Detector [message #450297 is a reply to message #450218] Fri, 29 July 2011 12:11 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
Yeah that's an issue with the threshold logic. The script gets destroyed and created again after you die so the timer for it should also get reset when that happens, though.

I could play around with the logic so it doesn't give score messages or disables the threshold if PP/Ref are destroyed.


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases

[Updated on: Fri, 29 July 2011 12:13]

Report message to a moderator

Re: [SSGM+BRenBot Plugin] AFK Detector [message #450299 is a reply to message #450297] Fri, 29 July 2011 12:25 Go to previous messageGo to next message
HaTe is currently offline  HaTe
Messages: 923
Registered: August 2007
Karma: 0
Colonel
In fnfalls they had something very similar, it was the points one, and if you didn't get any points in 10 mins then the server sent u a pm saying that you'll be kicked in 1 minute unless you say !here . It worked fairly well too

http://i162.photobucket.com/albums/t263/psuHaTe32_2007/HaTe3.jpg
‘All that is necessary for the triumph of evil is that good men do nothing’ - Edmund Burke
Re: [SSGM+BRenBot Plugin] AFK Detector [message #451198 is a reply to message #450235] Wed, 10 August 2011 13:48 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3811
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
iRANian wrote on Thu, 28 July 2011 13:44

Thanks for the suggestion, I didn't think about using facing. I appreciate the feedback, three issues with them though:

1. Ssometimes when you alt+tab out, you keep rotating.


Thats why I made a suggestion to make comparisions between facing and moving seperately:
IsTurning = false;
IsMoving = false;
if (abs(OldFacing - NewFacing) > 0.1)
IsTurning = True;
if (distancecheck)
IsMoving = true;

if (IsTurning == OldIsTurning && IsMoving == OldIsMoving)
increase the timer until you star marking them as afk.
else
reset the timer.

Because when you alt tab you keep doing what you were doing when you alt tabbed.

If you were rotating and turning, you keep doing that.
If you were going straight you keep doing that.
If you were just spinning in circles you keep doing that.
And if you were standing still you keep doing that.

That pseudo code checks out for all of that pretty much.

By checking facing you make sure snipers don't get counted as afk... or further reduce the chance anyways.

As for the other possibilities, can't help you out, ammo count obviously doesn't work on repair guns, otherwise you could further combine that in like I did with movement and rotation.


Re: [SSGM+BRenBot Plugin] AFK Detector [message #451202 is a reply to message #450218] Wed, 10 August 2011 14:35 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
Getting the amount of shots fired does work for Repair Guns, it's something the engine itself keeps (it's the 'ShotsFired' int member of cPlayer), and I checked if it counts firing the Repair Guns with that, and it does.

I'm gonna release a new version of this script once I'm finished with my server-side map fixes pack.


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases

[Updated on: Wed, 10 August 2011 14:37]

Report message to a moderator

Re: [SSGM+BRenBot Plugin] AFK Detector [message #451226 is a reply to message #451202] Wed, 10 August 2011 21:29 Go to previous messageGo to next message
Jerad2142 is currently offline  Jerad2142
Messages: 3811
Registered: July 2006
Location: USA
Karma: 6
General (3 Stars)
Well if it works in multiplayer and on weapons that don't require (or a bullet cost, but I think rep gun has a bullet cost of one so that should be good) a bullet count change then great, but regardless that still doesn't offer much protection against people repairing the hand of nod on Field when it's getting MLRS'd or whatever.

Reguardless, good luck.


Re: [SSGM+BRenBot Plugin] AFK Detector [message #452412 is a reply to message #450218] Wed, 24 August 2011 11:36 Go to previous messageGo to next message
liquidv2 is currently offline  liquidv2
Messages: 3407
Registered: February 2007
Karma: 0
General (3 Stars)
i think 5 minutes would make sense
after that it should pm them if they haven't done one of the following:

- made a purchase or refilled at a terminal
- entered or exited a vehicle
- gained any points (at least 1)
- spoken in F2 or F3 or done a radio command

though sometimes sbh lurk around in enemy bases for like 20 minutes at a time with nothing happening so maybe it should detect whether or not a player has moved on their own (if that's possible)
because they could be afk in someone's vehicle and it wouldn't know the difference, or similarly they could also get bumped around by teammates

i just don't know how it works or if any of those things are possible; pardon my lack of knowing anything about coding or ren's inner workings


liquidv2
Re: [SSGM+BRenBot Plugin] AFK Detector [message #452423 is a reply to message #450218] Wed, 24 August 2011 12:13 Go to previous messageGo to next message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
Alright, I'm thinking about adding the following:

-Don't do anything when there's only one player in-game.
-Add an option to disable checking score if Power Plant and/or Refinery is down.
-Add an option to PM a player if he's marked AFK (but don't do any kicking)

Have the code mark a player AFK during a check when first:

-He hasn't gained points (with the threshold logic taken in account and the option to disable checking points when PP/Ref is destroyed).
-When his position hasn't changed within a small renefeet threshold.
-If his facing hasn't changed.

And if he doesn't do any of the following:
-When he hasn't fired any shots.
-Doesn't speak.
-Doesn't enter or exit a vehicle.
-Doesn't purchase anything.

Then write to Renlog and relay with BRenbot facing/score/shotsfired/position for all of those that haven't changed. Looking like this:

[AFK] PLAYER's score(X, count: X) position(count: X, near BUILDING) shots fired with infantry(count: X) facing(count X) hasn't changed.


Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases

[Updated on: Thu, 25 August 2011 03:59]

Report message to a moderator

Re: [SSGM+BRenBot Plugin] AFK Detector [message #452480 is a reply to message #450218] Thu, 25 August 2011 18:16 Go to previous message
iRANian is currently offline  iRANian
Messages: 4308
Registered: April 2011
Karma: 0
General (4 Stars)
I've released version 2.0 with the changes from the previous post in it, see the opening post of this thread for the download.

Long time and well respected Renegade community member, programmer, modder and tester.

Scripts 4.0 private beta tester since May 2011.

My Renegade server plugins releases
Previous Topic: Search Hud Yet another D6 Hud
Next Topic: Helios' Scripts.dll 2.9.2/3.4.4 installer
Goto Forum:
  


Current Time: Thu Nov 28 05:45:15 MST 2024

Total time taken to generate the page: 0.00920 seconds