[Any] Idle Manager

Custom Packages that plugins can require for common usages.
decompile
Senior Member
Posts: 349
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

[Any] Idle Manager

Postby decompile » Mon Apr 17, 2017 11:15 pm

[Any] Idle Manager

Description
Idle Manager API which handles Idle players for Source Python.

Installation
Download and unpack the latest release of Idle Manager to your server folder.

Configuration
There's a configuration file cfg/source-python/idle_manager.cfg that holds the ConVar for the Idle Time.

Usage

@OnClientIdle

Called when a Client is marked as Idle.

Syntax: Select all

from idle_manager import OnClientIdle

@OnClientIdle
def on_client_idle(index):
print("Index '{:d}' is now marked as Idle.".format(index))


@OnClientBack

Called when a Client is back from being Idle.

Syntax: Select all

from idle_manager import OnClientBack

@OnClientBack
def on_client_back(index):
print("Index '{:d}' is no longer marked as Idle.".format(index))


is_client_idle(index)

Returns the Client Idle Status for the given Client Index.

Syntax: Select all

from idle_manager import is_client_idle

from events import Event
from players.helpers import index_from_userid

@Event('player_say')
def player_say(game_event):
index = index_from_userid(game_event.get_int('userid'))
print("Idle Status for Index '{:d}': {}".format(index, is_client_idle(index)))


Github
https://github.com/Frag1337/Idle-Manager/releases

Changelog

6th May 2017

Code: Select all

- Naming Conventions according to PEP8
- Update README.md
Last edited by decompile on Sat May 06, 2017 6:25 pm, edited 3 times in total.
decompile
Senior Member
Posts: 349
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Re: [Any] Idle Manager

Postby decompile » Fri May 05, 2017 11:50 pm

- Idle Manager is now a custom package.
- Added Description & Snippets
- Added Listeners
Mahi
Senior Member
Posts: 213
Joined: Wed Aug 29, 2012 8:39 pm
Location: Finland

Re: [Any] Idle Manager

Postby Mahi » Sat May 06, 2017 8:54 am

Looks really nice, good job!

One thing that catches my eye is the naming conventions. Function names should be snake_case instead of CamelCase, according to the PEP8 at least. So you should probably make these changes:

  • ResetIdleTimer => reset_idle_timer
  • SetIdle => set_idle
  • IsClientIdle => is_client_idle
Also, all of the above functions operate on client's index, yet only one says "client" in it. I'd suggest either changing all of them to use this, i.e. set_client_idle and reset_client_idle_timer, or rename the is_client_idle to is_idle. Consistency is always good.

Just my opinion though :)
Last edited by Mahi on Sat May 06, 2017 4:27 pm, edited 2 times in total.
User avatar
satoon101
Project Leader
Posts: 2539
Joined: Sat Jul 07, 2012 1:59 am

Re: [Any] Idle Manager

Postby satoon101 » Sat May 06, 2017 1:33 pm

I agree with everything that Mahi stated. Very nice! At the very least, to avoid confusion, you should not use the same naming convention for functions/methods as you do classes. I definitely prefer the way Mahi has stated, where classes are CamelCase (as you already have) while functions/methods are lower_case_with_underscores. If you do that, I will add this as a requirement for GunGame-SP, and utilize it to know when players are AFK.

Also, since this is a custom package now (yay!), I will move it to the appropriate forum.
Image
decompile
Senior Member
Posts: 349
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Re: [Any] Idle Manager

Postby decompile » Sat May 06, 2017 6:21 pm

Thank you guys for the feedback!

Still trying to get used to that Coding Conventions, but I fixed all the mistakes in the latest release.

Code: Select all

- Naming Conventions according to PEP8
- Update README.md


Also, Im having an idea to Timestamps, which can be used to return the Idle Time for a client.
decompile
Senior Member
Posts: 349
Joined: Sat Oct 10, 2015 10:37 am
Location: Germany
Contact:

Re: [Any] Idle Manager

Postby decompile » Mon May 22, 2017 12:33 pm

Thanks to @iPlayer.

Code: Select all

- Added Idle Timestamp's
- Added get_client_idle_time(index, timestamp=False)
- Changed dict() to PlayerDictionary()
- Updated README.md

Return to “Custom Packages”

Who is online

Users browsing this forum: No registered users and 0 guests