Cool plugin!
A couple of tips. First, the info module is pointless, as you don't import it. But also, if you did try to import it, there would be an error. We recently updated PluginInfo for a number of reasons. The best way to handle the plugin's info is to now have 2 files:
- info.py
:Syntax: Select all
# ../<plugin_name>/info.py
"""Provides/stores information about the plugin."""
# =============================================================================
# >> IMPORTS
# =============================================================================
# Source.Python
from plugins.manager import plugin_manager
# =============================================================================
# >> PLUGIN INFO
# =============================================================================
info = plugin_manager.get_plugin_info(__name__)
- info.ini
:Syntax: Select all
verbose_name = "Autobhop"
author = "joje3003 and velocity"
version = "1.0.0"
url = "<some url>"
This will automatically create the PublicConVar instance, unless you specify
public_convar = False in the ini file.
Also, I'm a little unsure why you bother casting the userid to a string. It should work fine as an integer, which it will be in both functions.
Syntax: Select all
# You are needlessly looping through every player in the following
if not player in PlayerIter('alive'):
return
# All you really need to do is
if player.dead:
return
If "jump" is always the only sub-key in the dictionary, what is the point of even using it? You can simply use:
Syntax: Select all
settings[userid] = True
settings[userid] = False
Notice above that I also switched using integers for booleans, since you are really only wanting true/false values.
Lastly, you are getting the userid and index of the player before you check whether or not the command was even used. You can either move those after the command check or instead of using player_say, use a SayCommand or TypedSayCommand, which will do that filtering for you.