Fix Lua API returning wrong player info
The Lua API would return wrong information on player fields such as the team or faction when it was changed in the lobby. It referenced fields on the PlayerReference, which are pretty much read-only and don't get changed by the lobby.
This commit is contained in:
@@ -39,18 +39,25 @@ namespace OpenRA.Mods.Common.Scripting
|
||||
get
|
||||
{
|
||||
Game.Debug("The property `PlayerProperties.Race` is deprecated! Use `PlayerProperties.Faction` instead!");
|
||||
return Player.PlayerReference.Faction;
|
||||
return Player.Faction.InternalName;
|
||||
}
|
||||
}
|
||||
|
||||
[Desc("The player's faction.")]
|
||||
public string Faction { get { return Player.PlayerReference.Faction; } }
|
||||
public string Faction { get { return Player.Faction.InternalName; } }
|
||||
|
||||
[Desc("The player's spawnpoint ID.")]
|
||||
public int Spawn { get { return Player.SpawnPoint; } }
|
||||
|
||||
[Desc("The player's team ID.")]
|
||||
public int Team { get { return Player.PlayerReference.Team; } }
|
||||
public int Team
|
||||
{
|
||||
get
|
||||
{
|
||||
var c = Player.World.LobbyInfo.Clients[Player.ClientIndex];
|
||||
return c != null ? c.Team : 0;
|
||||
}
|
||||
}
|
||||
|
||||
[Desc("Returns true if the player is a bot.")]
|
||||
public bool IsBot { get { return Player.IsBot; } }
|
||||
|
||||
Reference in New Issue
Block a user