[Python] ModManager.FindPlayer()
Posted: 2015-02-28 18:34
Hi there. Can someone tell me is there any way to output something into server console? 
Or, maybe, someone can help me with this script:
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.
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"