def send_initial_players(unique_id):
nr_players = 0
to_send = [8]
c = 1
for i in range(1, 11): # Notice the change from 1 to 11 for Python's 0-based index.
u_id = get_unique_id_by_local(i)
if u_id != 0:
position = get_position(u_id)
x, y, rot = position # Python allows unpacking in a single line.
# Directly appending to the list instead of using an index.
to_send.append(x)
to_send.append(y)
to_send.append(rot)
to_send.append(get_player_username(u_id))
to_send.append(get_active(u_id))
else:
# Instead of incrementing c, we can just append zeros and "Offline".
to_send.extend([0, 0, 0, "Offline", 0])
send_data_to_player(unique_id, to_send, 10)
# Assuming the existence of the following Python functions that
# replace the corresponding PHP functions:
# get_unique_id_by_local(), get_position(), get_player_username(),
# get_active(), and send_data_to_player()
Note: The custom functions used in the PHP script (get_unique_id_by_local(), get_position(), get_player_username(), get_active(), send_data_to_player()) would need equivalent Python versions for this code to be functional. These functions are not defined in the translation, as their implementations would depend on the surrounding application context.