Updated Local Files
This commit is contained in:
parent
87e3fd347d
commit
44afc6d8dd
3 changed files with 33 additions and 10 deletions
|
|
@ -1007,7 +1007,9 @@ namespace TShockAPI
|
|||
//Added restart command
|
||||
private static void Restart(CommandArgs args)
|
||||
{
|
||||
|
||||
if (Main.runningMono){
|
||||
Log.ConsoleInfo("Sorry, this command has not yet been implemented in Mono");
|
||||
}else{
|
||||
if (TShock.Config.ServerSideInventory)
|
||||
{
|
||||
foreach (TSPlayer player in TShock.Players)
|
||||
|
|
@ -1024,7 +1026,7 @@ namespace TShockAPI
|
|||
Netplay.disconnect = true;
|
||||
System.Diagnostics.Process.Start(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
|
||||
Environment.Exit(0);
|
||||
}
|
||||
}}
|
||||
|
||||
private static void OffNoSave(CommandArgs args)
|
||||
{
|
||||
|
|
@ -3452,4 +3454,4 @@ namespace TShockAPI
|
|||
|
||||
#endregion Cheat Comamnds
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,6 +44,28 @@ namespace TShockAPI.DB
|
|||
creator.EnsureExists(table);
|
||||
}
|
||||
|
||||
public Vector2 CheckLeavePos(string name)
|
||||
{
|
||||
try
|
||||
{
|
||||
using (var reader = database.QueryReader("SELECT * FROM RememberedPos WHERE Name=@0", name))
|
||||
{
|
||||
if (reader.Read())
|
||||
{
|
||||
return new Vector2(reader.Get<int>("X"), reader.Get<int>("Y"));
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Log.Error(ex.ToString());
|
||||
}
|
||||
|
||||
return new Vector2();
|
||||
}
|
||||
|
||||
|
||||
|
||||
public Vector2 GetLeavePos(string name, string IP)
|
||||
{
|
||||
try
|
||||
|
|
@ -66,12 +88,11 @@ namespace TShockAPI.DB
|
|||
|
||||
public void InsertLeavePos(string name, string IP, int X, int Y)
|
||||
{
|
||||
if (GetLeavePos(name, IP) == Vector2.Zero)
|
||||
if (CheckLeavePos(name) == Vector2.Zero)
|
||||
{
|
||||
try
|
||||
{
|
||||
database.Query("INSERT INTO RememberedPos (Name, IP, X, Y, WorldID) VALUES (@0, @1, @2, @3, @4);", name, IP, X,
|
||||
Y + 3, Main.worldID.ToString());
|
||||
database.Query("INSERT INTO RememberedPos (Name, IP, X, Y, WorldID) VALUES (@0, @1, @2, @3, @4);", name, IP, X, Y , Main.worldID.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -82,8 +103,7 @@ namespace TShockAPI.DB
|
|||
{
|
||||
try
|
||||
{
|
||||
database.Query("UPDATE RememberedPos SET X = @0, Y = @1 WHERE Name = @2 AND IP = @3 AND WorldID = @4;", X, Y + 3,
|
||||
name, IP, Main.worldID.ToString());
|
||||
database.Query("UPDATE RememberedPos SET X = @0, Y = @1, IP = @2 WHERE Name = @3 AND WorldID = @4;", X, Y, IP, name, Main.worldID.ToString());
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
@ -92,4 +112,4 @@ namespace TShockAPI.DB
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -854,10 +854,11 @@ namespace TShockAPI
|
|||
|
||||
if (Config.RememberLeavePos)
|
||||
{
|
||||
if (RememberedPos.GetLeavePos(player.Name, player.IP) != Vector2.Zero){
|
||||
var pos = RememberedPos.GetLeavePos(player.Name, player.IP);
|
||||
player.LastNetPosition = pos;
|
||||
player.Teleport((int) pos.X, (int) pos.Y + 3);
|
||||
}
|
||||
}}
|
||||
|
||||
e.Handled = true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue