How to read the .ini files in ./_libs/_data ?

Please post any questions about developing your plugin here. Please use the search function before posting!
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

How to read the .ini files in ./_libs/_data ?

Postby BackRaw » Thu Jun 13, 2013 2:34 am

Hey guys,

I'm trying SP for CSS with a little script, but I need to know how I can read the .ini files in the ./_libs/_data directory.
I wanna use the values for "t" and "ct" in ./_libs/_data/players/teams/cstrike.ini. How would I go about doing that?

Thank you :)
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Thu Jun 13, 2013 4:30 am

The only module, I believe, that uses that file, is the filters.players module. This is how it reads the data:[python]_game_teams = ConfigObj(
DATA_PATH.joinpath('players', 'teams', GAME_NAME + '.ini'), unrepr=True)[/python]Note that you will need to import ConfigObj, DATA_PATH, and GAME_NAME if you use this method.

Satoon
User avatar
BackRaw
Senior Member
Posts: 537
Joined: Sun Jul 15, 2012 1:46 am
Location: Germany
Contact:

Postby BackRaw » Fri Jun 14, 2013 4:34 pm

satoon101 wrote:The only module, I believe, that uses that file, is the filters.players module. This is how it reads the data:[python]_game_teams = ConfigObj(
DATA_PATH.joinpath('players', 'teams', GAME_NAME + '.ini'), unrepr=True)[/python]Note that you will need to import ConfigObj, DATA_PATH, and GAME_NAME if you use this method.

Satoon

Yeah, I already managed to do that. I thought there'd be some type of extra function/method for this :)
User avatar
satoon101
Project Leader
Posts: 2697
Joined: Sat Jul 07, 2012 1:59 am

Postby satoon101 » Sat Jun 15, 2013 12:21 am

This will possibly get moved to another module at some point, but you can always use the PlayerTeams dictionary from filters.players to get player teams for the current game:

Syntax: Select all

from filters.players import PlayerTeams

for team in PlayerTeams:
print(team + ': %s' % PlayerTeams[team].team)

Satoon

Return to “Plugin Development Support”

Who is online

Users browsing this forum: No registered users and 23 guests