New "AlwayaPvp" system. Client controls its own pvp status completely and will refuse all damage attempts by players outside of pvp and if it's not set to pvp. Solution? Block all actions and wait for user to manually enable pvp.

This commit is contained in:
Zidonuke 2011-12-20 04:20:18 -05:00
parent 82fb69f9d4
commit 37692d0365
3 changed files with 104 additions and 28 deletions

View file

@ -37,7 +37,7 @@ namespace TShockAPI
public Group Group { get; set; }
public bool ReceivedInfo { get; set; }
public int Index { get; protected set; }
public DateTime LastPvpChange { get; protected set; }
public DateTime LastPvpChange;
public Point[] TempPoints = new Point[2];
public int AwaitingTempPoint { get; set; }
public bool AwaitingName { get; set; }
@ -49,6 +49,7 @@ namespace TShockAPI
public TSPlayer LastWhisper;
public int LoginAttempts { get; set; }
public Vector2 TeleportCoords = new Vector2(-1, -1);
public Vector2 LastNetPosition = Vector2.Zero;
public string UserAccountName { get; set; }
public bool HasBeenSpammedWithBuildMessage;
public bool IsLoggedIn;
@ -307,18 +308,6 @@ namespace TShockAPI
NetMessage.SendData((int)PacketTypes.PlayerDamage, -1, -1, "", Index, ((new Random()).Next(-1, 1)), damage, (float)0);
}
public virtual void SetPvP(bool pvp)
{
if (TPlayer.hostile != pvp)
{
LastPvpChange = DateTime.UtcNow;
TPlayer.hostile = pvp;
All.SendMessage(string.Format("{0} has {1} PvP!", Name, pvp ? "enabled" : "disabled"), Main.teamColor[Team]);
}
//Broadcast anyways to keep players synced
NetMessage.SendData((int)PacketTypes.TogglePvp, -1, -1, "", Index);
}
public virtual void SetTeam(int team)
{
Main.player[Index].team = team;