public void CMD_RemoveParkinglot(Client player) { if (!player.IsAdmin()) { player.sendChatMessage("~r~ERRO: ~w~Você não tem permissão."); return; } if (!player.hasData("ParkinglotMarker_ID")) { player.sendChatMessage("~r~ERRO: ~w~Fique em cima do checkpoint do estacionamento que deseja excluir."); return; } Parkinglot parkinglot = Main.Parkinglots.FirstOrDefault(h => h.ID == player.getData("ParkinglotMarker_ID")); if (parkinglot == null) { return; } parkinglot.Destroy(); Main.Parkinglots.Remove(parkinglot); string parkinglot_file = Main.PARKINGLOT_SAVE_DIR + Path.DirectorySeparatorChar + parkinglot.ID + ".json"; if (File.Exists(parkinglot_file)) { File.Delete(parkinglot_file); } API.sendChatMessageToPlayer(player, $"~g~SUCESSO: ~s~Você deletou o estacionamento."); }
public void CMD_CreateParkinglot(Client player) { if (!player.IsAdmin()) { player.sendChatMessage("~r~ERRO: ~w~Você não tem permissão."); return; } Parkinglot new_parkinglot = new Parkinglot(Main.GetGuid(), player.position); new_parkinglot.Save(); Main.Parkinglots.Add(new_parkinglot); API.sendChatMessageToPlayer(player, $"~g~SUCESSO: ~s~Você criou um estacionamento."); }
public void Parkinglot_Init() { // load settings if (API.hasSetting("parkinglotDirName")) { PARKINGLOT_SAVE_DIR = API.getSetting <string>("parkinglotDirName"); } PARKINGLOT_SAVE_DIR = API.getResourceFolder() + Path.DirectorySeparatorChar + PARKINGLOT_SAVE_DIR; if (!Directory.Exists(PARKINGLOT_SAVE_DIR)) { Directory.CreateDirectory(PARKINGLOT_SAVE_DIR); } if (API.hasSetting("playerParkinglotLimit")) { PLAYER_PARKINGLOT_LIMIT = API.getSetting <int>("playerParkinglotLimit"); } if (API.hasSetting("parkinglotMoneyLimit")) { PARKINGLOT_MONEY_LIMIT = API.getSetting <int>("parkinglotMoneyLimit"); } if (API.hasSetting("saveInterval")) { SAVE_INTERVAL = API.getSetting <int>("saveInterval"); } API.consoleOutput("-> Player Parking lot Limit: {0}", ((PLAYER_PARKINGLOT_LIMIT == 0) ? "Disabled" : PLAYER_PARKINGLOT_LIMIT.ToString())); API.consoleOutput("-> Parking lot Safe Limit: ${0:n0}", PARKINGLOT_MONEY_LIMIT); // load parking lots foreach (string file in Directory.EnumerateFiles(PARKINGLOT_SAVE_DIR, "*.json")) { Parkinglot parkinglot = JsonConvert.DeserializeObject <Parkinglot>(File.ReadAllText(file)); Parkinglots.Add(parkinglot); } API.consoleOutput("Loaded {0} parking lots.", Parkinglots.Count); }