I came across the following sentence in Harry Potter à l'école des sorciers (Harry Potter and the Philosopher's Stone):
Les élèves de Smelting avaient également une canne dont ils se servaient pour se taper dessus quand les professeurs ne les voyaient pas.
My attempted translation of this is:
The pupils of Smeltings also had a stick which they used to hit themselves when the teachers couldn't see them.
The original sentence in J.K. Rowling's version is:
They also carried knobbly sticks, used for hitting each other while the teachers weren't looking.
How does the French translation above make clear that the pupils were hitting each other, rather than each pupil hitting himself?