Page 1 of 1

[Python] ModManager.FindPlayer()

Posted: 2015-02-28 18:34
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.

Re: [Python] ModManager.FindPlayer()

Posted: 2015-02-28 18:46
by Mats391
host.rcon_invoke("echo " + text) puts stuff on console

Re: [Python] ModManager.FindPlayer()

Posted: 2015-02-28 19:18
by RarWinZip
[R-DEV]Mats391 wrote:host.rcon_invoke("echo " + text) puts stuff on console
Thank you, man.