示例#1
0
 public async Task BuyVehicle(IPlayer player, int shopid, string hash)
 {
     try
     {
         Stopwatch stopwatch = new Stopwatch();
         stopwatch.Start();
         if (player == null || !player.Exists || shopid <= 0 || hash == "")
         {
             return;
         }
         ulong fHash  = Convert.ToUInt64(hash);
         int   charId = User.GetPlayerOnline(player);
         if (charId == 0 || fHash == 0)
         {
             return;
         }
         int      Price     = ServerVehicleShops.GetVehicleShopPrice(shopid, fHash);
         bool     PlaceFree = true;
         Position ParkOut   = ServerVehicleShops.GetVehicleShopOutPosition(shopid);
         Rotation RotOut    = ServerVehicleShops.GetVehicleShopOutRotation(shopid);
         foreach (IVehicle veh in Alt.Server.GetVehicles().ToList())
         {
             if (veh.Position.IsInRange(ParkOut, 2f))
             {
                 PlaceFree = false; break;
             }
         }
         if (!PlaceFree)
         {
             HUDHandler.SendNotification(player, 3, 5000, $"Der Ausladepunkt ist belegt."); return;
         }
         int rnd = new Random().Next(100000, 999999);
         if (ServerVehicles.ExistServerVehiclePlate($"NL{rnd}"))
         {
             BuyVehicle(player, shopid, hash); return;
         }
         if (!CharactersInventory.ExistCharacterItem(charId, "Bargeld", "inventory") || CharactersInventory.GetCharacterItemAmount(charId, "Bargeld", "inventory") < Price)
         {
             HUDHandler.SendNotification(player, 4, 5000, $"Du hast nicht genügend Bargeld dabei ({Price}$)."); return;
         }
         CharactersInventory.RemoveCharacterItemAmount(charId, "Bargeld", Price, "inventory");
         ServerVehicles.CreateVehicle(fHash, charId, 0, 0, false, 25, ParkOut, RotOut, $"NL{rnd}", 134, 134);
         CharactersInventory.AddCharacterItem(charId, $"Fahrzeugschluessel NL{rnd}", 2, "inventory");
         HUDHandler.SendNotification(player, 2, 5000, $"Fahrzeug erfolgreich gekauft.");
         if (!CharactersTablet.HasCharacterTutorialEntryFinished(charId, "buyVehicle"))
         {
             CharactersTablet.SetCharacterTutorialEntryState(charId, "buyVehicle", true);
             HUDHandler.SendNotification(player, 1, 2500, "Erfolg freigeschaltet: Mobilität");
         }
         stopwatch.Stop();
         if (stopwatch.Elapsed.Milliseconds > 30)
         {
             Alt.Log($"{charId} - BuyVehicle benötigte {stopwatch.Elapsed.Milliseconds}ms");
         }
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
示例#2
0
 public async Task LSPDAppSearchVehiclePlate(IPlayer player, string targetPlate)
 {
     try
     {
         if (player == null || !player.Exists || targetPlate == "")
         {
             return;
         }
         int charId = User.GetPlayerOnline(player);
         if (charId <= 0)
         {
             return;
         }
         if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
         {
             HUDHandler.SendNotification(player, 4, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
         }
         if (!ServerFactions.IsCharacterInAnyFaction(charId))
         {
             HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du bist in keiner Fraktion."); return;
         }
         if (ServerFactions.GetCharacterFactionId(charId) != 2 && ServerFactions.GetCharacterFactionId(charId) != 1)
         {
             HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du bist nicht im L.S.P.D. oder der Justiz angestellt."); return;
         }
         if (!ServerFactions.IsCharacterInFactionDuty(charId))
         {
             HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du bist nicht im Dienst."); return;
         }
         if (!ServerVehicles.ExistServerVehiclePlate(targetPlate))
         {
             HUDHandler.SendNotification(player, 3, 5000, "Fehler: Das angegebene Kennzeichen wurde nicht gefunden."); return;
         }
         int vehicleId = ServerVehicles.GetVehicleIdByPlate(targetPlate);
         if (vehicleId <= 0)
         {
             return;
         }
         int ownerId = ServerVehicles.GetVehicleOwnerById(vehicleId);
         if (ownerId <= 0)
         {
             return;
         }
         string owner      = Characters.GetCharacterName(ownerId);
         string vehName    = ServerVehicles.GetVehicleNameOnHash(ServerVehicles.GetVehicleHashById(vehicleId));
         string manufactor = ServerVehicles.GetVehicleManufactorOnHash(ServerVehicles.GetVehicleHashById(vehicleId));
         string buyDate    = $"{ServerVehicles.GetVehicleBuyDate(vehicleId).ToString("d", CultureInfo.CreateSpecificCulture("de-DE"))}";
         string trunk      = $"{ServerVehicles.GetVehicleTrunkCapacityOnHash(ServerVehicles.GetVehicleHashById(vehicleId))}kg";
         string tax        = $"{ServerAllVehicles.GetVehicleTaxes(ServerVehicles.GetVehicleHashById(vehicleId))}$";
         string maxfuel    = $"{ServerVehicles.GetVehicleFuelLimitOnHash(ServerVehicles.GetVehicleHashById(vehicleId))}";
         string fuelType   = ServerVehicles.GetVehicleFuelTypeOnHash(ServerVehicles.GetVehicleHashById(vehicleId));
         player.EmitLocked("Client:Tablet:SetLSPDAppSearchVehiclePlateData", owner, vehName, manufactor, buyDate, trunk, maxfuel, tax, fuelType);
         HUDHandler.SendNotification(player, 2, 1500, $"Fahrzeugabfrage durchgeführt: {targetPlate}");
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
示例#3
0
        public async Task LicensingAction(IPlayer player, string action, int vehId, string vehPlate, string newPlate)
        {
            try
            {
                if (player == null || !player.Exists || vehId <= 0 || vehPlate == "")
                {
                    return;
                }
                if (action != "anmelden" && action != "abmelden")
                {
                    return;
                }
                int charId = User.GetPlayerOnline(player);
                if (charId <= 0)
                {
                    return;
                }
                IVehicle veh = Alt.Server.GetVehicles().ToList().FirstOrDefault(x => x.GetVehicleId() == (ulong)vehId && x.NumberplateText == vehPlate);
                if (veh == null || !veh.Exists)
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Ein unerwarteter Fehler ist aufgetreten."); return;
                }
                if (ServerVehicles.GetVehicleOwner(veh) != charId)
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Dieses Fahrzeug gehört nicht dir."); return;
                }
                if (!veh.Position.IsInRange(Constants.Positions.VehicleLicensing_VehPosition, 10f))
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Das Fahrzeug ist nicht am Zulassungspunkt (hinterm Rathaus)."); return;
                }
                if (!ServerVehicles.GetVehicleLockState(veh))
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Das Fahrzeug muss zugeschlossen sein."); return;
                }

                if (action == "anmelden")
                {
                    var notAllowedStrings = new[] { "LSPD", "DOJ", "LSFD", "ACLS", "LSF", "FIB", "LSF-", "LSPD-", "DOJ-", "LSFD-", "ACLS-", "FIB-", "NL", "EL-", "MM-", "PL-", "SWAT", "S.W.A.T", "SWAT-", "NOOSE", "N.O.O.S.E" };
                    newPlate = newPlate.Replace(" ", "-");
                    if (ServerVehicles.ExistServerVehiclePlate(newPlate))
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Fehler: Dieses Nummernschild ist bereits vorhanden."); return;
                    }
                    bool stringIsValid = Regex.IsMatch(newPlate, @"[a-zA-Z0-9-]$");
                    bool validPlate    = false;
                    if (stringIsValid)
                    {
                        validPlate = true;
                    }
                    for (var i = 0; i < notAllowedStrings.Length; i++)
                    {
                        if (newPlate.Contains(notAllowedStrings[i]))
                        {
                            validPlate = false; break;
                        }
                    }
                    if (!validPlate)
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Fehler: Das Wunschnummernschild enthält unzulässige Zeichen."); return;
                    }
                    if (!CharactersInventory.ExistCharacterItem(charId, "Bargeld", "inventory"))
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Fehler: Du hast kein Bargeld dabei (250$)."); return;
                    }
                    if (CharactersInventory.GetCharacterItemAmount(charId, "Bargeld", "inventory") < 250)
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Fehler: Du hast nicht genügend Bargeld dabei (250$)."); return;
                    }
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Bargeld", 250, "inventory");
                    CharactersInventory.RenameCharactersItemName($"Fahrzeugschluessel {vehPlate}", $"Fahrzeugschluessel {newPlate}");
                    ServerVehicles.SetServerVehiclePlate(vehId, newPlate);
                    veh.NumberplateText = newPlate;
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast das Kennzeichen von dem Fahrzeug '{ServerVehicles.GetVehicleNameOnHash(veh.Model)}' auf {newPlate} geändert (Gebühr: 250$).");
                    return;
                }
                else if (action == "abmelden")
                {
                    int rnd = new Random().Next(100000, 999999);
                    if (ServerVehicles.ExistServerVehiclePlate($"NL{rnd}"))
                    {
                        LicensingAction(player, "abmelden", vehId, vehPlate, newPlate); return;
                    }
                    CharactersInventory.RenameCharactersItemName($"Fahrzeugschluessel {vehPlate}", $"Fahrzeugschluessel NL{rnd}");
                    ServerVehicles.SetServerVehiclePlate(vehId, $"NL{rnd}");
                    veh.NumberplateText = $"NL{rnd}";
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast das Fahrzeug '{ServerVehicles.GetVehicleNameOnHash(veh.Model)}' mit dem Kennzeichen '{vehPlate}' abgemeldet.");
                    return;
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }