我有一个在 python 中运行的插件,用于我的游戏服务器。我在这部分遇到了“处理您的命令时出错”的问题:
def cmd_cost(self, data, client=None, cmd=None):
"""
^3<command> - Tells you the cost of the specified command.
"""
input = self._adminPlugin.parseUserCmd(data)
weapon_cost = self._command_cost_dict.get('weapon',0)
item_cost = self._command_cost_dict.get('item',0)
if not data:
client.message('^7 correct syntax is !cost [command]')
return False
else:
if len([x for x in data if x.isspace()]) > 0:
client.message('^7 correct syntax is !cost [command]')
return False
else:
input_data = data.split(' ',1)
command_name = input_data[0]
if command_name in ['autobuy','buy']:
client.message('^7Weapon cost: ^2$%s ^7Item cost: ^2$%s' % (weapon_cost, item_cost))
if command_name not in self._command_cost_dict and not 'autobuy''buy':
client.message('^7 This command needn\'t money or this command doesn\'t exist!')
return False
command_cost = self._command_cost_dict[command_name]
if command_cost == 0:
return False
client.message('^7 Command %s needs ^2$%s' % (command_name, command_cost))
return True
当他们询问 !cost [...] 而它不在列表中时,就会发生这种情况。它应该说“这个命令不需要钱或这个命令不存在”,但它给出了错误。希望有人可以提供帮助。谢谢。