コード例 #1
0
ファイル: commands.py プロジェクト: SiF2/Project_PS
def admin_command_giveitem(player, args):
	name = args[1].replace('_', ' ')
	suffix = '.'
	itemId = int(args[2])
	amt = 1
	if len(args) == 4:
		amt = int(args[3])
		suffix = 's.'
	item = Item(itemId, amt)
	for p in World.getWorld().getPlayers():
		if NameUtils.formatName(p.getName()).lower() == name:
			if p.getInventory().add(item):
				player.getActionSender().sendMessage('You have given ' + p.getName() + ' ' + str(amt) + ' ' + item.getDefinition().getName() + suffix)
コード例 #2
0
ファイル: commands.py プロジェクト: SiF2/Project_PS
def admin_command_takeitem(player, args):
	name = args[1].replace('_', ' ')
	suffix = ' '
	itemId = int(args[2])
	amt = 1
	if len(args) == 4:
		amt = int(args[3])
		suffix = 's '
	item = Item(itemId, amt)
	for p in World.getWorld().getPlayers():
		if NameUtils.formatName(p.getName()).lower() == name:
			if p.getEquipment().contains(item.getId()):
				p.getEquipment().remove(item)
				player.getActionSender().sendMessage('You have taken a ' + item.getDefinition().getName() + suffix + 'from ' + p.getName() +"'s equipment.")
			elif p.getBank().contains(item.getId()):
				p.getBank().remove(item)
				player.getActionSender().sendMessage('You have taken ' + str(amt) + ' ' + item.getDefinition().getName() + suffix + 'from ' + p.getName() +"'s bank.")	
			elif p.getInventory().contains(item.getId()):
				p.getInventory().remove(item)
				player.getActionSender().sendMessage('You have taken ' + str(amt) + ' ' + item.getDefinition().getName() + suffix + 'from ' + p.getName() +"'s inventory.")
			else:
				suffix = 's.'
				player.getActionSender().sendMessage('The victim does not have any ' + item.getDefinition().getName() + suffix)