Quote:
Originally Posted by Stever1388
Yeah I was only testing with 2 players since it's the easiest way to do it.
And option one is what I was going for. I knew I was overlooking something like that, which is why I posted the question. I miss having a roommate that knows coding because this stuff is solved a lot faster!
Thanks Garan!
Edit: The sender in that event call is the EffectList that calls the event, not the player. How would I go about getting the player that the EffectList is for? Can I add a third parameter to the self.effectAddedHandler to be the player that has the EffectList, or would I have to go with option 2 and use the table?
|
You could add a .Player value to the self.effectList[] table entries to create a link back to the player:
change EffectTracker:HandleEffects to
Code:
function EffectTracker:HandleEffects(player)
self.effectList[player:GetName()] = player:GetEffects(); -- kept for removecallback function
self.effectList[player:GetName()].Player=player; -- creates a link back to the player
AddCallback(player:GetEffects(), "EffectAdded", self.effectAddedHandler);
end
and then in effectAddedHandler you could use sender.Player
Code:
self.effectAddedHandler = function(sender, args)
-- outputs data to chat window (code not important to discussion)
--sender.Player references the player for this effect list
end