public async Task DepositATMMoney(IPlayer player, int accountNumber, int amount, string zoneName) { if (player == null || !player.Exists || accountNumber == 0 || amount < 1) { return; } int charid = User.GetPlayerOnline(player); if (charid == 0) { return; } if (CharactersBank.GetBankAccountLockStatus(accountNumber)) { HUDHandler.SendNotification(player, 3, 5000, $"Diese EC Karte ist gesperrt und kann nicht weiter benutzt werden."); if (CharactersInventory.ExistCharacterItem(charid, "EC Karte " + accountNumber, "inventory")) { CharactersInventory.RemoveCharacterItemAmount(charid, "EC Karte " + accountNumber, 1, "inventory"); } return; } if (!CharactersInventory.ExistCharacterItem(charid, "Bargeld", "inventory") || CharactersInventory.GetCharacterItemAmount(charid, "Bargeld", "inventory") < amount) { HUDHandler.SendNotification(player, 3, 5000, $"Du hast nicht genug Bargeld in deinem Inventar dabei ({amount}$)."); return; } DateTime dateTime = DateTime.Now; CharactersBank.SetBankAccountMoney(accountNumber, (CharactersBank.GetBankAccountMoney(accountNumber) + amount)); //Geld aufs Konto packen CharactersInventory.RemoveCharacterItemAmount(charid, "Bargeld", amount, "inventory"); //Spieler Geld entfernen ServerBankPapers.CreateNewBankPaper(accountNumber, dateTime.ToString("dd.MM.yyyy"), dateTime.ToString("HH.mm"), "Einzahlung", "None", "None", $"+{amount}$", zoneName); HUDHandler.SendNotification(player, 2, 5000, $"Sie haben {amount}$ auf Ihr Bankkonto eingezahlt."); }
public async Task RentHouse(IPlayer player, int houseId) { try { if (player == null || !player.Exists || houseId <= 0) { return; } int charId = (int)player.GetCharacterMetaId(); if (charId <= 0) { return; } if (!ServerHouses.ExistHouse(houseId)) { return; } if (ServerHouses.GetHouseOwner(houseId) <= 0 || ServerHouses.GetHouseOwner(houseId) == charId) { return; } if (ServerHouses.IsCharacterRentedInAnyHouse(charId)) { HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du bist bereits in einem anderen Haus eingemietet."); return; } if (ServerHouses.IsCharacterRentedInHouse(charId, houseId)) { HUDHandler.SendNotification(player, 4, 5000, "Fehler: In diesem Haus bist du bereits eingemietet."); return; } if (!CharactersBank.HasCharacterBankMainKonto(charId)) { HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du besitzt kein Haupt-Bankkonto."); return; } int accNumber = CharactersBank.GetCharacterBankMainKonto(charId); int ownerBankNumber = CharactersBank.GetCharacterBankMainKonto(ServerHouses.GetHouseOwner(houseId)); int rentPrice = ServerHouses.GetHouseRentPrice(houseId); if (accNumber <= 0 || rentPrice <= 0 || ownerBankNumber <= 0) { return; } if (CharactersBank.GetBankAccountLockStatus(accNumber)) { HUDHandler.SendNotification(player, 4, 5000, "Fehler: Dein Hauptkonto ist gesperrt."); return; } if (CharactersBank.GetBankAccountMoney(accNumber) < rentPrice) { HUDHandler.SendNotification(player, 4, 5000, "Fehler: Dein Hauptkonto ist nicht ausreichend gedeckt."); return; } CharactersBank.SetBankAccountMoney(accNumber, CharactersBank.GetBankAccountMoney(accNumber) - rentPrice); CharactersBank.SetBankAccountMoney(ownerBankNumber, CharactersBank.GetBankAccountMoney(ownerBankNumber) + rentPrice); ServerHouses.AddServerHouseRenter(houseId, charId); ServerBankPapers.CreateNewBankPaper(accNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Ausgehende Überweisung", $"{ownerBankNumber}", "Mietvertrag", $"-{rentPrice}$", "Bankeinzug"); ServerBankPapers.CreateNewBankPaper(ownerBankNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Eingehende Überweisung", $"{accNumber}", "Mietvertrag", $"+{rentPrice}$", "Bankeinzug"); HUDHandler.SendNotification(player, 2, 5000, $"Du hast dich erfolgreich eingemietet, die Miete beträgt {rentPrice}$ täglich welche von deinem Hauptkonto abgezogen werden."); } catch (Exception e) { Alt.Log($"{e}"); } }
public async Task WithdrawATMMoney(IPlayer player, int accountNumber, int amount, string zoneName) { if (player == null || !player.Exists || accountNumber == 0 || amount < 1) { return; } int charid = User.GetPlayerOnline(player); if (charid == 0) { return; } if (CharactersBank.GetBankAccountLockStatus(accountNumber)) { HUDHandler.SendNotification(player, 3, 5000, $"Diese EC Karte ist gesperrt und kann nicht weiter benutzt werden."); if (CharactersInventory.ExistCharacterItem(charid, "EC Karte " + accountNumber, "inventory")) { CharactersInventory.RemoveCharacterItemAmount(charid, "EC Karte " + accountNumber, 1, "inventory"); } return; } if (CharactersBank.GetBankAccountMoney(accountNumber) < amount) { HUDHandler.SendNotification(player, 3, 5000, $"Ihr Konto ist für diese Summe nicht ausreichend gedeckt."); return; } DateTime dateTime = DateTime.Now; CharactersBank.SetBankAccountMoney(accountNumber, (CharactersBank.GetBankAccountMoney(accountNumber) - amount)); //Geld vom Konto abziehen CharactersInventory.AddCharacterItem(charid, "Bargeld", amount, "inventory"); //Spieler Geld geben ServerBankPapers.CreateNewBankPaper(accountNumber, dateTime.ToString("dd.MM.yyyy"), dateTime.ToString("HH.mm"), "Auszahlung", "None", "None", $"-{amount}$", zoneName); HUDHandler.SendNotification(player, 2, 5000, $"Sie haben {amount}$ von Ihrem Bankkonto abgehoben."); }
public async Task RentHotel(IPlayer player, int hotelId, int apartmentId) { try { if (player == null || !player.Exists || hotelId <= 0 || apartmentId <= 0) { return; } int charId = User.GetPlayerOnline(player); if (charId <= 0) { return; } if (!ServerHotels.ExistHotelApartment(hotelId, apartmentId)) { HUDHandler.SendNotification(player, 3, 5000, "Ein unerwarteter Fehler ist aufgetreten [HOTEL-001]."); return; } if (ServerHotels.HasCharacterAnApartment(charId)) { HUDHandler.SendNotification(player, 3, 5000, $"Du besitzt bereits ein Hotelzimmer in dem Hotel '{ServerHotels.GetCharacterRentedHotelName(charId)}'."); return; } if (ServerHotels.GetApartmentOwner(hotelId, apartmentId) > 0) { HUDHandler.SendNotification(player, 3, 5000, "Dieses Apartment ist bereits vermietet."); return; } if (!CharactersBank.HasCharacterBankMainKonto(charId)) { HUDHandler.SendNotification(player, 3, 5000, "Du hast noch kein Hauptkonto in der Bank festgelegt."); return; } int accNumber = CharactersBank.GetCharacterBankMainKonto(charId); if (accNumber <= 0) { return; } if (CharactersBank.GetBankAccountLockStatus(accNumber)) { HUDHandler.SendNotification(player, 3, 5000, "Dein Bankkonto ist gesperrt."); return; } if (CharactersBank.GetBankAccountMoney(accNumber) < ServerHotels.GetApartmentPrice(hotelId, apartmentId)) { HUDHandler.SendNotification(player, 3, 5000, $"Soviel Geld hast du auf deinem Konto nicht ({ServerHotels.GetApartmentPrice(hotelId, apartmentId)}$) - du hast {CharactersBank.GetBankAccountMoney(accNumber)}$"); return; } CharactersBank.SetBankAccountMoney(accNumber, CharactersBank.GetBankAccountMoney(accNumber) - ServerHotels.GetApartmentPrice(hotelId, apartmentId)); ServerBankPapers.CreateNewBankPaper(accNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Ausgehende Überweisung", "Hotelzahlung", $"Zimmerbuchung: {apartmentId}", $"+{ServerHotels.GetApartmentPrice(hotelId, apartmentId)}$", "Bankeinzug"); ServerHotels.SetApartmentOwner(hotelId, apartmentId, charId); HUDHandler.SendNotification(player, 2, 5000, $"Sie haben sich das Zimmer mit der Zimmernummer '{apartmentId}' erfolgreich gemietet (Kosten: {ServerHotels.GetApartmentPrice(hotelId, apartmentId)}$). Dieses Zimmer läuft automatisch nach {ServerHotels.GetApartmentRentHours(hotelId, apartmentId)} Stunden ab."); } catch (Exception e) { Alt.Log($"{e}"); } }
public async Task BuyHouse(IPlayer player, int houseId) { try { if (player == null || houseId <= 0 || !player.Exists) { return; } int charId = User.GetPlayerOnline(player); if (charId <= 0) { return; } if (!ServerHouses.ExistHouse(houseId)) { return; } if (ServerHouses.GetHouseOwner(houseId) > 0) { HUDHandler.SendNotification(player, 3, 5000, "Fehler: Dieses Haus gehört bereits jemanden."); return; } if (!CharactersBank.HasCharacterBankMainKonto(charId)) { HUDHandler.SendNotification(player, 3, 5000, "Du hast noch kein Hauptkonto in der Bank festgelegt."); return; } int accNumber = CharactersBank.GetCharacterBankMainKonto(charId); if (accNumber <= 0) { return; } if (CharactersBank.GetBankAccountLockStatus(accNumber)) { HUDHandler.SendNotification(player, 3, 5000, "Dein Bankkonto ist gesperrt."); return; } if (CharactersBank.GetBankAccountMoney(accNumber) < ServerHouses.GetHousePrice(houseId)) { HUDHandler.SendNotification(player, 3, 5000, $"Soviel Geld hast du auf deinem Konto nicht ({ServerHouses.GetHousePrice(houseId)}$) - du hast {CharactersBank.GetBankAccountMoney(accNumber)}$"); return; } CharactersBank.SetBankAccountMoney(accNumber, CharactersBank.GetBankAccountMoney(accNumber) - ServerHouses.GetHousePrice(houseId)); ServerBankPapers.CreateNewBankPaper(accNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Ausgehende Überweisung", "Dynasty8", $"Hauskauf: {ServerHouses.GetHouseStreet(houseId)}", $"-{ServerHouses.GetHousePrice(houseId)}$", "Bankeinzug"); ServerHouses.SetHouseOwner(houseId, charId); HUDHandler.SendNotification(player, 2, 5000, $"Sie haben sich das Haus mit der Adresse '{ServerHouses.GetHouseStreet(houseId)}' erfolgreich gekauft (Kosten: {ServerHouses.GetHousePrice(houseId)}$)."); } catch (Exception e) { Alt.Log($"{e}"); } }
public async Task SellHouse(IPlayer player, int houseId) { try { if (player == null || !player.Exists || houseId <= 0) { return; } int charId = (int)player.GetCharacterMetaId(); if (charId <= 0) { return; } if (!ServerHouses.ExistHouse(houseId) || ServerHouses.GetHouseOwner(houseId) != charId) { HUDHandler.SendNotification(player, 4, 3500, "Fehler: Dieses Haus gehört nicht dir."); return; } if (!CharactersBank.HasCharacterBankMainKonto(charId)) { HUDHandler.SendNotification(player, 3, 2500, "Du besitzt kein Haupt-Bankkonto"); return; } int accNumber = CharactersBank.GetCharacterBankMainKonto(charId); int housePrice = ServerHouses.GetHousePrice(houseId) / 2; if (!CharactersBank.ExistBankAccountNumber(accNumber)) { return; } ServerHouses.SetHouseLocked(houseId, true); ServerHouses.SetHouseOwner(houseId, 0); CharactersBank.SetBankAccountMoney(accNumber, CharactersBank.GetBankAccountMoney(accNumber) + housePrice); HUDHandler.SendNotification(player, 2, 2500, $"Haus erfolgreich für {housePrice}$ (50% Kaufpreis) verkauft."); ServerBankPapers.CreateNewBankPaper(accNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Eingehende Überweisung", "Immobilienmakler", $"Hausverkauf: {ServerHouses.GetHouseStreet(houseId)}", $"+{housePrice}$", "Online-Banking"); } catch (Exception e) { Alt.Log($"{e}"); } }
public async Task TransferATMMoney(IPlayer player, int accountNumber, int targetNumber, int amount, string zoneName) { if (player == null || !player.Exists || accountNumber == 0 || targetNumber == 0 || amount < 1) { return; } int charid = User.GetPlayerOnline(player); if (charid == 0) { return; } if (CharactersBank.GetBankAccountLockStatus(accountNumber)) { HUDHandler.SendNotification(player, 3, 5000, $"Diese EC Karte ist gesperrt und kann nicht weiter benutzt werden."); if (CharactersInventory.ExistCharacterItem(charid, "EC Karte " + accountNumber, "inventory")) { CharactersInventory.RemoveCharacterItemAmount(charid, "EC Karte " + accountNumber, 1, "inventory"); } return; } if (accountNumber == targetNumber) { HUDHandler.SendNotification(player, 3, 5000, $"Sie können sich selber kein Geld überweisen."); return; } if (CharactersBank.GetBankAccountMoney(accountNumber) < amount) { HUDHandler.SendNotification(player, 3, 5000, $"Ihr Bankkonto ist für diese Transaktion nicht ausreichend gedeckt ({amount}$)."); return; } CharactersBank.SetBankAccountMoney(accountNumber, (CharactersBank.GetBankAccountMoney(accountNumber) - amount)); //Geld vom Konto abziehen CharactersBank.SetBankAccountMoney(targetNumber, (CharactersBank.GetBankAccountMoney(targetNumber) + amount)); //Geld aufs Zielkonto addieren string Date = DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")); string Time = DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")); ServerBankPapers.CreateNewBankPaper(accountNumber, Date, Time, "Ausgehende Überweisung", $"{targetNumber}", "None", $"-{amount}$", zoneName); ServerBankPapers.CreateNewBankPaper(targetNumber, Date, Time, "Eingehende Überweisung", $"{accountNumber}", "None", $"+{amount}$", zoneName); HUDHandler.SendNotification(player, 2, 5000, $"Sie haben erfolgreich {amount}$ an das Konto mit der Kontonummer {targetNumber} überwiesen."); }
private static void PlayerExitVehicle(IVehicle vehicle, IPlayer player, byte seat) { try { if (player == null || vehicle == null || !player.Exists || !vehicle.Exists) { return; } int charId = User.GetPlayerOnline(player); if (charId <= 0) { return; } if (ServerVehicles.GetVehicleType(vehicle) != 2) { return; } if (ServerVehicles.GetVehicleOwner(vehicle) != charId) { return; } if (player.GetPlayerCurrentMinijob() == "None") { return; } if (player.GetPlayerCurrentMinijobStep() == "None") { return; } if (player.GetPlayerCurrentMinijob() != "Pilot") { return; } if (player.GetPlayerCurrentMinijobStep() == "DRIVE_BACK_TO_START" && vehicle.Position.IsInRange(Constants.Positions.Minijob_Pilot_VehOutPos, 10f)) { var model = vehicle.Model; foreach (var veh in Alt.Server.GetVehicles().Where(x => x.NumberplateText == $"PL-{charId}").ToList()) { if (veh == null || !veh.Exists) { continue; } ServerVehicles.RemoveVehiclePermanently(veh); veh.Remove(); } player.SetPlayerCurrentMinijob("None"); player.SetPlayerCurrentMinijobRouteId(0); player.SetPlayerCurrentMinijobStep("None"); player.SetPlayerCurrentMinijobActionCount(0); int rnd = 0; int rndExp = 0; switch (model) { case 2621610858: //Velum rnd = new Random().Next(250, 500); rndExp = new Random().Next(1, 5); break; case 1341619767: //Vestra rnd = new Random().Next(450, 650); rndExp = new Random().Next(3, 8); break; case 2999939664: //Nimbus rnd = new Random().Next(550, 850); rndExp = new Random().Next(5, 11); break; } if (!CharactersBank.HasCharacterBankMainKonto(charId)) { HUDHandler.SendNotification(player, 3, 5000, $"Dein Gehalt i.H.v. {rnd}$ konnte nicht überwiesen werden da du kein Hauptkonto hast."); return; } int accNumber = CharactersBank.GetCharacterBankMainKonto(charId); if (accNumber <= 0) { return; } CharactersMinijobs.IncreaseCharacterMinijobEXP(charId, "Pilot", rndExp); CharactersBank.SetBankAccountMoney(accNumber, CharactersBank.GetBankAccountMoney(accNumber) + rnd); ServerBankPapers.CreateNewBankPaper(accNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Eingehende Überweisung", "San Andreas Flights", "Minijob Gehalt", $"+{rnd}$", "Online Banking"); HUDHandler.SendNotification(player, 2, 5000, $"Du hast den Minijob erfolgreich abgeschlossen. Dein Gehalt i.H.v. {rnd}$ wurde dir auf dein Hauptkonto überwiesen. Du hast {rndExp}EXP dazu bekommen."); player.EmitLocked("Client:Minijob:RemoveJobMarker"); return; } } catch (Exception e) { Alt.Log($"{e}"); } }
private static async void PlayerExitVehicle(IVehicle vehicle, IPlayer player, byte seat) { try { if (player == null || !player.Exists) { return; } if (vehicle == null || !vehicle.Exists) { return; } int charId = User.GetPlayerOnline(player); if (charId <= 0) { return; } if (ServerVehicles.GetVehicleType(vehicle) != 2) { return; } if (ServerVehicles.GetVehicleOwner(vehicle) != charId) { return; } if (player.GetPlayerCurrentMinijob() != "Busfahrer") { return; } if (player.GetPlayerCurrentMinijobStep() != "DRIVE_BACK_TO_START") { return; } if (!vehicle.Position.IsInRange(Constants.Positions.Minijob_Busdriver_VehOutPos, 8f)) { return; } player.EmitLocked("Client:Minijob:RemoveJobMarker"); foreach (var veh in Alt.Server.GetVehicles().Where(x => x.NumberplateText == $"BUS-{charId}").ToList()) { if (veh == null || !veh.Exists) { continue; } ServerVehicles.RemoveVehiclePermanently(veh); await Task.Delay(5000); veh.Remove(); } int givenEXP = Model.GetRouteGivenEXP((int)player.GetPlayerCurrentMinijobRouteId()); int givenMoney = Model.GetRouteGivenMoney((int)player.GetPlayerCurrentMinijobRouteId()); player.SetPlayerCurrentMinijob("None"); player.SetPlayerCurrentMinijobStep("None"); player.SetPlayerCurrentMinijobActionCount(0); player.SetPlayerCurrentMinijobRouteId(0); CharactersMinijobs.IncreaseCharacterMinijobEXP(charId, "Busfahrer", givenEXP); if (!CharactersBank.HasCharacterBankMainKonto(charId)) { HUDHandler.SendNotification(player, 3, 5000, $"Dein Gehalt i.H.v. {givenMoney}$ konnte nicht überwiesen werden da du kein Hauptkonto hast. Du hast aber {givenEXP}EXP erhalten (du hast nun: {CharactersMinijobs.GetCharacterMinijobEXP(charId, "Busfahrer")}EXP)."); return; } int accNumber = CharactersBank.GetCharacterBankMainKonto(charId); if (accNumber <= 0) { return; } CharactersBank.SetBankAccountMoney(accNumber, CharactersBank.GetBankAccountMoney(accNumber) + givenMoney); ServerBankPapers.CreateNewBankPaper(accNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Eingehende Überweisung", "Los Santos Transit", "Minijob Gehalt", $"+{givenMoney}$", "Online Banking"); HUDHandler.SendNotification(player, 2, 5000, $"Du hast den Minijob erfolgreich abgeschlossen. Dein Gehalt i.H.v. {givenMoney}$ wurde dir auf dein Hauptkonto überwiesen. Du hast {givenEXP} erhalten (deine EXP: {CharactersMinijobs.GetCharacterMinijobEXP(charId, "Busfahrer")})"); return; } catch (Exception e) { Alt.Log($"{e}"); } }
public static async void OnEntityTimer(object sender, ElapsedEventArgs e) { try { Console.WriteLine($"Timer - Thread = {Thread.CurrentThread.ManagedThreadId}"); Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); foreach (IVehicle Veh in Alt.Server.GetVehicles().ToList()) { if (Veh == null || !Veh.Exists) { continue; } using (var vRef = new VehicleRef(Veh)) { if (!vRef.Exists) { continue; } lock (Veh) { if (Veh == null || !Veh.Exists) { continue; } ulong vehID = Veh.GetVehicleId(); if (vehID <= 0) { continue; } ServerVehicles.SaveVehiclePositionAndStates(Veh); if (Veh.EngineOn == true) { ServerVehicles.SetVehicleFuel(Veh, ServerVehicles.GetVehicleFuel(Veh) - 0.03f); } } } } stopwatch.Stop(); Alt.Log($"OnEntityTimer: Vehicle Foreach benötigte: {stopwatch.Elapsed}"); stopwatch.Reset(); stopwatch.Start(); foreach (IPlayer player in Alt.Server.GetPlayers().ToList()) { if (player == null) { continue; } using (var playerReference = new PlayerRef(player)) { if (!playerReference.Exists) { return; } if (player == null || !player.Exists) { continue; } lock (player) { if (player == null || !player.Exists) { continue; } int charId = User.GetPlayerOnline(player); if (charId > 0) { Characters.SetCharacterLastPosition(charId, player.Position, player.Dimension); if (User.IsPlayerBanned(player)) { player.kickWithMessage($"Du bist gebannt. (Grund: {User.GetPlayerBanReason(player)})."); } Characters.SetCharacterHealth(charId, player.Health); Characters.SetCharacterArmor(charId, player.Armor); WeatherHandler.SetRealTime(player); if (player.IsInVehicle) { player.EmitLocked("Client:HUD:GetDistanceForVehicleKM"); HUDHandler.SendInformationToVehicleHUD(player); } Characters.IncreaseCharacterPaydayTime(charId); if (Characters.IsCharacterUnconscious(charId)) { int unconsciousTime = Characters.GetCharacterUnconsciousTime(charId); if (unconsciousTime > 0) { Characters.SetCharacterUnconscious(charId, true, unconsciousTime - 1); } else if (unconsciousTime <= 0) { Characters.SetCharacterUnconscious(charId, false, 0); DeathHandler.closeDeathscreen(player); player.Spawn(new Position(355.54285f, -596.33405f, 28.75768f)); player.Health = player.MaxHealth; } } if (Characters.IsCharacterFastFarm(charId)) { int fastFarmTime = Characters.GetCharacterFastFarmTime(charId); if (fastFarmTime > 0) { Characters.SetCharacterFastFarm(charId, true, fastFarmTime - 1); } else if (fastFarmTime <= 0) { Characters.SetCharacterFastFarm(charId, false, 0); } } if (Characters.IsCharacterInJail(charId)) { int jailTime = Characters.GetCharacterJailTime(charId); if (jailTime > 0) { Characters.SetCharacterJailTime(charId, true, jailTime - 1); } else if (jailTime <= 0) { if (CharactersWanteds.HasCharacterWanteds(charId)) { int jailTimes = CharactersWanteds.GetCharacterWantedFinalJailTime(charId); int jailPrice = CharactersWanteds.GetCharacterWantedFinalJailPrice(charId); if (CharactersBank.HasCharacterBankMainKonto(charId)) { int accNumber = CharactersBank.GetCharacterBankMainKonto(charId); int bankMoney = CharactersBank.GetBankAccountMoney(accNumber); CharactersBank.SetBankAccountMoney(accNumber, bankMoney - jailPrice); HUDHandler.SendNotification(player, 1, 7500, $"Durch deine Inhaftierung wurden dir {jailPrice}$ vom Konto abgezogen."); } HUDHandler.SendNotification(player, 1, 7500, $"Du sitzt nun für {jailTimes} Minuten im Gefängnis."); Characters.SetCharacterJailTime(charId, true, jailTimes); CharactersWanteds.RemoveCharacterWanteds(charId); player.Position = new Position(1691.4594f, 2565.7056f, 45.556763f); if (Characters.GetCharacterGender(charId) == false) { player.EmitLocked("Client:SpawnArea:setCharClothes", 11, 5, 0); player.EmitLocked("Client:SpawnArea:setCharClothes", 3, 5, 0); player.EmitLocked("Client:SpawnArea:setCharClothes", 4, 7, 15); player.EmitLocked("Client:SpawnArea:setCharClothes", 6, 7, 0); player.EmitLocked("Client:SpawnArea:setCharClothes", 8, 1, 88); } else { } } else { Characters.SetCharacterJailTime(charId, false, 0); Characters.SetCharacterCorrectClothes(player); player.Position = new Position(1846.022f, 2585.8945f, 45.657f); HUDHandler.SendNotification(player, 1, 2500, "Du wurdest aus dem Gefängnis entlassen."); } } } if (Characters.GetCharacterPaydayTime(charId) >= 60) { Characters.IncreaseCharacterPlayTimeHours(charId); Characters.ResetCharacterPaydayTime(charId); if (CharactersBank.HasCharacterBankMainKonto(charId)) { int accountNumber = CharactersBank.GetCharacterBankMainKonto(charId); CharactersBank.SetBankAccountMoney(accountNumber, CharactersBank.GetBankAccountMoney(accountNumber) + 250); //250$ Stütze ServerBankPapers.CreateNewBankPaper(accountNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Eingehende Überweisung", "Staat", "Arbeitslosengeld", "+250$", "Unbekannt"); if (!Characters.IsCharacterCrimeFlagged(charId) && Characters.GetCharacterJob(charId) != "None" && DateTime.Now.Subtract(Convert.ToDateTime(Characters.GetCharacterLastJobPaycheck(charId))).TotalHours >= 12 && !ServerFactions.IsCharacterInAnyFaction(charId)) { if (Characters.GetCharacterJobHourCounter(charId) >= ServerJobs.GetJobNeededHours(Characters.GetCharacterJob(charId)) - 1) { int jobCheck = ServerJobs.GetJobPaycheck(Characters.GetCharacterJob(charId)); Characters.SetCharacterLastJobPaycheck(charId, DateTime.Now); Characters.ResetCharacterJobHourCounter(charId); CharactersBank.SetBankAccountMoney(accountNumber, CharactersBank.GetBankAccountMoney(accountNumber) + jobCheck); ServerBankPapers.CreateNewBankPaper(accountNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Eingehende Überweisung", "Arbeitsamt", $"Gehalt: {Characters.GetCharacterJob(charId)}", $"+{jobCheck}$", "Unbekannt"); HUDHandler.SendNotification(player, 1, 5000, $"Gehalt erhalten (Beruf: {Characters.GetCharacterJob(charId)} | Gehalt: {jobCheck}$)"); } else { Characters.IncreaseCharacterJobHourCounter(charId); } } if (ServerFactions.IsCharacterInAnyFaction(charId) && ServerFactions.IsCharacterInFactionDuty(charId)) { int factionid = ServerFactions.GetCharacterFactionId(charId); int factionPayCheck = ServerFactions.GetFactionRankPaycheck(factionid, ServerFactions.GetCharacterFactionRank(charId)); if (ServerFactions.GetFactionBankMoney(factionid) >= factionPayCheck) { ServerFactions.SetFactionBankMoney(factionid, ServerFactions.GetFactionBankMoney(factionid) - factionPayCheck); CharactersBank.SetBankAccountMoney(accountNumber, CharactersBank.GetBankAccountMoney(accountNumber) + factionPayCheck); HUDHandler.SendNotification(player, 1, 5000, $"Du hast deinen Lohn i.H.v. {factionPayCheck}$ erhalten ({ServerFactions.GetFactionRankName(factionid, ServerFactions.GetCharacterFactionRank(charId))})"); ServerBankPapers.CreateNewBankPaper(accountNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Eingehende Überweisung", $"{ServerFactions.GetFactionFullName(factionid)}", $"Gehalt: {ServerFactions.GetFactionRankName(factionid, ServerFactions.GetCharacterFactionRank(charId))}", $"+{factionPayCheck}$", "Dauerauftrag"); LoggingService.NewFactionLog(factionid, charId, 0, "paycheck", $"{Characters.GetCharacterName(charId)} hat seinen Lohn i.H.v. {factionPayCheck}$ erhalten ({ServerFactions.GetFactionRankName(factionid, ServerFactions.GetCharacterFactionRank(charId))})."); } else { HUDHandler.SendNotification(player, 3, 5000, $"Deine Fraktion hat nicht genügend Geld um dich zu bezahlen ({factionPayCheck}$)."); } } var playerVehicles = ServerVehicles.ServerVehicles_.Where(x => x.id > 0 && x.charid == charId && x.plate.Contains("NL")); int taxMoney = 0; foreach (var i in playerVehicles) { if (!i.plate.Contains("NL")) { continue; } taxMoney += ServerAllVehicles.GetVehicleTaxes(i.hash); } if (playerVehicles != null && taxMoney > 0) { if (CharactersBank.GetBankAccountMoney(accountNumber) < taxMoney) { HUDHandler.SendNotification(player, 3, 5000, $"Deine Fahrzeugsteuern konnten nicht abgebucht werden ({taxMoney}$)"); } else { CharactersBank.SetBankAccountMoney(accountNumber, CharactersBank.GetBankAccountMoney(accountNumber) - taxMoney); ServerBankPapers.CreateNewBankPaper(accountNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Ausgehende Überweisung", "Zulassungsamt", $"Fahrzeugsteuer", $"-{taxMoney}$", "Bankeinzug"); HUDHandler.SendNotification(player, 1, 5000, $"Du hast deine Fahrzeugsteuern i.H.v. {taxMoney}$ bezahlt."); } } } else { HUDHandler.SendNotification(player, 3, 5000, $"Dein Einkommen konnte nicht überwiesen werden da du kein Hauptkonto hast."); } } } } } } stopwatch.Stop(); Alt.Log($"OnEntityTimer: Player Foreach benötigte: {stopwatch.Elapsed}"); } catch (Exception ex) { Alt.Log($"{ex}"); } }
public async Task GiveLicense(IPlayer player, int targetCharId, string licShort) { try { if (player == null || !player.Exists || targetCharId <= 0 || licShort == "") { return; } int charId = User.GetPlayerOnline(player); if (charId <= 0) { return; } if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs()) { HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das gefesselt machen?"); return; } if (!ServerFactions.IsCharacterInAnyFaction(charId)) { HUDHandler.SendNotification(player, 3, 5000, "Du bist in keiner Fraktion."); return; } if (!ServerFactions.IsCharacterInFactionDuty(charId)) { HUDHandler.SendNotification(player, 3, 5000, "Du bist nicht im Dienst."); return; } if (ServerFactions.GetCharacterFactionId(charId) != 5) { HUDHandler.SendNotification(player, 3, 5000, "Du bist kein Angehöriger der Fahrschule."); return; } var targetPlayer = Alt.Server.GetPlayers().ToList().FirstOrDefault(x => x.GetCharacterMetaId() == (ulong)targetCharId); if (targetPlayer == null || !targetPlayer.Exists) { return; } if (targetCharId != (int)targetPlayer.GetCharacterMetaId()) { return; } if (!player.Position.IsInRange(targetPlayer.Position, 5f)) { HUDHandler.SendNotification(player, 3, 5000, "Du bist zu weit entfernt."); return; } if (!CharactersLicenses.ExistServerLicense(licShort)) { HUDHandler.SendNotification(player, 3, 5000, "Ein unerwarteter Fehler ist aufgetreten."); return; } if (CharactersLicenses.HasCharacterLicense(targetCharId, licShort)) { HUDHandler.SendNotification(player, 3, 5000, "Der Spieler hat diese Lizenz bereits."); return; } if (!CharactersBank.HasCharacterBankMainKonto(targetCharId)) { HUDHandler.SendNotification(player, 3, 5000, "Der Spieler besitzt kein Hauptkonto."); return; } int accNumber = CharactersBank.GetCharacterBankMainKonto(targetCharId); int licPrice = CharactersLicenses.GetLicensePrice(licShort); if (CharactersBank.GetBankAccountLockStatus(accNumber)) { HUDHandler.SendNotification(player, 3, 5000, "Das Hauptkonto des Spielers ist gesperrt."); return; } CharactersBank.SetBankAccountMoney(accNumber, CharactersBank.GetBankAccountMoney(accNumber) - licPrice); ServerBankPapers.CreateNewBankPaper(accNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Ausgehende Überweisung", "Fahrschule", $"Lizenzkauf: {CharactersLicenses.GetFullLicenseName(licShort)}", $"-{licPrice}$", "Bankeinzug"); CharactersLicenses.SetCharacterLicense(targetCharId, licShort, true); ServerFactions.SetFactionBankMoney(5, ServerFactions.GetFactionBankMoney(5) + licPrice); HUDHandler.SendNotification(player, 2, 2000, $"Sie haben dem Spieler {Characters.GetCharacterName(targetCharId)} die Lizenz '{CharactersLicenses.GetFullLicenseName(licShort)}' für eine Gebühr i.H.v. {licPrice}$ ausgestellt."); HUDHandler.SendNotification(targetPlayer, 2, 2000, $"Ihnen wurde die Lizenz '{CharactersLicenses.GetFullLicenseName(licShort)}' für eine Gebühr i.H.v. {licPrice}$ ausgestellt, diese wurde von Ihrem Hauptkonto abgebucht."); } catch (Exception e) { Alt.Log($"{e}"); } }
private static async void PlayerExitVehicle(IVehicle vehicle, IPlayer player, byte seat) { try { if (player == null || !player.Exists) { return; } if (vehicle == null || !vehicle.Exists) { return; } int charId = User.GetPlayerOnline(player); if (charId <= 0) { return; } if (ServerVehicles.GetVehicleType(vehicle) != 2) { return; } if (ServerVehicles.GetVehicleOwner(vehicle) != charId) { return; } if (player.GetPlayerCurrentMinijob() != "Müllmann") { return; } if (player.GetPlayerCurrentMinijobStep() != "DRIVE_BACK_TO_START") { return; } if (!vehicle.Position.IsInRange(Constants.Positions.Minijob_Müllmann_VehOutPos, 8f)) { return; } player.EmitLocked("Client:Minijob:RemoveJobMarker"); foreach (var veh in Alt.Server.GetVehicles().Where(x => x.NumberplateText == $"MM-{charId}").ToList()) { if (veh == null || !veh.Exists) { continue; } ServerVehicles.RemoveVehiclePermanently(veh); await Task.Delay(5000); veh.Remove(); } player.SetPlayerCurrentMinijob("None"); player.SetPlayerCurrentMinijobStep("None"); player.SetPlayerCurrentMinijobActionCount(0); player.SetPlayerCurrentMinijobRouteId(0); int rnd = new Random().Next(500, 850); if (!CharactersBank.HasCharacterBankMainKonto(charId)) { HUDHandler.SendNotification(player, 3, 5000, $"Dein Gehalt i.H.v. {rnd}$ konnte nicht überwiesen werden da du kein Hauptkonto hast."); return; } int accNumber = CharactersBank.GetCharacterBankMainKonto(charId); if (accNumber <= 0) { return; } CharactersBank.SetBankAccountMoney(accNumber, CharactersBank.GetBankAccountMoney(accNumber) + rnd); ServerBankPapers.CreateNewBankPaper(accNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Eingehende Überweisung", "Arbeitgeber: Müllmann", "Minijob Gehalt", $"+{rnd}$", "Online Banking"); HUDHandler.SendNotification(player, 2, 5000, $"Du hast den Minijob erfolgreich abgeschlossen. Dein Gehalt i.H.v. {rnd}$ wurde dir auf dein Hauptkonto überwiesen."); return; } catch (Exception e) { Alt.Log($"{e}"); } }
private static async void PlayerExitVehicle(IVehicle vehicle, IPlayer player, byte seat) { try { if (player == null || vehicle == null || !player.Exists || !vehicle.Exists) { return; } int charId = User.GetPlayerOnline(player); if (charId <= 0) { return; } if (ServerVehicles.GetVehicleType(vehicle) != 2) { return; } if (ServerVehicles.GetVehicleOwner(vehicle) != charId) { return; } if (player.GetPlayerCurrentMinijob() == "None") { return; } if (player.GetPlayerCurrentMinijobStep() == "None") { return; } if (player.GetPlayerCurrentMinijob() == "Elektrolieferant" && player.GetPlayerCurrentMinijobStep() == "DELIVER_TO_DESTINATION") { if (player.GetPlayerCurrentMinijobActionCount() == 1 && vehicle.Position.IsInRange(new Position(MinijobSpots_[0].pos.X, MinijobSpots_[0].pos.Y, MinijobSpots_[0].pos.Z), 5f)) { player.EmitLocked("Client:Minijob:RemoveJobMarker"); player.EmitLocked("Client:Minijob:CreateJobMarker", "Diamond Casino", 3, 514, 1, MinijobSpots_[0].depositPos.X, MinijobSpots_[0].depositPos.Y, MinijobSpots_[0].depositPos.Z - 1, false); HUDHandler.SendNotification(player, 1, 5000, "Begebe dich zur Tür und gebe das Paket ab."); return; } else if (player.GetPlayerCurrentMinijobActionCount() == 2 && vehicle.Position.IsInRange(new Position(MinijobSpots_[1].pos.X, MinijobSpots_[1].pos.Y, MinijobSpots_[1].pos.Z), 5f)) { player.EmitLocked("Client:Minijob:RemoveJobMarker"); player.EmitLocked("Client:Minijob:CreateJobMarker", "Lifeinvader", 3, 514, 1, MinijobSpots_[1].depositPos.X, MinijobSpots_[1].depositPos.Y, MinijobSpots_[1].depositPos.Z - 1, false); HUDHandler.SendNotification(player, 1, 5000, "Begebe dich zur Tür und gebe das Paket ab."); return; } else if (player.GetPlayerCurrentMinijobActionCount() == 3 && vehicle.Position.IsInRange(new Position(MinijobSpots_[2].pos.X, MinijobSpots_[2].pos.Y, MinijobSpots_[2].pos.Z), 5f)) { player.EmitLocked("Client:Minijob:RemoveJobMarker"); player.EmitLocked("Client:Minijob:CreateJobMarker", "Weazel News", 3, 514, 1, MinijobSpots_[2].depositPos.X, MinijobSpots_[2].depositPos.Y, MinijobSpots_[2].depositPos.Z - 1, false); HUDHandler.SendNotification(player, 1, 5000, "Begebe dich zur Tür und gebe das Paket ab."); return; } else if (player.GetPlayerCurrentMinijobActionCount() == 4 && vehicle.Position.IsInRange(new Position(MinijobSpots_[3].pos.X, MinijobSpots_[3].pos.Y, MinijobSpots_[3].pos.Z), 5f)) { player.EmitLocked("Client:Minijob:RemoveJobMarker"); player.EmitLocked("Client:Minijob:CreateJobMarker", "Maze Bank", 3, 514, 1, MinijobSpots_[3].depositPos.X, MinijobSpots_[3].depositPos.Y, MinijobSpots_[3].depositPos.Z - 1, false); HUDHandler.SendNotification(player, 1, 5000, "Begebe dich zur Tür und gebe das Paket ab."); return; } else if (player.GetPlayerCurrentMinijobActionCount() == 5 && vehicle.Position.IsInRange(new Position(MinijobSpots_[4].pos.X, MinijobSpots_[4].pos.Y, MinijobSpots_[4].pos.Z), 5f)) { player.EmitLocked("Client:Minijob:RemoveJobMarker"); player.EmitLocked("Client:Minijob:CreateJobMarker", "Crastenburg Hotel", 3, 514, 1, MinijobSpots_[4].depositPos.X, MinijobSpots_[4].depositPos.Y, MinijobSpots_[4].depositPos.Z - 1, false); HUDHandler.SendNotification(player, 1, 5000, "Begebe dich zur Tür und gebe das Paket ab."); return; } else if (player.GetPlayerCurrentMinijobActionCount() == 6 && vehicle.Position.IsInRange(new Position(MinijobSpots_[5].pos.X, MinijobSpots_[5].pos.Y, MinijobSpots_[5].pos.Z), 5f)) { player.EmitLocked("Client:Minijob:RemoveJobMarker"); player.EmitLocked("Client:Minijob:CreateJobMarker", "Glass Heroes", 3, 514, 1, MinijobSpots_[5].depositPos.X, MinijobSpots_[5].depositPos.Y, MinijobSpots_[5].depositPos.Z - 1, false); HUDHandler.SendNotification(player, 1, 5000, "Begebe dich zur Tür und gebe das Paket ab."); return; } } else if (player.GetPlayerCurrentMinijob() == "Elektrolieferant" && player.GetPlayerCurrentMinijobStep() == "DRIVE_BACK_TO_START" && vehicle.Position.IsInRange(Constants.Positions.Minijob_Elektrolieferant_VehOutPos, 8f)) { player.EmitLocked("Client:Minijob:RemoveJobMarker"); foreach (var veh in Alt.Server.GetVehicles().Where(x => x.NumberplateText == $"EL-{charId}").ToList()) { if (veh == null || !veh.Exists) { continue; } ServerVehicles.RemoveVehiclePermanently(veh); veh.Remove(); } player.SetPlayerCurrentMinijob("None"); player.SetPlayerCurrentMinijobStep("None"); player.SetPlayerCurrentMinijobActionCount(0); int rnd = new Random().Next(500, 750); if (!CharactersBank.HasCharacterBankMainKonto(charId)) { HUDHandler.SendNotification(player, 3, 5000, $"Dein Gehalt i.H.v. {rnd}$ konnte nicht überwiesen werden da du kein Hauptkonto hast."); return; } int accNumber = CharactersBank.GetCharacterBankMainKonto(charId); if (accNumber <= 0) { return; } CharactersBank.SetBankAccountMoney(accNumber, CharactersBank.GetBankAccountMoney(accNumber) + rnd); ServerBankPapers.CreateNewBankPaper(accNumber, DateTime.Now.ToString("d", CultureInfo.CreateSpecificCulture("de-DE")), DateTime.Now.ToString("t", CultureInfo.CreateSpecificCulture("de-DE")), "Eingehende Überweisung", "Department of Water and Power", "Minijob Gehalt", $"+{rnd}$", "Online Banking"); HUDHandler.SendNotification(player, 2, 5000, $"Du hast den Minijob erfolgreich abgeschlossen. Dein Gehalt i.H.v. {rnd}$ wurde dir auf dein Hauptkonto überwiesen."); return; } } catch (Exception e) { Alt.Log($"{e}"); } }