Jump to content

Onbattlegroundend get winning team


Mpur

Recommended Posts

Hi! I'm a bit lost here, I've been trying for hours to get a list of players in the winning team of a battleground from the OnBattlegroundEnd hook, this is what I have:

https://pastebin.com/jLzCp9Qg

My first thought was to be able to get the players in either team from the BattleGround object, but there was no method like that as far as I could tell.

My second thought is what I have there right now, since I know the BG's mapID and instanceID I should be able to get all players on a specific map, check if they are in the correct instance, check if they are on the winning teams faction and then give them rewards, but I'm not sure that I'm doing it in the correct way.

bg:GetMapId() is 489, which matches the mapID for WSG where I did my testing, so far everything is alright.

GetPlayersInMap(bg:GetMapId()) returns an empty table though, my print of the table length prints 0, even though my character is clearly in WSG.

 

I'm going to sleep on it, but I would appreciate any pointers I could get in the meanwhile. :P

Oh yeah, I run TrinityCore 3.3.5 if it matters, I implemented the OnBattlegroundEnd hook myself and I have verified that it gives me valid and correct values in all parameters.

 

Link to comment
Share on other sites

Being not much of Eluna user, I cannot say for sure. However, you'll never get players on an instanceable map without using instanceID. Look at the sources here. So you have to use more extended signature for your GetPlayersInMap method, including the instanceID as the second parameter.

Your request for players fails at this line.

Link to comment
Share on other sites

Unless you've modified your core, the Eluna integration for Trinity doesn't yet fire the BG events.  It that's what you meant by "implemented the OnBattlegroundEnd hook myself", so be it. When your code calls OnBGEnd, it should be passing the instance ID, and the winner as the last two params. The issue you're going to run into with winner is that Eluna defines that as a Team, when really (at least for Trinity), it should be a TeamId or a BattlegroundTeamId, as those map directly to Eluna's TeamId (Alliance = 0, Horde = 1, Neutral = 2). The Team enum defines Alliance as 469, and Horde as 67.  You'll have to manually map those to the team IDs used by GetPlayersInMap.

Link to comment
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue. Privacy Policy Terms of Use