Initial commit
This commit is contained in:
164
C#/FiveM/CardealerClient/Objects.cs
Normal file
164
C#/FiveM/CardealerClient/Objects.cs
Normal file
@@ -0,0 +1,164 @@
|
||||
using System;
|
||||
using System.Dynamic;
|
||||
using System.Threading.Tasks;
|
||||
using CitizenFX.Core;
|
||||
using Nexd.ESX.Client;
|
||||
|
||||
namespace CardealerClient {
|
||||
public class Exhibit {
|
||||
public int Slot { get; set; }
|
||||
public Vector4 Location { get; set; }
|
||||
}
|
||||
|
||||
public class VehicleData {
|
||||
public VehicleProperties Properties { get; }
|
||||
public string Owner { get; }
|
||||
public string Description { get; set; }
|
||||
public int Price { get; set; }
|
||||
public int Slot { get; }
|
||||
public int Id { get; }
|
||||
public int ParkingSpace { get; }
|
||||
public bool AutoShuffle { get; }
|
||||
|
||||
public VehicleData(dynamic data) {
|
||||
Properties = new VehicleProperties(data.vehicle);
|
||||
Owner = data.owner;
|
||||
Price = Convert.ToInt32(data.price);
|
||||
Slot = Convert.ToInt32(data.slot);
|
||||
ParkingSpace = Convert.ToInt32(data.parkingspace);
|
||||
Id = Convert.ToInt32(data.id);
|
||||
AutoShuffle = Convert.ToInt32(data.shuffle) == 1;
|
||||
|
||||
try {
|
||||
Description = data.description;
|
||||
}
|
||||
catch (Exception) {
|
||||
Description = "Nicht angegeben";
|
||||
}
|
||||
}
|
||||
|
||||
public void UpdateSlot() {
|
||||
dynamic data = new ExpandoObject();
|
||||
data.slot = Slot;
|
||||
data.parkingspace = ParkingSpace;
|
||||
data.description = Description;
|
||||
data.price = Price;
|
||||
data.owner = Owner;
|
||||
data.vehicle = Properties.Raw;
|
||||
data.shuffle = AutoShuffle ? 1 : 0;
|
||||
|
||||
BaseScript.TriggerServerEvent("cardealer:updateSlot", data);
|
||||
}
|
||||
|
||||
public void Delete() {
|
||||
BaseScript.TriggerServerEvent("cardealer:deleteVehicle", Slot);
|
||||
}
|
||||
|
||||
public async Task<bool> PushToExhibit() {
|
||||
return await CarDealer.ServerCallback("cardealer:pushToExhibit", Id) as bool? ?? false;
|
||||
}
|
||||
}
|
||||
|
||||
public class SellData {
|
||||
public int ParkingSpace { get; set; }
|
||||
public string Description { get; set; }
|
||||
public int Price { get; set; }
|
||||
public int Slot { get; set; }
|
||||
|
||||
public dynamic CreateDynamic(dynamic vehicle) {
|
||||
dynamic raw = new ExpandoObject();
|
||||
raw.parkingspace = ParkingSpace;
|
||||
raw.description = Description;
|
||||
raw.price = Price;
|
||||
raw.slot = Slot;
|
||||
raw.vehicle = vehicle;
|
||||
return raw;
|
||||
}
|
||||
}
|
||||
|
||||
public static class MenuElements {
|
||||
|
||||
public static dynamic GetElement_Parkingspace() {
|
||||
dynamic data = new ExpandoObject();
|
||||
|
||||
data.label = "Stellplatztyp wählen";
|
||||
data.name = "choose_parkingSpace";
|
||||
data.value = 0;
|
||||
data.options = new[] { "Ausgestellt", "Katalog" };
|
||||
data.type = "slider";
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public static dynamic GetElement_Description() {
|
||||
dynamic data = new ExpandoObject();
|
||||
|
||||
data.label = "Beschreibung hinzufügen";
|
||||
data.name = "choose_description";
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public static dynamic GetElement_Price() {
|
||||
dynamic data = new ExpandoObject();
|
||||
|
||||
data.label = "Preis wählen";
|
||||
data.name = "choose_price";
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public static dynamic GetElement_Finish() {
|
||||
dynamic data = new ExpandoObject();
|
||||
|
||||
data.label = "Fertig";
|
||||
data.name = "finish";
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
public static dynamic GetMenu_DigitalExhibit(string[] cars) {
|
||||
dynamic menuData = new ExpandoObject();
|
||||
|
||||
menuData.title = Config.MenuTitle;
|
||||
menuData.align = "top-left";
|
||||
menuData.elements = new dynamic[3];
|
||||
menuData.elements[0] = GetElement_AllCars(cars);
|
||||
menuData.elements[1] = GetElement_TestDrive();
|
||||
menuData.elements[2] = GetElement_Buy();
|
||||
|
||||
return menuData;
|
||||
}
|
||||
|
||||
private static dynamic GetElement_AllCars(string[] names) {
|
||||
dynamic data = new ExpandoObject();
|
||||
|
||||
data.label = "Auto";
|
||||
data.name = "car";
|
||||
data.value = 0;
|
||||
data.options = names;
|
||||
data.type = "slider";
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private static dynamic GetElement_TestDrive() {
|
||||
dynamic data = new ExpandoObject();
|
||||
|
||||
data.label = "Probefahrt";
|
||||
data.name = "testdrive";
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
private static dynamic GetElement_Buy() {
|
||||
dynamic data = new ExpandoObject();
|
||||
|
||||
data.label = "Kaufen";
|
||||
data.name = "buy";
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user