I'm using a simple function to try to see if there are any players close by. It should return true at the closest player and it works for the most part. If I run the code below it will find the closest player to me than if I move closer to a different player, but the last found player is still visible. It will return the last found player every time and not the closest player, until the last found player leaves or is to far away. Does anyone have any idea why this might be happening?
# This is a list of friendly player types.
Friendly_Player_Types = [0x0190, 0x0191, 0x02EC, 0x02EB, 0x007B]
def ScanForPlayer(ScanDistance):
SetFindDistance(ScanDistance)
FindTypeEx(0xFFFF, 0xFFFF, Ground(), False)
PossiblePlayers = GetFindedList()
#PossiblePlayers.reverse()
for player in PossiblePlayers:
playerType = GetType(player)
playerNotoriety = GetNotoriety(player)
print('Found Object - Name: ['+GetName(player)+'] Type: ['+str(playerType)+'] Notoriety: ['+str(playerNotoriety)+'].')
if not(IsNPC(player)):
continue
elif playerType not in Friendly_Player_Types:
continue
elif player == Self():
continue
elif playerNotoriety != 1:
continue
else:
print('Found nearby Player: ['+GetName(player)+'].')
return True
return False
Timer = GetTickCount()
foundPlayer = ScanForPlayer(10)
print('Search Time Took: ['+str(GetTickCount() - Timer)+'] in milliseconds.')
if foundPlayer:
print('Found a player.')
else:
print("Didn't find a player.")
Thanks for taking the time to read my post.