[Python] ModManager.FindPlayer()

Making or wanting help making your own asset? Check in here
Post Reply
RarWinZip
Posts: 162
Joined: 2011-08-15 07:22

[Python] ModManager.FindPlayer()

Post by RarWinZip »

Hi there. Can someone tell me is there any way to output something into server console? :D

Or, maybe, someone can help me with this script:

Code: Select all

def FindPlayer(playerName):
	matches = 0
	p_good = ""

	try:
		for p in bf2.playerManager.getPlayers():
			if p.getName().lower().find(playerName.lower()) != -1:
				p_good = p
				matches += 1

				mm.debug("Player name is %s" % p_good.getName().lower())
				
				# If actual player's name perfectly fits finish it up
[color=Red]				if p.getName().lower().equals(playerName.lower()):
					p_good = p
					matches = 1
					mm.debug("Exact name is found and it's  %s" % p_good.getName().lower())
					break[/color]
				
				if matches > 1:
					return "more"

		if matches == 0:
			return "none"
		else:
			return p_good
	except:
		mm.debug("Exception in FindPlayer()")
		return "none"
For some reason red part of the script don't work. I think it's a problem with the data player.getName() method returns, but I am not sure, because there could be some special sings or something.
User avatar
Mats391
PR:BF2 Lead Developer
Posts: 7643
Joined: 2010-08-06 18:06

Re: [Python] ModManager.FindPlayer()

Post by Mats391 »

host.rcon_invoke("echo " + text) puts stuff on console
RarWinZip
Posts: 162
Joined: 2011-08-15 07:22

Re: [Python] ModManager.FindPlayer()

Post by RarWinZip »

[R-DEV]Mats391 wrote:host.rcon_invoke("echo " + text) puts stuff on console
Thank you, man.
Post Reply

Return to “PR:BF2 Community Modding”