start car shop

This commit is contained in:
hydrant
2018-12-20 22:20:19 +01:00
parent b16ed270c2
commit 9f9d84f383
14 changed files with 144 additions and 70 deletions

View File

@@ -220,9 +220,9 @@ namespace reallife_gamemode.Server.Commands
}
player.SendChatMessage("~m~__________ ~s~Businesses ~m~__________");
foreach (Business.BusinessBase b in BusinessManager.Businesses)
foreach (BusinessBase b in BusinessManager.Businesses.OrderBy(b => b.Id))
{
player.SendChatMessage(b.Id.ToString().PadRight(3) + " | " + b.Name);
player.SendChatMessage(b.Id.ToString().PadRight(3) + " | " + b.Name + (b is CarDealerBusinessBase ? " | Autohaus" : ""));
}
}
#endregion
@@ -1440,8 +1440,8 @@ namespace reallife_gamemode.Server.Commands
}
}
[Command("save", "~m~Benutzung: ~s~/save [Typ = ~g~Blip~s~, ~g~Goto (X)~s~, ~r~Marker~s~, ~r~Ped~s~, ~r~Pickup~s~, ~r~TextLabel~s~, ~g~Vehicle~s~, ~g~FVehicle~s~, ~g~SVehicle~s~] (Beschreibung) = (X)")]
public void CmdAdminSave(Client player, string typ, string description = null)
[Command("save", "~m~Benutzung: ~s~/save [Typ = ~g~Blip~s~, ~g~Goto (X)~s~, ~r~Marker~s~, ~r~Ped~s~, ~r~Pickup~s~, ~r~TextLabel~s~, ~g~Vehicle~s~, ~g~FVehicle~s~, ~g~SVehicle (X)~s~] (Beschreibung) = (X)")]
public void CmdAdminSave(Client player, string typ, string option1 = null, string option2 = null)
{
if (!player.GetUser()?.IsAdmin(AdminLevel.HEADADMIN) ?? true)
{
@@ -1454,7 +1454,7 @@ namespace reallife_gamemode.Server.Commands
player.TriggerEvent("saveBlip");
break;
case "goto":
if (description == null)
if (option1 == null)
{
player.SendChatMessage("Für Goto musst du einen dritten Parameter angeben. Beispiel: Ort des Goto-Punktes.");
return;
@@ -1463,11 +1463,11 @@ namespace reallife_gamemode.Server.Commands
{
using (var dbContext = new DatabaseContext())
{
GotoPoint p = dbContext.GotoPoints.FirstOrDefault(x => x.Description == description);
GotoPoint p = dbContext.GotoPoints.FirstOrDefault(x => x.Description == option1);
if (p == null)
{
SaveManager.SaveGotoPoint(player, description);
player.SendNotification("Goto-Punkt ~g~" + description + "~s~ gespeichert.", true);
SaveManager.SaveGotoPoint(player, option1);
player.SendNotification("Goto-Punkt ~g~" + option1 + "~s~ gespeichert.", true);
}
else
{
@@ -1513,12 +1513,37 @@ namespace reallife_gamemode.Server.Commands
case "svehicle":
if (player.IsInVehicle)
{
if(option1 == null || option2 == null)
{
player.SendChatMessage("~m~Benutzung: ~s~/save SVehicle [Carshop Business ID] [Preis]");
return;
}
if(!int.TryParse(option1, out int businessId) || !int.TryParse(option2, out int price))
{
player.SendChatMessage("~m~Benutzung: ~s~/save SVehicle [Carshop Business ID] [Preis]");
return;
}
BusinessBase business = BusinessManager.GetBusiness(businessId);
if(business == null)
{
player.SendChatMessage("~r~[FEHLER]~s~ Dieses Business existiert nicht.");
return;
}
if(!(business is CarDealerBusinessBase))
{
player.SendChatMessage("~r~[FEHLER]~s~ Dieses Business ist kein Fahrzeug-Business.");
return;
}
Vehicle vehicle = player.Vehicle;
int playerSeat = player.VehicleSeat;
vehicle = SaveManager.SaveShopVehicleData(vehicle, (VehicleHash)vehicle.Model, vehicle.DisplayName, vehicle.Position, vehicle.Heading, vehicle.NumberPlate,
Convert.ToByte(vehicle.PrimaryColor), Convert.ToByte(vehicle.SecondaryColor));
Convert.ToByte(vehicle.PrimaryColor), Convert.ToByte(vehicle.SecondaryColor), business, price);
player.SendNotification("Shopfahrzeug ~g~" + vehicle.DisplayName + "~s~ gespeichert.", true);
player.SetIntoVehicle(vehicle, playerSeat);
player.Position = player.Position.Add(new Vector3(0, 0, 2));
}
else player.SendChatMessage("~m~Du sitzt in keinem Fahrzeug!");
break;