Hey,
After all the updates I want to ask how to create now properly config files for a plugin.
How to create config files/ convars
Syntax: Select all
from config.manager import ConfigManager
# Create config
with ConfigManager("my_new_plugin", cvar_prefix='mnp_') as config_manager:
config_manager.section("ConVar section 1: Useful cvars")
# Let's define mnp_cvar1
cvar1 = config_manager.cvar(
name="cvar1",
default="default_value",
description="My first console variable",
)
# Access cvar value
print(cvar1.get_string())
Also be sure to check my ControlledCvars package
EDIT: As for descriptions and sections, you can utilize translated strings:
Syntax: Select all
from translations.strings import LangStrings
my_strings = LangStrings("my_new_plugin") # /resource/source-python/translations/my_new_plugin.ini
# ...
config_manager.section(my_strings['config section1 description'])

My plugins: Map Cycle • Killstreaker • DeadChat • Infinite Jumping • TripMines • AdPurge • Bot Damage • PLRBots • Entity AntiSpam
Hail, Companion. [...] Hands to yourself, sneak thief.

There is also a tutorial in our wiki about config files.
http://build.affecta.net/job/Source.Python%20-%20Documentation/lastSuccessfulBuild/artifact/cstrike/addons/source-python/docs/source-python/build/developing/module_tutorials/config.html
http://build.affecta.net/job/Source.Python%20-%20Documentation/lastSuccessfulBuild/artifact/cstrike/addons/source-python/docs/source-python/build/developing/module_tutorials/config.html
Return to “Plugin Development Support”
Who is online
Users browsing this forum: No registered users and 91 guests