private void Update(SwitchCmd cmd) { try { _database.Query("UPDATE SwitchCommands SET Command=@0, IgnorePermission=@1, AllPlayerCdSecond=@2 WHERE X=@3 AND Y=@4 AND WorldId=@5", cmd.Command, cmd.IgnorePermission ? 1 : 0, cmd.AllPlayerCdSecond, cmd.X, cmd.Y, Main.worldID); } catch (Exception ex) { TShock.Log.Error(ex.ToString()); } }
private void Insert(SwitchCmd cmd) { try { _database.Query("INSERT INTO SwitchCommands (X, Y, Command, IgnorePermission, AllPlayerCdSecond, WorldId) VALUES (@0, @1, @2, @3, @4, @5);", cmd.X, cmd.Y, cmd.Command, cmd.IgnorePermission ? 1 : 0, cmd.AllPlayerCdSecond, Main.worldID); } catch (Exception ex) { TShock.Log.Error(ex.ToString()); } }
public void UpdateSwitchCommands() { SwitchCmds.Clear(); using (var reader = _database.QueryReader("SELECT * FROM SwitchCommands WHERE WorldId=@0", Main.worldID)) { while (reader != null && reader.Read()) { SwitchCmds.Add(SwitchCmd.FromReader(reader)); } } TShock.Log.ConsoleInfo("共载入{0}个指令开关。", SwitchCmds.Count); }
public void Add(int x, int y, string command) { var ex = SwitchCmds.FirstOrDefault(sc => sc.X == x && sc.Y == y); if (ex != null) { ex.Command = command; Update(ex); } else { ex = new SwitchCmd { Command = command, X = x, Y = y, IgnorePermission = false, AllPlayerCdSecond = 0 }; Insert(ex); SwitchCmds.Add(ex); } }