PUpdate()//called by the current leader everytime someone leaves,enters the party,or is changed to leader status
if(!lead) return
for(var/mob/M in party)
if(M!=src)
if(M.party.len)
M.party.Remove(M.party)
M.party.Add(party)
for(var/mob/M in party)
M.PartyMeters()
PartyMeters()
if(inparty)
for(var/obj/HUD/PMeters/o in client.screen)
del o
var/hudstart=12//location on the y-axis where the HUD will be added
for(var/i=1;i<=party.len;i++)
for(var/mob/M in party)
if(M.partyid==i && M!=src)
new/obj/HUD/PMeters/BG(client,hudstart,M)
new/obj/HUD/PMeters/PHP(client,hudstart,M)
new/obj/HUD/PMeters/PE(client,hudstart,M)
Partytext(M.name,hudstart)
updatePStats()
hudstart--
Problem description:
I recently started implementing a party system in my code, and began to set up a feature where people in your party can monitor your basic statistics(HP and Energy). Even though I've currently only tested it with two people only the member who isn't the party leader gets the hp bars. When I use a coded verb to switch the leader roles the previous leader then receives the HUD additions that he hadn't received earlier, but everyone in the party is supposed to receive the extra HUD elements whenever the party contents are collectively updated.
http://www.byond.com/forum/?post=2017162#comment18065405
Addendum to second link:
Basically, each party member's bar shouldn't be deleting and recreating itself every frame. Switch to a state based approach and create a system that notifies you when a player leaves or joins. Update the party bars from within their own code, and NEVER search through the screen using a for loop.