-
First Dev On The Internet
Is there a way to get data for the other players ?
Hi guys,
I can get my player data from Hud.Game.Me but how can I get the data from other players in the party ?
Using foreach (var player in players) or is there another way ? (like getting data for player 3 only)
Thanks.
-
Savvy ? 🐒
PHP Code:
using System.Linq;
// inside your method :
var playerByIndex = Hud.Game.Players.FirstOrDefault(p => p.Index == 2);
// or
// var playerByPortraitIndex = Hud.Game.Players.FirstOrDefault(p => p.PortraitIndex == 2);
// don't forget to test for null
if (playerByIndex != null)
{
//do your stuff
}
-
Post Thanks / Like - 1 Thanks
User5981 (1 members gave Thanks to JackCeparou for this useful post)
-
First Dev On The Internet
Originally Posted by
JackCeparou
PHP Code:
using System.Linq;
// inside your method :
var playerByIndex = Hud.Game.Players.FirstOrDefault(p => p.Index == 2);
// or
// var playerByPortraitIndex = Hud.Game.Players.FirstOrDefault(p => p.PortraitIndex == 2);
// don't forget to test for null
if (playerByIndex != null)
{
//do your stuff
}
I tried to use it but playerByIndex is always null
-
Savvy ? 🐒
Try to use portraitIndex instead.
-
First Dev On The Internet
Originally Posted by
JackCeparou
Try to use portraitIndex instead.
it's working, I was just doing it at the wrong place,
+ I solved a two weeks long dilemma just by using a public variable :shh:
STUPID ME IS LEARNING THE HARD WAY... 
[v7.3] [INTERNATIONAL] [Resu] ParagonPercentagePlugin
-
Originally Posted by
JackCeparou
PHP Code:
using System.Linq;
// inside your method :
var playerByIndex = Hud.Game.Players.FirstOrDefault(p => p.Index == 2);
// or
// var playerByPortraitIndex = Hud.Game.Players.FirstOrDefault(p => p.PortraitIndex == 2);
// don't forget to test for null
if (playerByIndex != null)
{
//do your stuff
}
index is the slot index in the game (there are 4 slots)
if you create a game then you are #0
then somebody joins, he is #1
then you leave, he is still #1, while #0 is empty
then somebody join instead of you, he is #0
then you rejoin, you are #3
and so on
portraitIndex is ordered by the portraits on the screen, so you are always #0
Do not send me private messages unless it is absolutely necessary or the content is sensitive or when I ask you to do that...