Fix hardcore deaths by wiping and reseeding the tsCharacter table.
Log to server/logs chat over head.
This commit is contained in:
parent
acdaa2eb05
commit
ddb2afefe9
3 changed files with 33 additions and 3 deletions
|
|
@ -130,5 +130,20 @@ namespace TShockAPI.DB
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool RemovePlayer(int userid)
|
||||
{
|
||||
try
|
||||
{
|
||||
database.Query("DELETE FROM tsCharacter WHERE Account = @0;", userid);
|
||||
return true;
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.ToString());
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -2513,6 +2513,15 @@ namespace TShockAPI
|
|||
args.Player.LastDeath = DateTime.Now;
|
||||
args.Player.Dead = true;
|
||||
|
||||
if (args.TPlayer.difficulty == 2 && TShock.Config.ServerSideCharacter && args.Player.IsLoggedIn)
|
||||
{
|
||||
User user = TShock.Users.GetUserByName(args.Player.UserAccountName);
|
||||
if (TShock.CharacterDB.RemovePlayer(user.ID))
|
||||
{
|
||||
TShock.CharacterDB.SeedInitialData(user);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -920,7 +920,7 @@ namespace TShockAPI
|
|||
}
|
||||
Log.Info(string.Format("{0} disconnected.", tsplr.Name));
|
||||
|
||||
if (tsplr.IsLoggedIn && !tsplr.IgnoreActionsForClearingTrashCan && TShock.Config.ServerSideCharacter)
|
||||
if (tsplr.IsLoggedIn && !tsplr.IgnoreActionsForClearingTrashCan && TShock.Config.ServerSideCharacter && (!tsplr.Dead || tsplr.TPlayer.difficulty != 2))
|
||||
{
|
||||
tsplr.PlayerData.CopyCharacter(tsplr);
|
||||
CharacterDB.InsertPlayerData(tsplr);
|
||||
|
|
@ -990,9 +990,15 @@ namespace TShockAPI
|
|||
ply.name = name;
|
||||
NetMessage.SendData((int) PacketTypes.ChatText, -1, args.Who, args.Text, args.Who, tsplr.Group.R, tsplr.Group.G, tsplr.Group.B);
|
||||
NetMessage.SendData((int)PacketTypes.PlayerInfo, -1, -1, name, args.Who, 0, 0, 0, 0);
|
||||
tsplr.SendMessage(String.Format("<{0}> {1}",
|
||||
|
||||
string msg = String.Format("<{0}> {1}",
|
||||
String.Format(Config.ChatAboveHeadsFormat, tsplr.Group.Name, tsplr.Group.Prefix, tsplr.Name, tsplr.Group.Suffix),
|
||||
args.Text), tsplr.Group.R, tsplr.Group.G, tsplr.Group.B);
|
||||
args.Text);
|
||||
|
||||
tsplr.SendMessage(msg, tsplr.Group.R, tsplr.Group.G, tsplr.Group.B);
|
||||
|
||||
TSPlayer.Server.SendMessage(msg, tsplr.Group.R, tsplr.Group.G, tsplr.Group.B);
|
||||
Log.Info(string.Format("Broadcast: {0}", msg));
|
||||
args.Handled = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue