public static async Task RequestInventoryItems(IPlayer player) { try { Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); if (player == null || !player.Exists) { return; } int charId = User.GetPlayerOnline(player); if (charId <= 0) { return; } if (!CharactersTablet.HasCharacterTutorialEntryFinished(charId, "openInventory")) { CharactersTablet.SetCharacterTutorialEntryState(charId, "openInventory", true); HUDHandler.SendNotification(player, 1, 5000, "Erfolg freigeschaltet: Inventar öffnen."); } string invArray = CharactersInventory.GetCharacterInventory(User.GetPlayerOnline(player)); player.EmitLocked("Client:Inventory:AddInventoryItems", invArray, Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(User.GetPlayerOnline(player))), 0); if (stopwatch.Elapsed.Milliseconds > 30) { Alt.Log($"{charId} - Inventaraufruf benötigte {stopwatch.Elapsed.Milliseconds}ms"); } } catch (Exception e) { Alt.Log($"{e}"); } }
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}"); } }
public async Task SelectJobcenterJob(IPlayer player, string jobName) { try { if (player == null || !player.Exists || jobName == "" || jobName == "undefined") { return; } int charId = User.GetPlayerOnline(player); if (charId == 0) { return; } if (jobName == "None") { HUDHandler.SendNotification(player, 2, 5000, $"Du hast deinen Job als {Characters.GetCharacterJob(charId)} gekündigt."); Characters.SetCharacterLastJobPaycheck(charId, DateTime.Now); Characters.SetCharacterJob(charId, "None"); return; } Characters.SetCharacterJob(charId, jobName); Characters.SetCharacterLastJobPaycheck(charId, DateTime.Now); Characters.ResetCharacterJobHourCounter(charId); HUDHandler.SendNotification(player, 2, 5000, $"Du hast den Vertrag für den Beruf '{jobName}' unterschrieben. Dein Gehalt liegt bei {ServerJobs.GetJobPaycheck(jobName)}$. Du musst täglich {ServerJobs.GetJobNeededHours(jobName)} Stunden anwesend sein."); if (!CharactersTablet.HasCharacterTutorialEntryFinished(charId, "acceptJob")) { CharactersTablet.SetCharacterTutorialEntryState(charId, "acceptJob", true); HUDHandler.SendNotification(player, 1, 2500, "Erfolg freigeschaltet: Die Tür vom Arbeitsamt"); } } catch (Exception e) { Alt.Log($"{e}"); } }
public async Task CreateNewBankAccount(IPlayer player, string zoneName) { if (player == null || !player.Exists || zoneName == "") { return; } if (CharactersBank.GetCharacterBankAccountCount(player) >= 2) { HUDHandler.SendNotification(player, 4, 5000, "Du kannst nur zwei Bankkonten gleichzeitig haben."); return; } int rndAccNumber = new Random().Next(1000000, 999999999); int rndPin = new Random().Next(0000, 9999); int charid = User.GetPlayerOnline(player); if (charid == 0) { return; } if (CharactersBank.ExistBankAccountNumber(rndAccNumber)) { HUDHandler.SendNotification(player, 3, 5000, "Es ist ein Fehler aufgetreten. Bitte versuchen Sie es erneut."); return; } CharactersBank.CreateBankAccount(charid, rndAccNumber, rndPin, zoneName); HUDHandler.SendNotification(player, 2, 5000, $"Sie haben erfolgreich ein Konto erstellt. Ihre Kontonummer lautet ({rndAccNumber}) - ihr PIN: ({rndPin})."); CharactersInventory.AddCharacterItem(charid, "EC Karte " + rndAccNumber, 1, "inventory"); if (!CharactersTablet.HasCharacterTutorialEntryFinished(charid, "createBankAccount")) { CharactersTablet.SetCharacterTutorialEntryState(charid, "createBankAccount", true); HUDHandler.SendNotification(player, 1, 2500, "Erfolg freigeschaltet: Dein erstes Konto"); } }
public async Task DoGarageAction(IPlayer player, int garageid, string action, int vehID) { try { if (player == null || !player.Exists || action == "" || vehID <= 0 || garageid <= 0) { return; } Stopwatch stopwatch = new Stopwatch(); stopwatch.Start(); int charId = User.GetPlayerOnline(player); if (charId <= 0) { return; } var vehicle = Alt.Server.GetVehicles().ToList().FirstOrDefault(x => x.GetVehicleId() == (ulong)vehID); if (action == "storage") { //Fahrzeug einparken if (vehicle == null) { return; } if (!vehicle.Position.IsInRange(player.Position, 50f)) { return; } //var gData = ServerGarages.ServerGarageSlots_.FirstOrDefault(x => vehicle.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 15f) && x.garageId == garageid); //Position garagePos = new Position(gData.posX, gData.posY, gData.posZ); //Alt.Log($"StorageVeh: {gData} - {gData.garageId} - {garagePos} - {garagePos.ToString()}"); //if (garagePos == null || garagePos == new Position(0, 0, 0)) return; ServerVehicles.SetVehicleInGarage(vehicle, true, garageid); HUDHandler.SendNotification(player, 2, 5000, $"Fahrzeug erfolgreich eingeparkt."); } else if (action == "take") { //Fahrzeug ausparken Position outPos = new Position(0, 0, 0); int curPid = 1; bool slotAreFree = true; foreach (var x in ServerGarages.ServerGarageSlots_.Where(x => x.garageId == garageid)) { foreach (var veh in Alt.Server.GetVehicles().ToList()) { if (veh.Position.IsInRange(ServerGarages.GetGarageSlotPosition(garageid, curPid), 2f)) { slotAreFree = false; curPid++; break; } else { slotAreFree = true; } } if (slotAreFree) { break; } } if (!slotAreFree) { HUDHandler.SendNotification(player, 4, 5000, $"Es ist kein Parkplatz mehr frei."); return; } if (vehicle != null) { HUDHandler.SendNotification(player, 4, 5000, $"Ein unerwarteter Fehler ist aufgetreten. [GARAGE-002]"); return; } var finalVeh = ServerVehicles.ServerVehicles_.FirstOrDefault(v => v.id == vehID); if (finalVeh == null) { HUDHandler.SendNotification(player, 4, 5000, $"Ein unerwarteter Fehler ist aufgetreten. [GARAGE-001]"); return; } var altVeh = await AltAsync.Do(() => Alt.CreateVehicle((uint)finalVeh.hash, ServerGarages.GetGarageSlotPosition(garageid, curPid), (ServerGarages.GetGarageSlotRotation(garageid, curPid)))); altVeh.LockState = VehicleLockState.Locked; altVeh.EngineOn = false; altVeh.NumberplateText = finalVeh.plate; altVeh.SetVehicleId((ulong)finalVeh.id); altVeh.SetVehicleTrunkState(false); ServerVehicles.SetVehicleModsCorrectly(altVeh); ServerVehicles.SetVehicleInGarage(altVeh, false, garageid); } if (!CharactersTablet.HasCharacterTutorialEntryFinished(charId, "useGarage")) { CharactersTablet.SetCharacterTutorialEntryState(charId, "useGarage", true); HUDHandler.SendNotification(player, 1, 2500, "Erfolg freigeschaltet: Keine Schäden"); } stopwatch.Stop(); if (stopwatch.Elapsed.Milliseconds > 30) { Alt.Log($"{charId} - DoGarageAction benötigte {stopwatch.Elapsed.Milliseconds}ms"); } } catch (Exception e) { Alt.Log($"{e}"); } }