protected override void Load() { Instance = this; Garages = new Garages(); Garages.Load(); U.Events.OnPlayerConnected += Events_OnPlayerConnected; U.Events.OnPlayerDisconnected += Events_OnPlayerDisconnected; Logger.Log("Loaded!", ConsoleColor.DarkGreen); }
public void Events_OnPlayerConnected(UnturnedPlayer player) { Garages g = GarageList.Find(x => x.SteamID == player.CSteamID.ToString()); if (g == null) { var newGarage = new Garages(); newGarage.SteamID = player.CSteamID.ToString(); newGarage.VehicleID = 0; GarageList.Add(newGarage); } }
public void Execute(IRocketPlayer caller, params string[] command) { UnturnedPlayer player = (UnturnedPlayer)caller; if (command.Length > 0) { switch (command[0]) { case "save": if (player.IsInVehicle) { Garages plrGarage = Garage.Instance.GarageList.Find(x => x.SteamID == player.CSteamID.ToString()); if (plrGarage == null) { UnturnedChat.Say(caller, Garage.Instance.Translations.Instance.Translate("garage_error"), Color.red); Console.WriteLine("ERROR! Cannot find garage for online player!"); return; } plrGarage.VehicleID = player.CurrentVehicle.id; UnturnedChat.Say(caller, Garage.Instance.Translations.Instance.Translate("garage_vehicle_saved"), Color.green); } else { UnturnedChat.Say(caller, Garage.Instance.Translations.Instance.Translate("garage_not_in_vehicle"), Color.red); } break; case "load": Garages plrVehicle = Garage.Instance.GarageList.Find(x => x.SteamID == player.CSteamID.ToString()); if (plrVehicle == null) { UnturnedChat.Say(caller, Garage.Instance.Translations.Instance.Translate("garage_error"), Color.red); Console.WriteLine("ERROR! Cannot find garage for online player!"); return; } if (plrVehicle.VehicleID == 0) { UnturnedChat.Say(caller, Garage.Instance.Translations.Instance.Translate("garage_no_vehicle"), Color.red); return; } player.GiveVehicle(plrVehicle.VehicleID); if (Garage.Instance.Configuration.Instance.RemoveVehicleWhenLoaded) { plrVehicle.VehicleID = 0; } UnturnedChat.Say(caller, Garage.Instance.Translations.Instance.Translate("garage_vehicle_loaded"), Color.green); break; default: UnturnedChat.Say(caller, Garage.Instance.Translations.Instance.Translate("garage_invalid_command"), Color.red); break; } } else { UnturnedChat.Say(caller, Help, Color.white); UnturnedChat.Say(caller, "Syntax: " + Syntax, Color.yellow); } }