Getting a strange IndexError
Posted: Thu Jan 29, 2015 8:13 pm
Hi,
whenever I do this (running CS: S):
I get that exception:Why is that so? Because, I definitely have menus[0]:
The funny thing is, I actually open the weapons menu, and I can choose the weapons and receive them. The code itself works, it seems like the exception is coming out of nowhere. Sometimes it throws the exception and sometimes it doesn't... Can you help me? :)
whenever I do this (running CS: S):
Syntax: Select all
@SayCommand(config["saycommand_weapons"])
def saycommand_weapons(playerinfo, command, teamonly):
"""
Gets called whenever someone types the saycommand for the weapons menu in the chat.
"""
# send the main menu
menus[0].send(index_from_playerinfo(playerinfo))
# block the message from being shown
return CommandReturn.BLOCK
I get that exception:
Code: Select all
[SP] Caught an Exception:
Traceback (most recent call last):
File '../addons/source-python/packages/source-python/commands/manager.py', line 148, in __call__
return_value = callback(*args)
File '../addons/source-python/packages/source-python/commands/auth.py', line 63, in __call__
return self.callback(*args)
File '../addons/source-python/plugins/simpledm/simpledm.py', line 307, in saycommand_weapons
menus[0].send(index_from_playerinfo(playerinfo))
IndexError: list index out of range
The funny thing is, I actually open the weapons menu, and I can choose the weapons and receive them. The code itself works, it seems like the exception is coming out of nowhere. Sometimes it throws the exception and sometimes it doesn't... Can you help me? :)