Beispiel #1
0
        public async Task switchTuning(IPlayer player, IVehicle vehicle, string Type, int ModType, string Action)
        {
            try
            {
                if (player == null || !player.Exists || vehicle == null || !vehicle.Exists)
                {
                    return;
                }
                if (player.GetCharacterMetaId() <= 0 || vehicle.GetVehicleId() <= 0)
                {
                    return;
                }
                vehicle.ModKit = 1;
                if (Type == "Preview")
                {
                    ServerVehicles.SetVehicleModID(vehicle, Type, Action, ModType);
                    byte modId = 0;
                    if (ModType == 280)
                    {
                        modId = vehicle.HeadlightColor;
                    }
                    else
                    {
                        modId = vehicle.GetMod(Convert.ToByte(ModType));
                    }
                    if (modId == 255)
                    {
                        modId = 0;
                    }
                    if (ModType == 46)
                    {
                        modId = vehicle.WindowTint;
                        if (modId == 255)
                        {
                            modId = 0;
                        }
                    }
                    else if (ModType == 132)
                    {
                        modId = vehicle.WheelColor;
                    }
                    else if (ModType == 23)
                    {
                        modId = vehicle.WheelVariation;
                    }
                    else if (ModType == 100)
                    {
                        modId = vehicle.PrimaryColor;
                    }
                    else if (ModType == 200)
                    {
                        modId = vehicle.SecondaryColor;
                    }
                    else if (ModType == 250)
                    {
                        modId = vehicle.PearlColor;
                    }
                    else if (ModType == 280)
                    {
                        modId = vehicle.HeadlightColor;
                    }

                    if (modId > 0)
                    {
                        if (ModType == 23)
                        {
                            int WheelT = vehicle.WheelType;
                            if (WheelT == 255)
                            {
                                WheelT = 0;
                            }
                            string modName = ServerVehicles.GetVehicleModName(0, Convert.ToInt32(ModType + "" + WheelT), modId);
                            HUDHandler.SendNotification(player, 1, 3500, $"Mod Name: {modName} | Mod-ID: {modId} | Mod-Type: {ModType}");
                        }
                        else if (ModType == 46)
                        {
                            modId = vehicle.WindowTint;
                            if (modId == 255)
                            {
                                modId = 0;
                            }
                            string modName = ServerVehicles.GetVehicleModName(0, 46, modId);
                            HUDHandler.SendNotification(player, 1, 3500, $"Mod Name: {modName} | Mod-ID: {modId} | Mod-Type: {ModType}");
                        }
                        else if (ModType == 11 || ModType == 12 || ModType == 13 || ModType == 14 || ModType == 15 || ModType == 22)
                        {
                            string modName = ServerVehicles.GetVehicleModName(0, ModType, modId);
                            HUDHandler.SendNotification(player, 1, 3500, $"Mod Name: {modName} | Mod-ID: {modId} | Mod-Type: {ModType}");
                        }
                        else if (ModType == 100)
                        {
                            modId = vehicle.PrimaryColor;
                            string modName = ServerVehicles.GetVehicleModName(0, 132, modId);
                            HUDHandler.SendNotification(player, 1, 3500, $"Mod-Name: {modName} | Mod-ID: {modId} | Mod-Type: {ModType}");
                        }
                        else if (ModType == 200)
                        {
                            modId = vehicle.SecondaryColor;
                            string modName = ServerVehicles.GetVehicleModName(0, 132, modId);
                            HUDHandler.SendNotification(player, 1, 3500, $"Mod-Name: {modName} | Mod-ID: {modId}| Mod-Type: {ModType}");
                        }
                        else if (ModType == 250)
                        {
                            modId = vehicle.PearlColor;
                            string modName = ServerVehicles.GetVehicleModName(0, 132, modId);
                            HUDHandler.SendNotification(player, 1, 3500, $"Mod-Name: {modName} | Mod-ID: {modId}| Mod-Type: {ModType}");
                        }
                        else if (ModType == 280)
                        {
                            modId = vehicle.HeadlightColor;
                            string modName = ServerVehicles.GetVehicleModName(0, 280, modId);
                            HUDHandler.SendNotification(player, 1, 3500, $"Mod-Name: {modName} | Mod-ID: {modId}| Mod-Type: {ModType}");
                        }
                        else if (ModType == 131)
                        {
                            modId = vehicle.WheelType;
                            string modName = ServerVehicles.GetVehicleModName(0, 131, modId);
                            HUDHandler.SendNotification(player, 1, 3500, $"Mod Name: {modName} | Mod-ID: {modId} | Mod-Type: {ModType}");
                        }
                        else if (ModType == 132)
                        {
                            modId = vehicle.WheelColor;
                            string modName = ServerVehicles.GetVehicleModName(0, 132, modId);
                            HUDHandler.SendNotification(player, 1, 3500, $"Mod Name: {modName} | Mod-ID: {modId} | Mod-Type: {ModType}");
                        }
                        else
                        {
                            string modName = ServerVehicles.GetVehicleModName(0, ModType, modId);
                            HUDHandler.SendNotification(player, 1, 3500, $"Mod Name: {modName} | Mod-ID: {modId} | Mod-Type: {ModType}");
                        }
                    }
                    else if (modId <= 0)
                    {
                        HUDHandler.SendNotification(player, 4, 2000, $"Tuning Teil entfernt. [ModType: {ModType}].");
                    }
                }
                else if (Type == "Build")
                {
                    ServerVehicles.SetVehicleModID(vehicle, Type, Action, ModType);
                    int ModID = ServerVehicles.GetCurrentVehMod(vehicle, ModType);
                    if (ModID == 255)
                    {
                        ModID = 0;
                    }
                    if (ModID > 0)
                    {
                        if (ModType == 23)
                        {
                            int WheelT = vehicle.WheelType;
                            if (WheelT == 255)
                            {
                                WheelT = 0;
                            }
                            string modName = ServerVehicles.GetVehicleModName(0, Convert.ToInt32(ModType + "" + WheelT), ModID);
                            HUDHandler.SendNotification(player, 1, 1500, $"Mod-Name: {modName} | Mod-ID: {ModID} | Mod-Type: {ModType}");
                        }
                        else if (ModType == 46)
                        {
                            ModID = vehicle.WindowTint;
                            if (ModID == 255)
                            {
                                ModID = 0;
                            }
                            string modName = ServerVehicles.GetVehicleModName(0, 46, ModID);
                        }
                        else if (ModType == 11 || ModType == 12 || ModType == 13 || ModType == 14 || ModType == 15 || ModType == 22)
                        {
                            string modName = ServerVehicles.GetVehicleModName(0, ModType, ModID);
                            HUDHandler.SendNotification(player, 1, 1500, $"Mod-Name: {modName} | Mod-ID: {ModID} | Mod-Type: {ModType}");
                        }
                        else if (ModType == 100)
                        {
                            ModID = vehicle.PrimaryColor;
                            if (ModID == 255)
                            {
                                ModID = 0;
                            }
                            string modName = ServerVehicles.GetVehicleModName(0, 132, ModID);
                            HUDHandler.SendNotification(player, 1, 1500, $"Mod-Name: {modName} | Mod-ID: {ModID} | Mod-Type: {ModType}");
                        }
                        else if (ModType == 200)
                        {
                            ModID = vehicle.SecondaryColor;
                            if (ModID == 255)
                            {
                                ModID = 0;
                            }
                            string modName = ServerVehicles.GetVehicleModName(0, 132, ModID);
                            HUDHandler.SendNotification(player, 1, 1500, $"Mod-Name: {modName} | Mod-ID: {ModID} | Mod-Type: {ModType}");
                        }
                        else if (ModType == 250)
                        {
                            ModID = vehicle.PearlColor;
                            if (ModID == 255)
                            {
                                ModID = 0;
                            }
                            string modName = ServerVehicles.GetVehicleModName(0, 132, ModID);
                            HUDHandler.SendNotification(player, 1, 1500, $"Mod-Name: {modName} | Mod-ID: {ModID} | Mod-Type: {ModType}");
                        }
                        else if (ModType == 280)
                        {
                            ModID = vehicle.HeadlightColor;
                            if (ModID == 255)
                            {
                                ModID = 0;
                            }
                            string modName = ServerVehicles.GetVehicleModName(0, 280, ModID);
                            HUDHandler.SendNotification(player, 1, 1500, $"Mod-Name: {modName} | Mod-ID: {ModID} | Mod-Type: {ModType}");
                        }
                        else if (ModType == 131)
                        {
                            string modName = ServerVehicles.GetVehicleModName(0, 131, ModID);
                            HUDHandler.SendNotification(player, 1, 1500, $"Mod-Name: {modName} | Mod-ID: {ModID} | Mod-Type: {ModType}");
                        }
                        else if (ModType == 132)
                        {
                            string modName = ServerVehicles.GetVehicleModName(0, 132, ModID);
                            HUDHandler.SendNotification(player, 1, 1500, $"Mod-Name: {modName} | Mod-ID: {ModID} | Mod-Type: {ModType}");
                        }
                        else
                        {
                            string modName = ServerVehicles.GetVehicleModName(vehicle.Model, ModType, ModID);
                            HUDHandler.SendNotification(player, 1, 1500, $"Mod-Name: {modName} | Mod-ID: {ModID} | Mod-Type: {ModType}");
                        }
                    }
                    else if (ModID <= 0)
                    {
                        HUDHandler.SendNotification(player, 4, 2000, $"Tuning Teil entfernt. [ModType: {ModType} - ModID: {ModID}].");
                    }
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }