Skip to content

Commit 2c64fb7

Browse files
committed
Added documentation to players.helpers functions.
1 parent 081b3c3 commit 2c64fb7

1 file changed

Lines changed: 37 additions & 6 deletions

File tree

  • addons/source-python/packages/source-python/players

addons/source-python/packages/source-python/players/helpers.py

Lines changed: 37 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,11 @@
8989
# >> OTHER HELPER FUNCTIONS
9090
# =============================================================================
9191
def index_from_steamid(steamid):
92-
"""Return an index from the given SteamID."""
92+
"""Return an index from the given SteamID.
93+
94+
:param str steamid: The SteamID to get the index of.
95+
:rtype: int
96+
"""
9397
# Loop through all players on the server
9498
for edict in PlayerGenerator():
9599

@@ -107,7 +111,11 @@ def index_from_steamid(steamid):
107111

108112

109113
def index_from_uniqueid(uniqueid):
110-
"""Return an index from the given UniqueID."""
114+
"""Return an index from the given UniqueID.
115+
116+
:param str uniqueid: The UniqueID to get the index of.
117+
:rtype: int
118+
"""
111119
# Loop through all players on the server
112120
for edict in PlayerGenerator():
113121

@@ -125,7 +133,11 @@ def index_from_uniqueid(uniqueid):
125133

126134

127135
def index_from_name(name):
128-
"""Return an index from the given player name."""
136+
"""Return an index from the given player name.
137+
138+
:param str name: The player name to get the index of.
139+
:rtype: int
140+
"""
129141
# Loop through all players on the server
130142
for edict in PlayerGenerator():
131143

@@ -143,7 +155,13 @@ def index_from_name(name):
143155

144156

145157
def uniqueid_from_playerinfo(playerinfo):
146-
"""Return the UniqueID for the given player."""
158+
"""Return the UniqueID for the given player.
159+
160+
:param PlayerInfo playerinfo: The PlayerInfo
161+
instance to get the UniqueID from.
162+
:return: The UniqueID of the player. E.g. 'BOT_STAN' or 'STEAM_0:0:12345'
163+
:rtype: str
164+
"""
147165
# Is the player a Bot?
148166
if playerinfo.is_fake_client():
149167

@@ -167,12 +185,25 @@ def uniqueid_from_playerinfo(playerinfo):
167185

168186

169187
def uniqueid_from_index(index):
170-
"""Return the UniqueID for the given player index."""
188+
"""Return the UniqueID for the given player index.
189+
190+
:param int index: The player index to get the UniqueID from.
191+
:return: The UniqueID of the player. E.g. 'BOT_STAN' or 'STEAM_0:0:12345'
192+
:rtype: str
193+
"""
171194
return uniqueid_from_playerinfo(playerinfo_from_index(index))
172195

173196

174197
def address_from_playerinfo(playerinfo):
175-
"""Return the IP address for the given player."""
198+
"""Return the IP address for the given player.
199+
200+
If the player is a bot, an empty string will be returned.
201+
202+
:param PlayerInfo playerinfo: The PlayerInfo
203+
instance to get the UniqueID from.
204+
:return: The IP address. E.g. '127.0.0.1:27015'
205+
:rtype: str
206+
"""
176207
# Is the player a bot?
177208
if playerinfo.is_fake_client():
178209

0 commit comments

Comments
 (0)