Friendship is not based on how many minutes you spend with someone, nor how many miles between them.
Neither is it exclusive, nor can anyone "steal" a friend from you. A might monopolize B's phoneline, but that doesn't stop B and C from still being friends.
A friend is someone that knows you and cares for you, regardless of time, distance, or other people.
Take a deep breath, relax, and ignore the childish 'alliances' or 'rivalries' your friends conjure up between each other.
Treat each person as an individual, worthy of respect and honour and care.
Controlling or influencing 'alliances' and 'rivalries' is just plain socially abusive. Deal with people one on one, not through third parties. If someone is socially bullying you, or you witness social bullying going on, speak up and stop it... either directly, or approach your school's guidance counsellor about the problem.
Often, a country has some sort of charter or constitution regarding:
Freedom of choice / belief / emotion / thought or assembly / association
If S doesn't care or doesn't associate with H, that's S's choice. Don't rob S of S's choice, nor boss S around.
If H feels rejected, that's H's choice to feel that way. H could seek out friends that treat H better, or H could wallow in self-pity over losing S. Glass half-full, glass half empty.
If H spends more time associating with Z than with you, once again, that's H's choice. Whether or not you feel left out, or choose to rise above and seek friends who are more inclusive, is your choice. Chose wisely.
Z won't 'forget about you' unless Z gets amnesia or Alzheimers. If you've been an honest, caring friend to Z, let Z choose who and when to associate with. Your patience will be rewarded.
If S gets angry, that's S's emotional choice, and immaturity. Anger happens when an injustice is percieved, but doesn't mean a friendship is over.
If Z is emotional, that's Z's choice. If Z 'leaves' you, that's Z's choice to not associate. This isn't a marriage between 4 people. Why not invite S, and H, to your town, some weekend, so they aren't so far, and go for coffee with Z as well. Sounds like all 4 of you could sit down and enjoy a 15 scoop bowl of ice cream together, if you all collectively figure out how to:
a) express what hurts without blaming.
b) apologize for how you've hurt others.
c) forgive, even if an apology isn't offered.
d) forget, for tomorrow is full of opportunities to bless and encouage each other.