Exemple #1
0
        private async void StreamSocketListener_ConnectionReceived(Windows.Networking.Sockets.StreamSocketListener sender, Windows.Networking.Sockets.StreamSocketListenerConnectionReceivedEventArgs args)
        {
            string request;

            using (var streamReader = new StreamReader(args.Socket.InputStream.AsStreamForRead()))
            {
                request = await streamReader.ReadLineAsync();
            }
            await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                CoreDispatcherPriority.Normal, () =>
                ServerItems.Add(string.Format("server received the request: \"{0}\"", request)));

            // Echo the request back as the response.
            using (Stream outputStream = args.Socket.OutputStream.AsStreamForWrite())
            {
                using (var streamWriter = new StreamWriter(outputStream))
                {
                    await streamWriter.WriteLineAsync(request);

                    await streamWriter.FlushAsync();
                }
            }

            await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                CoreDispatcherPriority.Normal, () =>
                ServerItems.Add(string.Format("server sent back the response: \"{0}\"", request)));

            sender.Dispose();

            await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                CoreDispatcherPriority.Normal, () =>
                ServerItems.Add("server closed its socket"));

            //RaisePropertyChanged("ServerItems");
        }
Exemple #2
0
        private async void StartServer()
        {
            try
            {
                var streamSocketListener = new StreamSocketListener();

                // The ConnectionReceived event is raised when connections are received.
                streamSocketListener.ConnectionReceived += this.StreamSocketListener_ConnectionReceived;

                // Start listening for incoming TCP connections on the specified port. You can specify any port that's not currently in use.
                await streamSocketListener.BindServiceNameAsync(PortNumber);

                await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                    CoreDispatcherPriority.Normal, () =>
                    ServerItems.Add("server is listening..."));
            }
            catch (Exception ex)
            {
                Windows.Networking.Sockets.SocketErrorStatus webErrorStatus = Windows.Networking.Sockets.SocketError.GetStatus(ex.GetBaseException().HResult);
                await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(
                    CoreDispatcherPriority.Normal, () =>
                    ServerItems.Add(webErrorStatus.ToString() != "Unknown" ? webErrorStatus.ToString() : ex.Message));
            }
            //RaisePropertyChanged("ServerItems");
        }
Exemple #3
0
 public async Task StorageItem(IPlayer player, int houseId, string itemName, int itemAmount, string fromContainer)
 {
     try
     {
         if (player == null || !player.Exists || houseId <= 0 || itemName == "" || itemName == "undefined" || itemAmount <= 0 || fromContainer == "none" || fromContainer == "")
         {
             return;
         }
         int charId = (int)player.GetCharacterMetaId();
         if (charId <= 0)
         {
             return;
         }
         if (!ServerHouses.ExistHouse(houseId))
         {
             return;
         }
         if (!ServerHouses.HasHouseStorageUpgrade(houseId))
         {
             HUDHandler.SendNotification(player, 4, 5000, "Dieses Haus besitzt noch keinen ausgebauten Lagerplatz."); return;
         }
         if (player.Dimension - 10000 <= 0 || player.Dimension - 10000 != houseId)
         {
             return;
         }
         if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
         {
             HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
         }
         if (!CharactersInventory.ExistCharacterItem(charId, itemName, fromContainer))
         {
             HUDHandler.SendNotification(player, 4, 5000, "Fehler: Diesen Gegenstand besitzt du nicht."); return;
         }
         if (CharactersInventory.GetCharacterItemAmount(charId, itemName, fromContainer) < itemAmount)
         {
             HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du hast nicht genügend Gegenstände davon dabei."); return;
         }
         if (CharactersInventory.IsItemActive(player, itemName))
         {
             HUDHandler.SendNotification(player, 4, 5000, "Fehler: Ausgerüstete Gegenstände können nicht umgelagert werden."); return;
         }
         float storageLimit = ServerHouses.GetInteriorStorageLimit(ServerHouses.GetHouseInteriorId(houseId));
         float itemWeight   = ServerItems.GetItemWeight(itemName) * itemAmount;
         if (ServerHouses.GetHouseStorageItemWeight(houseId) >= storageLimit || (ServerHouses.GetHouseStorageItemWeight(houseId) + itemWeight >= storageLimit))
         {
             HUDHandler.SendNotification(player, 3, 5000, $"Fehler: Soviel passt in das Hauslager nicht rein (maximal {storageLimit}kg Lagerplatz).");
             return;
         }
         CharactersInventory.RemoveCharacterItemAmount(charId, itemName, itemAmount, fromContainer);
         ServerHouses.AddServerHouseStorageItem(houseId, itemName, itemAmount);
         HUDHandler.SendNotification(player, 2, 5000, $"Der Gegenstand wurde erfolgreich eingelagert ({itemName} - {itemAmount}x).");
         //ToDo: Log Eintrag
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
 public async void StopServer()
 {
     CloseServerConnection();
     streamSocketListener?.Dispose();
     serverIsRunning = false;
     await CoreApplication.MainView.CoreWindow.
     Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                         () => ServerItems.Add("server closed its socket"));
 }
Exemple #5
0
        public async Task switchItemToDifferentInv(ClassicPlayer player, string itemname, int itemAmount, string fromContainer, string toContainer)
        {
            try
            {
                if (player == null || !player.Exists || itemname == "" || itemAmount <= 0 || fromContainer == "" || toContainer == "" || User.GetPlayerOnline(player) == 0)
                {
                    return;
                }
                if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                }
                int    charId         = player.CharacterId;
                string normalName     = ServerItems.ReturnNormalItemName(itemname);
                float  itemWeight     = ServerItems.GetItemWeight(itemname) * itemAmount;
                float  invWeight      = CharactersInventory.GetCharacterItemWeight(charId, "inventory");
                float  backpackWeight = CharactersInventory.GetCharacterItemWeight(charId, "backpack");
                if (!CharactersInventory.ExistCharacterItem(charId, itemname, fromContainer))
                {
                    return;
                }

                if (toContainer == "inventory")
                {
                    if (invWeight + itemWeight > 15f)
                    {
                        HUDHandler.SendNotification(player, 3, 5000, $"Soviel Platz hast du im Inventar nicht."); return;
                    }
                }
                else if (toContainer == "backpack")
                {
                    if (backpackWeight + itemWeight > Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
                    {
                        HUDHandler.SendNotification(player, 3, 5000, $"Soviel Platz hast du in deinen Taschen / deinem Rucksack nicht."); return;
                    }
                }

                if (CharactersInventory.GetCharacterItemAmount(charId, itemname, fromContainer) < itemAmount)
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Die angegebene Item-Anzahl ist größer als die Anzahl der Items die du mit dir trägst."); return;
                }
                if (itemname == "Rucksack" || itemname == "Tasche" || normalName == "Ausweis" || normalName == "Bargeld" || normalName == "Smartphone" || normalName == "EC Karte" || normalName == "Fahrzeugschluessel")
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Diesen Gegenstand kannst du nicht in deinen Rucksack / deine Tache legen."); return;
                }
                CharactersInventory.RemoveCharacterItemAmount(charId, itemname, itemAmount, fromContainer);
                CharactersInventory.AddCharacterItem(charId, itemname, itemAmount, toContainer);
                HUDHandler.SendNotification(player, 2, 5000, $"Der Gegenstand {itemname} ({itemAmount}x) wurde erfolgreich vom ({fromContainer}) in ({toContainer}) verschoben.");
                RequestInventoryItems(player);
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Exemple #6
0
        public async Task TakeHotelItem(IPlayer player, int apartmentId, string itemName, int itemAmount)
        {
            try
            {
                if (player == null || !player.Exists || apartmentId <= 0 | itemAmount <= 0 || itemName == "" || itemName == "undefined")
                {
                    return;
                }
                int charId = User.GetPlayerOnline(player);
                if (charId <= 0)
                {
                    return;
                }
                if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                }
                if (!ServerHotels.ExistServerHotelStorageItem(apartmentId, itemName))
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Der Gegenstand existiert im Lager nicht."); return;
                }
                if (ServerHotels.GetServerHotelStorageItemAmount(apartmentId, itemName) < itemAmount)
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Soviele Gegenstände sind nicht im Lager."); return;
                }
                float itemWeight     = ServerItems.GetItemWeight(itemName) * itemAmount;
                float invWeight      = CharactersInventory.GetCharacterItemWeight(charId, "inventory");
                float backpackWeight = CharactersInventory.GetCharacterItemWeight(charId, "backpack");
                if (invWeight + itemWeight > 15f && backpackWeight + itemWeight > Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
                {
                    HUDHandler.SendNotification(player, 3, 5000, $"Du hast nicht genug Platz in deinen Taschen."); return;
                }
                ServerHotels.RemoveServerHotelStorageItemAmount(apartmentId, itemName, itemAmount);
                //LoggingService.NewFactionLog(factionId, charId, 0, "storage", $"{Characters.GetCharacterName(charId)} ({charId}) hat den Gegenstand '{itemName} ({amount}x)' aus seinem Spind entnommen."); // ToDo: Hotel Log
                if (invWeight + itemWeight <= 15f)
                {
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast {itemName} ({itemAmount}x) aus deinem Lager genommen (Lagerort: Inventar).");
                    CharactersInventory.AddCharacterItem(charId, itemName, itemAmount, "inventory");
                    return;
                }

                if (Characters.GetCharacterBackpack(charId) != "None" && backpackWeight + itemWeight <= Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
                {
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast {itemName} ({itemAmount}x) aus deinem Lager genommen (Lagerort: Rucksack / Tasche).");
                    CharactersInventory.AddCharacterItem(charId, itemName, itemAmount, "backpack");
                    return;
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Exemple #7
0
        internal static async void FarmFieldAction(IPlayer player, string itemName, int itemMinAmount, int itemMaxAmount, string animation, int duration)
        {
            if (player == null || !player.Exists || itemName == "" || itemMinAmount == 0 || itemMaxAmount == 0 || animation == "")
            {
                return;
            }
            int charId = User.GetPlayerOnline(player);

            if (charId <= 0)
            {
                return;
            }
            if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
            {
                HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
            }
            InventoryHandler.InventoryAnimation(player, animation, duration);
            await Task.Delay(duration + 1250);

            lock (player)
            {
                player.SetPlayerFarmingActionMeta("None");
            }
            int rndItemAmount = new Random().Next(itemMinAmount, itemMaxAmount);

            //Doppelte Menge aufsammeln
            if (Characters.IsCharacterFastFarm(charId))
            {
                rndItemAmount += 1;
            }
            float itemWeight     = ServerItems.GetItemWeight(itemName) * rndItemAmount;
            float invWeight      = CharactersInventory.GetCharacterItemWeight(charId, "inventory");
            float backpackWeight = CharactersInventory.GetCharacterItemWeight(charId, "backpack");

            if (invWeight + itemWeight > 15f && backpackWeight + itemWeight > Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
            {
                HUDHandler.SendNotification(player, 3, 5000, $"Deine Taschen sind voll."); return;
            }

            if (invWeight + itemWeight <= 15f)
            {
                HUDHandler.SendNotification(player, 2, 5000, $"Du hast {itemName} ({rndItemAmount}x) gesammelt (Lagerort: Inventar).");
                CharactersInventory.AddCharacterItem(charId, itemName, rndItemAmount, "inventory");
                return;
            }

            if (Characters.GetCharacterBackpack(charId) != "None" && backpackWeight + itemWeight <= Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
            {
                HUDHandler.SendNotification(player, 2, 5000, $"Du hast {itemName} ({rndItemAmount}x) gesammelt (Lagerort: Rucksack / Tasche).");
                CharactersInventory.AddCharacterItem(charId, itemName, rndItemAmount, "backpack");
                return;
            }
        }
        private async void StreamSocketListener_ConnectionReceived(StreamSocketListener sender, StreamSocketListenerConnectionReceivedEventArgs args)
        {
            bool clientconnected = true;

            await CoreApplication.MainView.CoreWindow.
            Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                () => ServerItems.Add(string.Format("client connected from {0}:{1} ...",
                                                                    args.Socket.Information.RemoteAddress, args.Socket.Information.RemotePort)));

            while (clientconnected)
            {
                try
                {
                    string request;
                    if (streamReader == null)
                    {
                        streamReader = new StreamReader(args.Socket.InputStream.AsStreamForRead());
                    }

                    request = await streamReader.ReadLineAsync();


                    await CoreApplication.MainView.CoreWindow.
                    Dispatcher.RunAsync(CoreDispatcherPriority.Normal,
                                        () => ServerItems.Add(string.Format("server received the request: \"{0}\"", request)));

                    // Echo the request back as the response.
                    if (streamWriter == null)
                    {
                        Stream ServeroutputStream = args.Socket.OutputStream.AsStreamForWrite();
                        streamWriter = new StreamWriter(ServeroutputStream);
                    }

                    await streamWriter.WriteLineAsync(request);

                    await streamWriter.FlushAsync();

                    await CoreApplication.MainView.CoreWindow.Dispatcher.
                    RunAsync(CoreDispatcherPriority.Normal,
                             () => ServerItems.Add(string.Format("server sent back the response: \"{0}\"", request)));
                }
                catch (Exception ex)
                {
                    clientconnected = false;
                    CloseServerConnection();
                    SocketErrorStatus webErrorStatus = SocketError.GetStatus(ex.GetBaseException().HResult);
                    await CoreApplication.MainView.CoreWindow.Dispatcher.
                    RunAsync(CoreDispatcherPriority.Normal,
                             () => ServerItems.Add(webErrorStatus.ToString() != "Unknown" ? webErrorStatus.ToString() : ex.Message));
                }
            }
        }
Exemple #9
0
 public async Task StorageHotelItem(IPlayer player, int apartmentId, string itemName, int itemAmount, string fromContainer)
 {
     try
     {
         if (player == null || !player.Exists || apartmentId <= 0 || itemName == "" || itemName == "undefined" || itemAmount <= 0 || fromContainer == "none" || fromContainer == "")
         {
             return;
         }
         int cCharId = User.GetPlayerOnline(player);
         if (cCharId <= 0)
         {
             return;
         }
         if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
         {
             HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
         }
         if (!CharactersInventory.ExistCharacterItem(cCharId, itemName, fromContainer))
         {
             HUDHandler.SendNotification(player, 4, 5000, "Fehler: Diesen Gegenstand besitzt du nicht."); return;
         }
         if (CharactersInventory.GetCharacterItemAmount(cCharId, itemName, fromContainer) < itemAmount)
         {
             HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du hast nicht genügend Gegenstände davon dabei."); return;
         }
         if (CharactersInventory.IsItemActive(player, itemName))
         {
             HUDHandler.SendNotification(player, 4, 5000, "Fehler: Ausgerüstete Gegenstände können nicht umgelagert werden."); return;
         }
         float itemWeight = ServerItems.GetItemWeight(itemName) * itemAmount;
         if (ServerHotels.GetHotelStorageItemWeight(apartmentId) >= 15f || (ServerHotels.GetHotelStorageItemWeight(apartmentId) + itemWeight) >= 15f)
         {
             HUDHandler.SendNotification(player, 3, 5000, "Fehler: Soviel passt in das Lager nicht rein (maximal 15kg Lagerplatz).");
             return;
         }
         CharactersInventory.RemoveCharacterItemAmount(cCharId, itemName, itemAmount, fromContainer);
         ServerHotels.AddServerHotelStorageItem(apartmentId, itemName, itemAmount);
         HUDHandler.SendNotification(player, 2, 5000, $"Der Gegenstand wurde erfolgreich eingelagert ({itemName} - {itemAmount}x).");
         //LoggingService.NewHotelLog(apartmentId, cCharId, 0, "storage", $"{Characters.GetCharacterName(charId)} ({charId}) hat den Gegenstand '{itemName} ({amount}x)' in seinen Spind gelegt."); //ToDo: Hotel Storage Log
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Exemple #10
0
        internal IServerItem[] AddServerItems(IEnumerable <string> hostQueryAddresses)
        {
            var result = new List <IServerItem>(hostQueryAddresses.Count());

            foreach (var hostQueryAddress in hostQueryAddresses)
            {
                var pos  = hostQueryAddress.IndexOf(':');
                var addr = hostQueryAddress.Substring(0, pos);
                var port = 0;
                int.TryParse(hostQueryAddress.Substring(pos + 1), out port);

                var serverItem = new ServerItem {
                    Host = IPAddress.Parse(addr), QueryPort = port, Name = addr
                };
                ServerItems.Add(serverItem);
                result.Add(serverItem);
            }
            return(result.ToArray());
        }
Exemple #11
0
        public async void StartServer()
        {
            try
            {
                streamSocketListener = new StreamSocketListener();

                // The ConnectionReceived event is raised when connections are received.
                streamSocketListener.ConnectionReceived += StreamSocketListener_ConnectionReceived;

                // Start listening for incoming TCP connections on the specified port. You can specify any port that's not currently in use.
                await streamSocketListener.BindServiceNameAsync(PortNumber);

                serverIsRunning = true;
                ServerItems.Add(string.Format("server is listening on port {0} ...", PortNumber));
            }
            catch (Exception ex)
            {
                SocketErrorStatus webErrorStatus = SocketError.GetStatus(ex.GetBaseException().HResult);
                ServerItems.Add(webErrorStatus.ToString() != "Unknown" ? webErrorStatus.ToString() : ex.Message);
            }
        }
Exemple #12
0
        public void GiveItemCMD(IPlayer player, string itemName, int itemAmount)
        {
            if (player == null || !player.Exists)
            {
                return;
            }
            if (player.AdminLevel() <= 8)
            {
                HUDHandler.SendNotification(player, 4, 5000, "Keine Rechte."); return;
            }
            if (!ServerItems.ExistItem(ServerItems.ReturnNormalItemName(itemName)))
            {
                HUDHandler.SendNotification(player, 4, 5000, $"Itemname nicht gefunden: {itemName}"); return;
            }
            ulong charId = player.GetCharacterMetaId();

            if (charId <= 0)
            {
                return;
            }
            CharactersInventory.AddCharacterItem((int)charId, itemName, itemAmount, "inventory");
            HUDHandler.SendNotification(player, 2, 5000, $"Gegenstand '{itemName}' ({itemAmount}x) erhalten.");
        }
Exemple #13
0
        public async Task GiveItem(ClassicPlayer player, string itemname, int itemAmount, string fromContainer, int targetPlayerId)
        {
            try
            {
                if (player == null || !player.Exists || itemname == "" || itemAmount <= 0 || fromContainer == "" || targetPlayerId == 0)
                {
                    return;
                }
                player.EmitLocked("Client:Inventory:closeCEF");
                if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                }
                if (!ServerItems.IsItemGiveable(itemname))
                {
                    HUDHandler.SendNotification(player, 4, 5000, $"Diesen Gegenstand kannst du nicht weggeben ({itemname})."); return;
                }
                int charId = player.CharacterId;
                if (charId <= 0 || !CharactersInventory.ExistCharacterItem(charId, itemname, fromContainer))
                {
                    return;
                }
                if (CharactersInventory.GetCharacterItemAmount(charId, itemname, fromContainer) < itemAmount)
                {
                    HUDHandler.SendNotification(player, 4, 5000, $"Die angegebene Anzahl ist nicht vorhanden ({itemname})."); return;
                }
                if (CharactersInventory.IsItemActive(player, itemname))
                {
                    HUDHandler.SendNotification(player, 4, 5000, $"Ausgerüstete Gegenstände können nicht abgegeben werden."); return;
                }
                float itemWeight     = ServerItems.GetItemWeight(itemname) * itemAmount;
                float invWeight      = CharactersInventory.GetCharacterItemWeight(targetPlayerId, "inventory");
                float backpackWeight = CharactersInventory.GetCharacterItemWeight(targetPlayerId, "backpack");
                var   targetPlayer   = Alt.Server.GetPlayers().ToList().FirstOrDefault(x => x.GetCharacterMetaId() == (ulong)targetPlayerId);
                if (targetPlayer == null)
                {
                    return;
                }
                if (!player.Position.IsInRange(targetPlayer.Position, 5f))
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Die Person ist zu weit entfernt."); return;
                }
                if (invWeight + itemWeight > 15f && backpackWeight + itemWeight > Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(targetPlayerId)))
                {
                    HUDHandler.SendNotification(player, 3, 5000, $"Der Spieler hat nicht genug Platz in seinen Taschen."); return;
                }
                if (invWeight + itemWeight <= 15f)
                {
                    HUDHandler.SendNotification(targetPlayer, 1, 5000, $"Eine Person hat dir den Gegenstand {itemname} ({itemAmount}x) gegeben.");
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast einem Spieler den Gegenstand {itemname} ({itemAmount}x) gegeben.");
                    CharactersInventory.AddCharacterItem(targetPlayerId, itemname, itemAmount, "inventory");
                    CharactersInventory.RemoveCharacterItemAmount(charId, itemname, itemAmount, fromContainer);
                    InventoryAnimation(player, "give", 0);
                    return;
                }

                if (Characters.GetCharacterBackpack(targetPlayerId) != "None" && backpackWeight + itemWeight <= Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(targetPlayerId)))
                {
                    HUDHandler.SendNotification(targetPlayer, 1, 5000, $"Eine Person hat dir den Gegenstand {itemname} ({itemAmount}x) gegeben.");
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast einem Spieler den Gegenstand {itemname} ({itemAmount}x) gegeben.");
                    CharactersInventory.AddCharacterItem(targetPlayerId, itemname, itemAmount, "backpack");
                    CharactersInventory.RemoveCharacterItemAmount(charId, itemname, itemAmount, fromContainer);
                    InventoryAnimation(player, "give", 0);
                    return;
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Exemple #14
0
        public async Task VehicleTrunkTakeItem(ClassicPlayer player, int vehId, int charId, string itemName, int itemAmount, string type)
        {
            try
            {
                if (player == null || !player.Exists || vehId <= 0 || charId <= 0 || itemName == "" || itemAmount <= 0)
                {
                    return;
                }
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                }
                if (type != "trunk" && type != "glovebox")
                {
                    return;
                }
                int cCharId = player.CharacterId;
                if (cCharId != charId)
                {
                    return;
                }
                var targetVehicle = Alt.Server.GetVehicles().ToList().FirstOrDefault(x => x.GetVehicleId() == (ulong)vehId);
                if (targetVehicle == null || !targetVehicle.Exists)
                {
                    return;
                }
                if (!player.Position.IsInRange(targetVehicle.Position, 5f))
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du bist zu weit entfernt."); return;
                }
                if (type == "trunk")
                {
                    if (player.IsInVehicle)
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Wie willst du von Innen an den Kofferraum kommen?"); return;
                    }
                    if (!targetVehicle.GetVehicleTrunkState())
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Fehler: Der Kofferraum ist nicht geöffnet."); return;
                    }
                    if (!ServerVehicles.ExistVehicleTrunkItem(vehId, itemName, false))
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Fehler: Der Gegenstand existiert hier nicht."); return;
                    }
                    if (ServerVehicles.GetVehicleTrunkItemAmount(vehId, itemName, false) < itemAmount)
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Fehler: Soviele Gegenstände sind nicht im Fahrzeug."); return;
                    }
                }
                else if (type == "glovebox")
                {
                    if (!player.IsInVehicle)
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du bist in keinem Fahrzeug."); return;
                    }
                    if (!ServerVehicles.ExistVehicleTrunkItem(vehId, itemName, true))
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Fehler: Der Gegenstand existiert hier nicht."); return;
                    }
                    if (ServerVehicles.GetVehicleTrunkItemAmount(vehId, itemName, true) < itemAmount)
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Fehler: Soviele Gegenstände sind nicht im Fahrzeug."); return;
                    }
                }
                float itemWeight     = ServerItems.GetItemWeight(itemName) * itemAmount;
                float invWeight      = CharactersInventory.GetCharacterItemWeight(charId, "inventory");
                float backpackWeight = CharactersInventory.GetCharacterItemWeight(charId, "backpack");
                if (invWeight + itemWeight > 15f && backpackWeight + itemWeight > Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
                {
                    HUDHandler.SendNotification(player, 3, 5000, $"Du hast nicht genug Platz in deinen Taschen."); return;
                }

                if (type == "trunk")
                {
                    ServerVehicles.RemoveVehicleTrunkItemAmount(vehId, itemName, itemAmount, false);
                }
                else if (type == "glovebox")
                {
                    ServerVehicles.RemoveVehicleTrunkItemAmount(vehId, itemName, itemAmount, true);
                }

                if (invWeight + itemWeight <= 15f)
                {
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast {itemName} ({itemAmount}x) aus dem Fahrzeug genommen (Lagerort: Inventar).");
                    CharactersInventory.AddCharacterItem(charId, itemName, itemAmount, "inventory");
                    stopwatch.Stop();
                    Alt.Log($"{charId} - VehicleTrunkTakeItem benötigte {stopwatch.Elapsed.Milliseconds}ms");
                    return;
                }

                if (Characters.GetCharacterBackpack(charId) != "None" && backpackWeight + itemWeight <= Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
                {
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast {itemName} ({itemAmount}x) aus dem Fahrzeug genommen (Lagerort: Rucksack / Tasche).");
                    CharactersInventory.AddCharacterItem(charId, itemName, itemAmount, "backpack");
                    stopwatch.Stop();
                    Alt.Log($"{charId} - VehicleTrunkTakeItem benötigte {stopwatch.Elapsed.Milliseconds}ms");
                    return;
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Exemple #15
0
        public async Task VehicleTrunkStorageItem(ClassicPlayer player, int vehId, int charId, string itemName, int itemAmount, string fromContainer, string type)
        {
            try
            {
                Stopwatch stopwatch = new Stopwatch();
                stopwatch.Start();
                if (player == null || !player.Exists || vehId <= 0 || charId <= 0 || itemName == "" || itemAmount <= 0 || fromContainer == "none" || fromContainer == "")
                {
                    return;
                }
                if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                }
                if (type != "trunk" && type != "glovebox")
                {
                    return;
                }
                int cCharId = player.CharacterId;
                if (cCharId != charId)
                {
                    return;
                }
                var targetVehicle = Alt.Server.GetVehicles().ToList().FirstOrDefault(x => x.GetVehicleId() == (ulong)vehId);
                if (targetVehicle == null || !targetVehicle.Exists)
                {
                    return;
                }
                if (!player.Position.IsInRange(targetVehicle.Position, 5f))
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du bist zu weit entfernt."); return;
                }
                if (type == "trunk")
                {
                    if (player.IsInVehicle)
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Wie willst du von Innen an den Kofferraum kommen?"); return;
                    }
                    if (!targetVehicle.GetVehicleTrunkState())
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Fehler: Der Kofferraum ist nicht geöffnet."); return;
                    }
                }
                else if (type == "glovebox")
                {
                    if (!player.IsInVehicle)
                    {
                        HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du bist in keinem Fahrzeug."); return;
                    }
                }
                if (!CharactersInventory.ExistCharacterItem(charId, itemName, fromContainer))
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Diesen Gegenstand besitzt du nicht."); return;
                }
                if (CharactersInventory.GetCharacterItemAmount(charId, itemName, fromContainer) < itemAmount)
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Du hast nicht genügend Gegenstände davon dabei."); return;
                }
                if (CharactersInventory.IsItemActive(player, itemName))
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Ausgerüstete Gegenstände können nicht umgelagert werden."); return;
                }
                float itemWeight   = ServerItems.GetItemWeight(itemName) * itemAmount;
                float curVehWeight = 0f;
                float maxVehWeight = 0f;

                if (type == "trunk")
                {
                    curVehWeight = ServerVehicles.GetVehicleVehicleTrunkWeight(vehId, false);
                    maxVehWeight = ServerVehicles.GetVehicleTrunkCapacityOnHash(targetVehicle.Model);
                }
                else if (type == "glovebox")
                {
                    curVehWeight = ServerVehicles.GetVehicleVehicleTrunkWeight(vehId, true);
                    maxVehWeight = 5f;
                }

                if (curVehWeight + itemWeight > maxVehWeight)
                {
                    HUDHandler.SendNotification(player, 3, 5000, $"Fehler: Soviel passt hier nicht rein (Aktuell: {curVehWeight} |  Maximum: {maxVehWeight})."); return;
                }
                CharactersInventory.RemoveCharacterItemAmount(charId, itemName, itemAmount, fromContainer);

                if (type == "trunk")
                {
                    ServerVehicles.AddVehicleTrunkItem(vehId, itemName, itemAmount, false);
                    HUDHandler.SendNotification(player, 2, 2500, $"Du hast den Gegenstand '{itemName} ({itemAmount}x)' in den Kofferraum gelegt.");
                    stopwatch.Stop();
                    Alt.Log($"{charId} - VehicleTrunkStorageItem benötigte {stopwatch.Elapsed.Milliseconds}ms");
                    return;
                }
                else if (type == "glovebox")
                {
                    ServerVehicles.AddVehicleTrunkItem(vehId, itemName, itemAmount, true);
                    HUDHandler.SendNotification(player, 2, 2500, $"Du hast den Gegenstand '{itemName} ({itemAmount}x)' in das Handschuhfach gelegt.");
                    stopwatch.Stop();
                    Alt.Log($"{charId} - VehicleTrunkStorageItem benötigte {stopwatch.Elapsed.Milliseconds}ms");
                    return;
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Exemple #16
0
        public async Task buyShopItem(IPlayer player, int shopId, int amount, string itemname)
        {
            if (player == null || !player.Exists || shopId <= 0 || amount <= 0 || itemname == "")
            {
                return;
            }
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
            {
                HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
            }
            if (!player.Position.IsInRange(ServerShops.GetShopPosition(shopId), 3f))
            {
                HUDHandler.SendNotification(player, 3, 5000, $"Du bist zu weit vom Shop entfernt."); return;
            }
            int charId = User.GetPlayerOnline(player);

            if (charId == 0)
            {
                return;
            }
            if (ServerShops.GetShopNeededLicense(shopId) != "None" && !Characters.HasCharacterPermission(charId, ServerShops.GetShopNeededLicense(shopId)))
            {
                HUDHandler.SendNotification(player, 3, 5000, $"Du hast hier keinen Zugriff drauf."); return;
            }
            float itemWeight     = ServerItems.GetItemWeight(itemname) * amount;
            float invWeight      = CharactersInventory.GetCharacterItemWeight(charId, "inventory");
            float backpackWeight = CharactersInventory.GetCharacterItemWeight(charId, "backpack");
            int   itemPrice      = ServerShopsItems.GetShopItemPrice(shopId, itemname) * amount;
            int   shopFaction    = ServerShops.GetShopFaction(shopId);

            if (ServerShopsItems.GetShopItemAmount(shopId, itemname) < amount)
            {
                HUDHandler.SendNotification(player, 3, 5000, $"Soviele Gegenstände hat der Shop nicht auf Lager."); return;
            }
            if (invWeight + itemWeight > 15f && backpackWeight + itemWeight > Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
            {
                HUDHandler.SendNotification(player, 3, 5000, $"Du hast nicht genug Platz in deinen Taschen."); return;
            }

            if (invWeight + itemWeight <= 15f)
            {
                if (shopFaction > 0 && shopFaction != 0)
                {
                    if (!ServerFactions.IsCharacterInAnyFaction(charId))
                    {
                        HUDHandler.SendNotification(player, 3, 2500, "Du hast hier keinen Zugriff drauf [CODE1-2]."); return;
                    }
                    if (ServerFactions.GetCharacterFactionId(charId) != shopFaction)
                    {
                        HUDHandler.SendNotification(player, 3, 2500, $"Du hast hier keinen Zugriff drauf (Gefordert: {shopFaction} - Deine: {ServerFactions.GetCharacterFactionId(charId)}."); return;
                    }
                    if (ServerFactions.GetFactionBankMoney(shopFaction) < itemPrice)
                    {
                        HUDHandler.SendNotification(player, 3, 2500, "Die Frakton hat nicht genügend Geld auf dem Fraktionskonto."); return;
                    }
                    ServerFactions.SetFactionBankMoney(shopFaction, ServerFactions.GetFactionBankMoney(shopFaction) - itemPrice);
                    LoggingService.NewFactionLog(shopFaction, charId, 0, "shop", $"{Characters.GetCharacterName(charId)} hat {itemname} ({amount}x) für {itemPrice}$ erworben.");
                }
                else
                {
                    if (!CharactersInventory.ExistCharacterItem(charId, "Bargeld", "inventory") || CharactersInventory.GetCharacterItemAmount(charId, "Bargeld", "inventory") < itemPrice)
                    {
                        HUDHandler.SendNotification(player, 3, 2500, "Du hast nicht genügend Geld dabei.");
                        return;
                    }
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Bargeld", itemPrice, "inventory");
                }

                CharactersInventory.AddCharacterItem(charId, itemname, amount, "inventory");
                HUDHandler.SendNotification(player, 2, 5000, $"Du hast {itemname} ({amount}x) für {itemPrice} gekauft (Lagerort: Inventar).");
                stopwatch.Stop();
                if (stopwatch.Elapsed.Milliseconds > 30)
                {
                    Alt.Log($"{charId} - buyShopItem benötigte {stopwatch.Elapsed.Milliseconds}ms");
                }
                return;
            }

            if (Characters.GetCharacterBackpack(charId) != "None" && backpackWeight + itemWeight <= Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
            {
                if (shopFaction > 0 && shopFaction != 0)
                {
                    if (!ServerFactions.IsCharacterInAnyFaction(charId))
                    {
                        HUDHandler.SendNotification(player, 3, 2500, "Du hast hier keinen Zugriff drauf [CODE1]."); return;
                    }
                    if (ServerFactions.GetCharacterFactionId(charId) != shopFaction)
                    {
                        HUDHandler.SendNotification(player, 3, 2500, $"Du hast hier keinen Zugriff drauf (Gefordert: {shopFaction} - Deine: {ServerFactions.GetCharacterFactionId(charId)}."); return;
                    }
                    if (ServerFactions.GetFactionBankMoney(shopFaction) < itemPrice)
                    {
                        HUDHandler.SendNotification(player, 3, 2500, "Die Frakton hat nicht genügend Geld auf dem Fraktionskonto."); return;
                    }
                    ServerFactions.SetFactionBankMoney(shopFaction, ServerFactions.GetFactionBankMoney(shopFaction) - itemPrice);
                    LoggingService.NewFactionLog(shopFaction, charId, 0, "shop", $"{Characters.GetCharacterName(charId)} hat {itemname} ({amount}x) für {itemPrice}$ erworben.");
                }
                else
                {
                    if (!CharactersInventory.ExistCharacterItem(charId, "Bargeld", "inventory") || CharactersInventory.GetCharacterItemAmount(charId, "Bargeld", "inventory") < itemPrice)
                    {
                        HUDHandler.SendNotification(player, 3, 2500, "Du hast nicht genügend Geld dabei.");
                        return;
                    }
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Bargeld", itemPrice, "inventory");
                }

                CharactersInventory.AddCharacterItem(charId, itemname, amount, "backpack");
                HUDHandler.SendNotification(player, 2, 5000, $"Du hast {itemname} ({amount}x) für {itemPrice} gekauft (Lagerort: Rucksack / Tasche).");
                stopwatch.Stop();
                if (stopwatch.Elapsed.Milliseconds > 30)
                {
                    Alt.Log($"{charId} - buyShopItem benötigte {stopwatch.Elapsed.Milliseconds}ms");
                }
                return;
            }
        }
Exemple #17
0
        internal static void closeDeathscreen(IPlayer player)
        {
            try
            {
                if (player == null || !player.Exists)
                {
                    return;
                }
                int charId = (int)player.GetCharacterMetaId();
                if (charId <= 0)
                {
                    return;
                }
                player.EmitLocked("Client:Deathscreen:closeCEF");
                player.SetPlayerIsUnconscious(false);
                player.SetPlayerIsFastFarm(false);
                player.EmitLocked("Client:Ragdoll:SetPedToRagdoll", false, 2000);
                Characters.SetCharacterUnconscious(charId, false, 0);
                Characters.SetCharacterFastFarm(charId, false, 0);
                player.EmitLocked("Client:Inventory:StopEffect", "DrugsMichaelAliensFight");

                foreach (var item in CharactersInventory.CharactersInventory_.ToList().Where(x => x.charId == charId))
                {
                    if (item.itemName.Contains("EC Karte") || item.itemName.Contains("Ausweis") || item.itemName.Contains("Fahrzeugschluessel") || ServerItems.GetItemType(ServerItems.ReturnNormalItemName(item.itemName)) == "clothes")
                    {
                        continue;
                    }
                    CharactersInventory.RemoveCharacterItem(charId, item.itemName, item.itemLocation);
                }

                Characters.SetCharacterWeapon(player, "PrimaryWeapon", "None");
                Characters.SetCharacterWeapon(player, "PrimaryAmmo", 0);
                Characters.SetCharacterWeapon(player, "SecondaryWeapon2", "None");
                Characters.SetCharacterWeapon(player, "SecondaryWeapon", "None");
                Characters.SetCharacterWeapon(player, "SecondaryAmmo2", 0);
                Characters.SetCharacterWeapon(player, "SecondaryAmmo", 0);
                Characters.SetCharacterWeapon(player, "FistWeapon", "None");
                Characters.SetCharacterWeapon(player, "FistWeaponAmmo", 0);
                player.EmitLocked("Client:Smartphone:equipPhone", false, Characters.GetCharacterPhonenumber(charId), Characters.IsCharacterPhoneFlyModeEnabled(charId));
                Characters.SetCharacterPhoneEquipped(charId, false);
                player.RemoveAllWeaponsAsync();
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Exemple #18
0
        public static void EquipCharacterWeapon(IPlayer player, string type, string wName, int amount, string fromContainer)
        {
            try
            {
                int         charId      = User.GetPlayerOnline(player);
                string      wType       = "None";
                string      normalWName = "None";
                string      ammoWName   = "None";
                WeaponModel wHash       = 0;

                switch (wName)
                {
                case "Pistole":
                case "Pistolen Munition":
                    wType       = "Secondary";
                    normalWName = "Pistole";
                    ammoWName   = "Pistolen";
                    wHash       = (WeaponModel)0x1B06D571;
                    break;

                case "MkII Pistole":
                case "MkII Pistolen Munition":
                    wType       = "Secondary";
                    normalWName = "MkII Pistole";
                    ammoWName   = "MkII Pistolen";
                    wHash       = (WeaponModel)0xBFE256D4;
                    break;

                case "Pistole .50":
                case "Pistole .50 Munition":
                    wType       = "Secondary";
                    normalWName = "Pistole .50";
                    ammoWName   = "Pistole .50";
                    wHash       = (WeaponModel)0x99AEEB3B;
                    break;

                case "Revolver":
                case "Revolver Munition":
                    wType       = "Secondary";
                    normalWName = "Revolver";
                    ammoWName   = "Revolver";
                    wHash       = (WeaponModel)0xC1B3C3D1;
                    break;

                case "Elektroschocker":
                    wType = "Secondary";
                    wHash = WeaponModel.StunGun;
                    break;

                case "Flaregun":
                case "Flaregun Munition":
                    wType       = "Secondary";
                    normalWName = "Flaregun";
                    ammoWName   = "Flaregun";
                    wHash       = (WeaponModel)0x47757124;
                    break;

                case "PDW":
                case "PDW Munition":
                    wType       = "Primary";
                    normalWName = "PDW";
                    ammoWName   = "PDW";
                    wHash       = (WeaponModel)0x0A3D4D34;
                    break;

                case "Karabiner":
                case "Karabiner Munition":
                    wType       = "Primary";
                    normalWName = "Karabiner";
                    ammoWName   = "Karabiner";
                    wHash       = (WeaponModel)0x83BF0278;
                    break;

                case "SMG":
                case "SMG Munition":
                    wType       = "Primary";
                    normalWName = "SMG";
                    ammoWName   = "SMG";
                    wHash       = (WeaponModel)0x2BE6766B;
                    break;

                case "Schlagstock":
                    wType       = "Fist";
                    normalWName = "Schlagstock";
                    wHash       = (WeaponModel)0x678B81B1;
                    break;

                case "Messer":
                    wType       = "Fist";
                    normalWName = "Messer";
                    wHash       = (WeaponModel)0x99B507EA;
                    break;

                case "Brecheisen":
                    wType       = "Fist";
                    normalWName = "Brecheisen";
                    wHash       = (WeaponModel)0x84BD7BFD;
                    break;

                case "Baseballschlaeger":
                    wType       = "Fist";
                    normalWName = "Baseballschlaeger";
                    wHash       = (WeaponModel)0x958A4A8F;
                    break;

                case "Dolch":
                    wType       = "Fist";
                    normalWName = "Dolch";
                    wHash       = (WeaponModel)0x92A27487;
                    break;

                case "Hammer":
                    wType       = "Fist";
                    normalWName = "Hammer";
                    wHash       = (WeaponModel)0x4E875F73;
                    break;

                case "Axt":
                    wType       = "Fist";
                    normalWName = "Axt";
                    wHash       = (WeaponModel)0xF9DCBF2D;
                    break;

                case "Machete":
                    wType       = "Fist";
                    normalWName = "Machete";
                    wHash       = (WeaponModel)0xDD5DF8D9;
                    break;

                case "Springmesser":
                    wType       = "Fist";
                    normalWName = "Springmesser";
                    wHash       = (WeaponModel)0xDFE37640;
                    break;

                case "Schlagring":
                    wType       = "Fist";
                    normalWName = "Schlagring";
                    wHash       = (WeaponModel)0xD8DF3C3C;
                    break;

                case "Taschenlampe":
                    wType       = "Fist";
                    normalWName = "Taschenlampe";
                    wHash       = (WeaponModel)0x8BB05FD7;
                    break;

                case "Golfschlaeger":
                    wType       = "Fist";
                    normalWName = "Golfschlaeger";
                    wHash       = (WeaponModel)0x440E4788;
                    break;
                }


                if (type == "Weapon")
                {
                    if (wType == "Primary")
                    {
                        string primWeapon = (string)Characters.GetCharacterWeapon(player, "PrimaryWeapon");

                        if (primWeapon == "None")
                        {
                            player.GiveWeapon(wHash, 0, true);
                            Characters.SetCharacterWeapon(player, "PrimaryWeapon", wName);
                            Characters.SetCharacterWeapon(player, "PrimaryAmmo", 0);
                            SetWeaponComponents(player, wName);
                            HUDHandler.SendNotification(player, 2, 5000, $"{wName} erfolgreich ausgerüstet.");
                            return;
                        }
                        else if (primWeapon == wName)
                        {
                            int   wAmmoAmount    = (int)Characters.GetCharacterWeapon(player, "PrimaryAmmo");
                            float invWeight      = CharactersInventory.GetCharacterItemWeight(charId, "inventory");
                            float backpackWeight = CharactersInventory.GetCharacterItemWeight(charId, "backpack");
                            float bigWeight      = invWeight + backpackWeight;
                            float itemWeight     = ServerItems.GetItemWeight($"{ammoWName} Munition");
                            float multiWeight    = itemWeight * wAmmoAmount;
                            float finalWeight    = bigWeight + multiWeight;
                            float helpWeight     = 15f + Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId));
                            bool  inBackpack     = false;

                            if (invWeight + multiWeight > 15f && backpackWeight + multiWeight > Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
                            {
                                HUDHandler.SendNotification(player, 4, 5000, "Nicht genügend Platz."); return;
                            }

                            if (wAmmoAmount >= 1 && ammoWName != "None" && finalWeight <= helpWeight)
                            {
                                if (invWeight + multiWeight <= 15f)
                                {
                                    CharactersInventory.AddCharacterItem(charId, $"{ammoWName} Munition", wAmmoAmount, "inventory"); inBackpack = false;
                                }
                                else
                                {
                                    inBackpack = true;
                                }
                                if (backpackWeight + multiWeight <= Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)) && inBackpack == true)
                                {
                                    CharactersInventory.AddCharacterItem(charId, $"{ammoWName} Munition", wAmmoAmount, "backpack");
                                }
                            }

                            if (finalWeight <= helpWeight)
                            {
                                HUDHandler.SendNotification(player, 2, 5000, $"{wName} erfolgreich abgelegt.");
                                Characters.SetCharacterWeapon(player, "PrimaryWeapon", "None");
                                Characters.SetCharacterWeapon(player, "PrimaryAmmo", 0);
                                player.RemoveWeapon(wHash);
                            }
                        }
                        else
                        {
                            HUDHandler.SendNotification(player, 3, 5000, "Du musst zuerst deine Hauptwaffe ablegen bevor du eine neue anlegen kannst.");
                        }
                    }
                    else if (wType == "Fist")
                    {
                        string fistWeapon = (string)Characters.GetCharacterWeapon(player, "FistWeapon");
                        if (fistWeapon == "None")
                        {
                            player.GiveWeapon(wHash, 0, false);
                            Characters.SetCharacterWeapon(player, "FistWeapon", wName);
                            Characters.SetCharacterWeapon(player, "FistWeaponAmmo", 0);
                            HUDHandler.SendNotification(player, 2, 500, $"{wName} erfolgreich ausgerüstet.");
                        }
                        else if (fistWeapon == wName)
                        {
                            float curWeight = CharactersInventory.GetCharacterItemWeight(charId, "inventory") + CharactersInventory.GetCharacterItemWeight(charId, "backpack");
                            float maxWeight = 15f + Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId));
                            if (curWeight < maxWeight)
                            {
                                Characters.SetCharacterWeapon(player, "FistWeapon", "None"); Characters.SetCharacterWeapon(player, "FistWeaponAmmo", 0); player.RemoveWeapon(wHash); HUDHandler.SendNotification(player, 2, 5000, $"{wName} erfolgreich abgelegt.");
                            }
                            else
                            {
                                HUDHandler.SendNotification(player, 4, 5000, "Du hast nicht genügend Platz.");
                            }
                        }
                        else
                        {
                            HUDHandler.SendNotification(player, 3, 5000, "Du musst zuerst deine Schlagwaffe ablegen bevor du eine neue anlegen kannst.");
                        }
                    }
                    else if (wType == "Secondary")
                    {
                        string secondaryWeapon  = (string)Characters.GetCharacterWeapon(player, "SecondaryWeapon");
                        string secondaryWeapon2 = (string)Characters.GetCharacterWeapon(player, "SecondaryWeapon2");

                        if (secondaryWeapon == "None")
                        {
                            if (secondaryWeapon2 == wName)
                            {
                                int   ammoAmount     = (int)Characters.GetCharacterWeapon(player, "SecondaryAmmo2");
                                float invWeight      = CharactersInventory.GetCharacterItemWeight(charId, "inventory");
                                float backpackWeight = CharactersInventory.GetCharacterItemWeight(charId, "backpack");
                                float bigWeight      = invWeight + backpackWeight;
                                float itemWeight     = ServerItems.GetItemWeight($"{ammoWName} Munition");
                                float multiWeight    = itemWeight * ammoAmount;
                                float finalWeight    = bigWeight + multiWeight;
                                float helpWeight     = 15f + Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId));
                                bool  inBackpack     = false;
                                if (invWeight + multiWeight > 15f && backpackWeight + multiWeight > Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
                                {
                                    HUDHandler.SendNotification(player, 4, 5000, "Nicht genügend Platz."); return;
                                }

                                if (ammoAmount >= 1 && ammoWName != "None" && finalWeight <= helpWeight)
                                {
                                    if (invWeight + multiWeight <= 15f)
                                    {
                                        CharactersInventory.AddCharacterItem(charId, $"{ammoWName} Munition", ammoAmount, "inventory"); inBackpack = false;
                                    }
                                    else
                                    {
                                        inBackpack = true;
                                    }
                                    if (backpackWeight + multiWeight <= Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)) && inBackpack == true)
                                    {
                                        CharactersInventory.AddCharacterItem(charId, $"{ammoWName} Munition", ammoAmount, "backpack");
                                    }
                                }

                                if (finalWeight <= helpWeight)
                                {
                                    HUDHandler.SendNotification(player, 2, 5000, $"{wName} erfolgreich abgelegt.");
                                    Characters.SetCharacterWeapon(player, "SecondaryWeapon2", "None");
                                    Characters.SetCharacterWeapon(player, "SecondaryAmmo2", "None");
                                    player.RemoveWeapon(wHash);
                                }
                            }
                            else
                            {
                                player.GiveWeapon(wHash, 0, true);
                                Characters.SetCharacterWeapon(player, "SecondaryWeapon", wName);
                                Characters.SetCharacterWeapon(player, "SecondaryAmmo", 0);
                                SetWeaponComponents(player, wName);
                                HUDHandler.SendNotification(player, 2, 5000, $"{wName} erfolgreich ausgerüstet.");
                            }
                        }
                        else if (secondaryWeapon == wName)
                        {
                            int   ammoAmount     = (int)Characters.GetCharacterWeapon(player, "SecondaryAmmo");
                            float invWeight      = CharactersInventory.GetCharacterItemWeight(charId, "inventory");
                            float backpackWeight = CharactersInventory.GetCharacterItemWeight(charId, "backpack");
                            float bigWeight      = invWeight + backpackWeight;
                            float itemWeight     = ServerItems.GetItemWeight($"{ammoWName} Munition");
                            float multiWeight    = itemWeight * ammoAmount;
                            float finalWeight    = bigWeight + multiWeight;
                            float helpWeight     = 15f + Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId));
                            bool  inBackpack     = false;
                            if (invWeight + multiWeight > 15f && backpackWeight + multiWeight > Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
                            {
                                HUDHandler.SendNotification(player, 4, 5000, "Nicht genügend Platz."); return;
                            }
                            if (ammoAmount >= 1 && ammoWName != "None" && finalWeight <= helpWeight)
                            {
                                if (invWeight + multiWeight <= 15f)
                                {
                                    CharactersInventory.AddCharacterItem(charId, $"{ammoWName} Munition", ammoAmount, "inventory"); inBackpack = false;
                                }
                                else
                                {
                                    inBackpack = true;
                                }
                                if (backpackWeight + multiWeight <= Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)) && inBackpack == true)
                                {
                                    CharactersInventory.AddCharacterItem(charId, $"{ammoWName} Munition", ammoAmount, "backpack");
                                }
                            }

                            if (finalWeight <= helpWeight)
                            {
                                HUDHandler.SendNotification(player, 2, 5000, $"{wName} erfolgreich abgelegt.");
                                Characters.SetCharacterWeapon(player, "SecondaryWeapon", "None");
                                Characters.SetCharacterWeapon(player, "SecondaryAmmo", 0);
                                player.RemoveWeapon(wHash);
                            }
                        }
                        else
                        {
                            if (secondaryWeapon2 == "None")
                            {
                                player.GiveWeapon(wHash, 0, true);
                                Characters.SetCharacterWeapon(player, "SecondaryWeapon2", wName);
                                Characters.SetCharacterWeapon(player, "SecondaryAmmo2", 0);
                                SetWeaponComponents(player, wName);
                                HUDHandler.SendNotification(player, 2, 5000, $"{wName} erfolgreich ausgerüstet.");
                            }
                            else if (secondaryWeapon2 == wName)
                            {
                                int   ammoAmount     = (int)Characters.GetCharacterWeapon(player, "SecondaryAmmo2");
                                float invWeight      = CharactersInventory.GetCharacterItemWeight(charId, "inventory");
                                float backpackWeight = CharactersInventory.GetCharacterItemWeight(charId, "backpack");
                                float bigWeight      = invWeight + backpackWeight;
                                float itemWeight     = ServerItems.GetItemWeight($"{ammoWName} Munition");
                                float multiWeight    = itemWeight * ammoAmount;
                                float finalWeight    = bigWeight + multiWeight;
                                float helpWeight     = 15f + Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId));
                                bool  inBackpack     = false;

                                if (ammoAmount >= 1 && ammoWName != "None" && finalWeight <= helpWeight)
                                {
                                    if (invWeight + multiWeight <= 15f)
                                    {
                                        CharactersInventory.AddCharacterItem(charId, $"{ammoWName} Munition", ammoAmount, "inventory"); inBackpack = false;
                                    }
                                    else
                                    {
                                        inBackpack = true;
                                    }
                                    if (backpackWeight + multiWeight <= Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)) && inBackpack == true)
                                    {
                                        CharactersInventory.AddCharacterItem(charId, $"{ammoWName} Munition", ammoAmount, "backpack");
                                    }
                                }

                                if (finalWeight <= helpWeight)
                                {
                                    HUDHandler.SendNotification(player, 2, 5000, $"{wName} erfolgreich abgelegt.");
                                    Characters.SetCharacterWeapon(player, "SecondaryWeapon2", "None");
                                    Characters.SetCharacterWeapon(player, "SecondaryAmmo2", 0);
                                    player.RemoveWeapon(wHash);
                                }
                            }
                            else
                            {
                                HUDHandler.SendNotification(player, 3, 5000, "Du musst zuerst deine Sekundärwaffe ablegen bevor du eine neue anlegen kannst.");
                            }
                        }
                    }
                }
                else if (type == "Ammo")
                {
                    if (wType == "Primary")
                    {
                        string primaryWeapon = (string)Characters.GetCharacterWeapon(player, "PrimaryWeapon");
                        if (primaryWeapon == "None")
                        {
                            HUDHandler.SendNotification(player, 3, 5000, "Du hast keine Primärwaffe angelegt.");
                        }
                        else if (primaryWeapon == normalWName)
                        {
                            int newAmmo = (int)Characters.GetCharacterWeapon(player, "PrimaryAmmo") + amount;
                            player.GiveWeapon(wHash, newAmmo, true);
                            Characters.SetCharacterWeapon(player, "PrimaryAmmo", newAmmo);
                            HUDHandler.SendNotification(player, 2, 5000, $"Du hast {wName} in deine Waffe geladen.");

                            if (CharactersInventory.ExistCharacterItem(charId, $"{wName}", fromContainer))
                            {
                                CharactersInventory.RemoveCharacterItemAmount(charId, $"{wName}", amount, fromContainer);
                            }
                        }
                        else
                        {
                            HUDHandler.SendNotification(player, 3, 5000, "Die Munitionen passen nicht in deine Waffe.");
                        }
                    }
                    else if (wType == "Secondary")
                    {
                        string secondaryWeapon = (string)Characters.GetCharacterWeapon(player, "SecondaryWeapon");
                        if (secondaryWeapon == "None")
                        {
                            HUDHandler.SendNotification(player, 4, 5000, "Du hast keine Sekundärwaffe angelegt.");
                        }
                        else if (secondaryWeapon == normalWName)
                        {
                            int newAmmo = (int)Characters.GetCharacterWeapon(player, "SecondaryAmmo") + amount;
                            player.GiveWeapon(wHash, newAmmo, true);
                            Characters.SetCharacterWeapon(player, "SecondaryAmmo", newAmmo);
                            HUDHandler.SendNotification(player, 2, 5000, $"Du hast {wName} in deine Waffe geladen.");

                            if (CharactersInventory.ExistCharacterItem(charId, $"{wName}", fromContainer))
                            {
                                CharactersInventory.RemoveCharacterItemAmount(charId, $"{wName}", amount, fromContainer);
                            }
                        }
                        else
                        {
                            string secondary2Weapon = (string)Characters.GetCharacterWeapon(player, "SecondaryWeapon2");
                            if (secondary2Weapon == "None")
                            {
                                HUDHandler.SendNotification(player, 4, 5000, "Du hast keine Sekundärwaffe angelegt.");
                            }
                            else if (secondary2Weapon == normalWName)
                            {
                                int newAmmo = (int)Characters.GetCharacterWeapon(player, "SecondaryAmmo2") + amount;
                                player.GiveWeapon(wHash, newAmmo, true);
                                Characters.SetCharacterWeapon(player, "SecondaryAmmo2", newAmmo);
                                HUDHandler.SendNotification(player, 2, 5000, $"Du hast {wName} in deine Waffe geladen.");

                                if (CharactersInventory.ExistCharacterItem(charId, $"{wName}", fromContainer))
                                {
                                    CharactersInventory.RemoveCharacterItemAmount(charId, $"{wName}", amount, fromContainer);
                                }
                            }
                            else
                            {
                                HUDHandler.SendNotification(player, 4, 5000, "Die Munitionen passen nicht in deine Waffe.");
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Exemple #19
0
 public async Task DropItem(ClassicPlayer player, string itemname, int itemAmount, string fromContainer)
 {
     try
     {
         if (player == null || !player.Exists || itemname == "" || itemAmount <= 0 || fromContainer == "" || User.GetPlayerOnline(player) == 0)
         {
             return;
         }
         if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
         {
             HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
         }
         string normalItemName = ServerItems.ReturnNormalItemName(itemname);
         if (ServerItems.IsItemDroppable(itemname) == false)
         {
             HUDHandler.SendNotification(player, 4, 5000, $"Diesen Gegenstand kannst du nicht wegwerfen ({itemname})."); return;
         }
         int charId = player.CharacterId;
         if (charId <= 0 || CharactersInventory.ExistCharacterItem(charId, itemname, fromContainer) == false)
         {
             return;
         }
         if (CharactersInventory.GetCharacterItemAmount(charId, itemname, fromContainer) < itemAmount)
         {
             HUDHandler.SendNotification(player, 4, 5000, $"Die angegebene wegzuwerfende Anzahl ist nicht vorhanden ({itemname})."); return;
         }
         if (itemname == "Smartphone")
         {
             if (Characters.IsCharacterPhoneEquipped(charId))
             {
                 HUDHandler.SendNotification(player, 3, 2500, "Du musst dein Handy erst ausschalten / ablegen."); return;
             }
         }
         else if (itemname == "Rucksack")
         {
             if (Characters.GetCharacterBackpack(charId) == "Rucksack")
             {
                 if (CharactersInventory.GetCharacterItemAmount(charId, "Rucksack", "inventory") == itemAmount)
                 {
                     HUDHandler.SendNotification(player, 3, 5000, "Du musst deinen Rucksack erst ablegen, bevor du diesen wegwerfen kannst.");
                     return;
                 }
                 else
                 {
                     CharactersInventory.RemoveCharacterItemAmount(charId, itemname, itemAmount, fromContainer);
                     InventoryAnimation(player, "drop", 0);
                     HUDHandler.SendNotification(player, 2, 5000, $"Der Gegenstand {itemname} ({itemAmount}) wurde erfolgreich weggeworfen ({fromContainer}).");
                     return;
                 }
             }
             else
             {
                 CharactersInventory.RemoveCharacterItemAmount(charId, itemname, itemAmount, fromContainer);
                 InventoryAnimation(player, "drop", 0);
                 HUDHandler.SendNotification(player, 2, 5000, $"Der Gegenstand {itemname} ({itemAmount}) wurde erfolgreich weggeworfen ({fromContainer}).");
                 return;
             }
         }
         else if (itemname == "Tasche")
         {
             if (Characters.GetCharacterBackpack(charId) == "Tasche")
             {
                 if (CharactersInventory.GetCharacterItemAmount(charId, "Tasche", "inventory") == itemAmount)
                 {
                     HUDHandler.SendNotification(player, 3, 5000, "Du musst zuerst deine Tasche ablegen, bevor du diese wegwerfen kannst.");
                     return;
                 }
                 else
                 {
                     CharactersInventory.RemoveCharacterItemAmount(charId, itemname, itemAmount, fromContainer);
                     InventoryAnimation(player, "drop", 0);
                     HUDHandler.SendNotification(player, 2, 5000, $"Der Gegenstand {itemname} ({itemAmount}) wurde erfolgreich weggeworfen ({fromContainer}).");
                     RequestInventoryItems(player);
                     return;
                 }
             }
             else
             {
                 CharactersInventory.RemoveCharacterItemAmount(charId, itemname, itemAmount, fromContainer);
                 InventoryAnimation(player, "drop", 0);
                 HUDHandler.SendNotification(player, 2, 5000, $"Der Gegenstand {itemname} ({itemAmount}) wurde erfolgreich weggeworfen ({fromContainer}).");
                 RequestInventoryItems(player);
                 return;
             }
         }
         else if (ServerItems.GetItemType(itemname) == "weapon")
         {
             if ((string)Characters.GetCharacterWeapon(player, "PrimaryWeapon") == normalItemName || (string)Characters.GetCharacterWeapon(player, "SecondaryWeapon") == normalItemName || (string)Characters.GetCharacterWeapon(player, "SecondaryWeapon2") == normalItemName || (string)Characters.GetCharacterWeapon(player, "FistWeapon") == normalItemName)
             {
                 if (CharactersInventory.GetCharacterItemAmount(charId, normalItemName, fromContainer) == itemAmount)
                 {
                     HUDHandler.SendNotification(player, 3, 5000, "Du musst zuerst deine Waffe ablegen."); return;
                 }
             }
         }
         CharactersInventory.RemoveCharacterItemAmount(charId, itemname, itemAmount, fromContainer);
         InventoryAnimation(player, "drop", 0);
         HUDHandler.SendNotification(player, 2, 5000, $"Der Gegenstand {itemname} ({itemAmount}) wurde erfolgreich weggeworfen ({fromContainer}).");
         RequestInventoryItems(player);
     }
     catch (Exception e)
     {
         Alt.Log($"{e}");
     }
 }
Exemple #20
0
        public async Task UseItem(ClassicPlayer player, string itemname, int itemAmount, string fromContainer)
        {
            try
            {
                string ECData     = null,
                       CarKeyData = null;
                if (player == null || !player.Exists || itemname == "" || itemAmount <= 0 || fromContainer == "" || User.GetPlayerOnline(player) == 0)
                {
                    return;
                }
                if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                }
                if (ServerItems.IsItemUseable(ServerItems.ReturnNormalItemName(itemname)) == false)
                {
                    HUDHandler.SendNotification(player, 4, 5000, $"Dieser Gegenstand ist nicht benutzbar ({itemname})!"); return;
                }
                int charId = player.CharacterId;
                if (charId <= 0 || CharactersInventory.ExistCharacterItem(charId, itemname, fromContainer) == false)
                {
                    return;
                }
                if (CharactersInventory.GetCharacterItemAmount(charId, itemname, fromContainer) < itemAmount)
                {
                    HUDHandler.SendNotification(player, 4, 5000, $"Die angegeben zu nutzende Anzahl ist nicht vorhanden ({itemname})!"); return;
                }
                if (itemname.Contains("EC Karte"))
                {
                    string[] SplittedItemName = itemname.Split(' '); ECData = itemname.Replace("EC Karte ", ""); itemname = "EC Karte";
                }
                else if (itemname.Contains("Fahrzeugschluessel"))
                {
                    string[] SplittedItemName = itemname.Split(' '); CarKeyData = itemname.Replace("Fahrzeugschluessel ", ""); itemname = "Autoschluessel";
                }

                if (ServerItems.IsItemDesire(itemname))
                {
                    CharactersInventory.RemoveCharacterItemAmount(charId, itemname, itemAmount, fromContainer);
                    Characters.SetCharacterHunger(charId, Characters.GetCharacterHunger(charId) + ServerItems.GetItemDesireFood(itemname) * itemAmount);
                    Characters.SetCharacterThirst(charId, Characters.GetCharacterThirst(charId) + ServerItems.GetItemDesireDrink(itemname) * itemAmount);
                    player.EmitLocked("Client:HUD:UpdateDesire", Characters.GetCharacterHunger(charId), Characters.GetCharacterThirst(charId)); //HUD updaten
                }
                else if (itemname == "Beamtenschutzweste")
                {
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Beamtenschutzweste", 1, fromContainer);
                    Characters.SetCharacterArmor(charId, 100);
                    player.Armor = 100;
                }
                if (itemname == "Rucksack" || itemname == "Tasche")
                {
                    if (fromContainer == "backpack")
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Kleidungen & Taschen können nicht aus dem Rucksack aus benutzt werden."); return;
                    }
                    if (Characters.GetCharacterBackpack(charId) == "Rucksack")
                    {
                        if (itemname == "Rucksack")
                        {
                            if (CharactersInventory.GetCharacterBackpackItemCount(charId) == 0)
                            {
                                Characters.SetCharacterBackpack(player, "None");
                                HUDHandler.SendNotification(player, 2, 5000, "Du hast deinen Rucksack ausgezogen.");
                            }
                            else
                            {
                                HUDHandler.SendNotification(player, 4, 5000, "Du hast zuviele Sachen im Rucksack, du kannst deinen Rucksack nicht ablegen.");
                            }
                        }
                        else
                        {
                            HUDHandler.SendNotification(player, 3, 5000, "Du hast bereits eine Tasche angelegt, lege diese vorher ab um deinen Rucksack anzulegen.");
                        }
                    }
                    else if (Characters.GetCharacterBackpack(charId) == "Tasche")
                    {
                        if (itemname == "Tasche")
                        {
                            if (CharactersInventory.GetCharacterBackpackItemCount(charId) == 0)
                            {
                                Characters.SetCharacterBackpack(player, "None");
                                HUDHandler.SendNotification(player, 2, 5000, "Du hast deine Tasche ausgezogen.");
                            }
                            else
                            {
                                HUDHandler.SendNotification(player, 4, 5000, "Du hast zuviele Sachen in deiner Tasche, du kannst deine Tasche nicht ablegen.");
                            }
                        }
                        else
                        {
                            HUDHandler.SendNotification(player, 3, 5000, "Du hast bereits einen Rucksack angelegt, lege diesen vorher ab um deine Tasche anzulegen.");
                        }
                    }
                    else if (Characters.GetCharacterBackpack(charId) == "None")
                    {
                        Characters.SetCharacterBackpack(player, itemname);
                        HUDHandler.SendNotification(player, 2, 5000, "Du hast deine Tasche / deinen Rucksack angezogen.");
                    }
                }
                else if (itemname == "EC Karte")
                {
                    var atmPos = ServerATM.ServerATM_.FirstOrDefault(x => player.Position.IsInRange(new Position(x.posX, x.posY, x.posZ), 1f));
                    if (atmPos == null || player.IsInVehicle)
                    {
                        HUDHandler.SendNotification(player, 3, 5000, "Du bist an keinem ATM oder sitzt in einem Auto."); return;
                    }
                    int usingAccountNumber = Convert.ToInt32(ECData);
                    if (CharactersBank.GetBankAccountLockStatus(usingAccountNumber))
                    {
                        if (CharactersInventory.ExistCharacterItem(charId, "EC Karte " + usingAccountNumber, "inventory"))
                        {
                            CharactersInventory.RemoveCharacterItemAmount(charId, "EC Karte " + usingAccountNumber, 1, "inventory");
                        }
                        HUDHandler.SendNotification(player, 3, 5000, $"Ihre EC Karte wurde einzogen da diese gesperrt ist."); return;
                    }
                    player.EmitLocked("Client:ATM:BankATMcreateCEF", CharactersBank.GetBankAccountPIN(usingAccountNumber), usingAccountNumber, atmPos.zoneName);
                }
                else if (ServerItems.GetItemType(itemname) == "weapon")
                {
                    if (itemname.Contains("Munitionsbox"))
                    {
                        string wName = itemname.Replace(" Munitionsbox", "");
                        CharactersInventory.RemoveCharacterItemAmount(charId, itemname, itemAmount, fromContainer);
                        CharactersInventory.AddCharacterItem(charId, $"{wName} Munition", 30 * itemAmount, fromContainer);
                    }
                    else if (itemname.Contains("Munition"))
                    {
                        WeaponHandler.EquipCharacterWeapon(player, "Ammo", itemname, itemAmount, fromContainer);
                    }
                    else
                    {
                        WeaponHandler.EquipCharacterWeapon(player, "Weapon", itemname, 0, fromContainer);
                    }
                }
                else if (itemname == "Brecheisen")
                {
                    var house = ServerHouses.ServerHouses_.FirstOrDefault(x => x.ownerId > 0 && x.isLocked && ((ClassicColshape)x.entranceShape).IsInRange((ClassicPlayer)player));
                    if (house != null)
                    {
                        HouseHandler.BreakIntoHouse(player, house.id);
                        return;
                    }
                }
                else if (itemname == "Verbandskasten")
                {
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Verbandskasten", 1, fromContainer);
                    Characters.SetCharacterHealth(charId, 200);
                    player.Health = 200;
                }
                else if (itemname == "Benzinkanister" && player.IsInVehicle && player.Vehicle.Exists)
                {
                    if (ServerVehicles.GetVehicleFuel(player.Vehicle) >= ServerVehicles.GetVehicleFuelLimitOnHash(player.Vehicle.Model))
                    {
                        HUDHandler.SendNotification(player, 4, 2000, "Der Tank ist bereits voll."); return;
                    }
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Benzinkanister", 1, fromContainer);
                    ServerVehicles.SetVehicleFuel(player.Vehicle, ServerVehicles.GetVehicleFuel(player.Vehicle) + 15.0f);
                    HUDHandler.SendNotification(player, 2, 2000, "Du hast das Fahrzeug erfolgreich aufgetankt.");
                }
                else if (itemname == "Weste")
                {
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Weste", 1, fromContainer);
                    Characters.SetCharacterArmor(charId, 100);
                    player.Armor = 100;
                    if (Characters.GetCharacterGender(charId))
                    {
                        player.EmitLocked("Client:SpawnArea:setCharClothes", 9, 17, 2);
                    }
                    else
                    {
                        player.EmitLocked("Client:SpawnArea:setCharClothes", 9, 15, 2);
                    }
                }
                else if (itemname == "Pedalo")
                {
                    HUDHandler.SendNotification(player, 1, 3500, "Bruder muss los..");
                    player.EmitLocked("Client:Ragdoll:SetPedToRagdoll", true, 0);  //Ragdoll setzen
                    player.EmitLocked("Client:Ragdoll:SetPedToRagdoll", false, 0); //Ragdoll setzen
                }
                else if (itemname == "Kokain")
                {
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Kokain", 1, fromContainer);
                    HUDHandler.SendNotification(player, 2, 2000, "Du hast Koks gezogen du bist nun 15 Minuten effektiver.");
                    player.EmitLocked("Client:Inventory:PlayEffect", "DrugsMichaelAliensFight", 900000);
                    Characters.SetCharacterFastFarm(charId, true, 15);
                }
                else if (itemname == "Joint")
                {
                    if (player.Armor >= 60)
                    {
                        HUDHandler.SendNotification(player, 3, 2000, "Weiter kannst du dich nicht selbst heilen."); return;
                    }
                    CharactersInventory.RemoveCharacterItemAmount(charId, "Joint", 1, fromContainer);
                    Characters.SetCharacterArmor(charId, 15);
                    player.Armor = +15;
                }
                else if (itemname == "Smartphone")
                {
                    Alt.Log("Phone benutzt.");
                    if (Characters.IsCharacterPhoneEquipped(charId))
                    {
                        Alt.Log("Phone benutzt2.");
                        player.EmitLocked("Client:Smartphone:equipPhone", false, Characters.GetCharacterPhonenumber(charId), Characters.IsCharacterPhoneFlyModeEnabled(charId));
                        HUDHandler.SendNotification(player, 2, 1500, "Smartphone ausgeschaltet.");
                    }
                    else
                    {
                        Alt.Log("Phone benutzt3.");
                        player.EmitLocked("Client:Smartphone:equipPhone", true, Characters.GetCharacterPhonenumber(charId), Characters.IsCharacterPhoneFlyModeEnabled(charId));
                        HUDHandler.SendNotification(player, 2, 1500, "Smartphone eingeschaltet.");
                    }
                    Characters.SetCharacterPhoneEquipped(charId, !Characters.IsCharacterPhoneEquipped(charId));
                    SmartphoneHandler.RequestLSPDIntranet((ClassicPlayer)player);
                }

                if (ServerItems.hasItemAnimation(ServerItems.ReturnNormalItemName(itemname)))
                {
                    InventoryAnimation(player, ServerItems.GetItemAnimationName(ServerItems.ReturnNormalItemName(itemname)), 0);
                }

                RequestInventoryItems(player);
                //HUDHandler.SendNotification(player, 2, 5000, $"DEBUG: Der Gegenstand {itemname} ({itemAmount}) wurde erfolgreich aus ({fromContainer}) benutzt.");
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Exemple #21
0
        public async Task TakeItem(IPlayer player, int houseId, string itemName, int itemAmount)
        {
            try
            {
                if (player == null || !player.Exists || houseId <= 0 | itemAmount <= 0 || itemName == "" || itemName == "undefined")
                {
                    return;
                }
                int charId = (int)player.GetCharacterMetaId();
                if (charId <= 0)
                {
                    return;
                }
                if (!ServerHouses.ExistHouse(houseId))
                {
                    return;
                }
                if (!ServerHouses.HasHouseStorageUpgrade(houseId))
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Dieses Haus besitzt noch keinen ausgebauten Lagerplatz."); return;
                }
                if (player.Dimension - 10000 <= 0 || player.Dimension - 10000 != houseId)
                {
                    return;
                }
                if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                }
                if (!ServerHouses.ExistServerHouseStorageItem(houseId, itemName))
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Der Gegenstand existiert im Hauslager nicht."); return;
                }
                if (ServerHouses.GetServerHouseStorageItemAmount(houseId, itemName) < itemAmount)
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Soviele Gegenstände sind nicht im Hauslager."); return;
                }
                float itemWeight     = ServerItems.GetItemWeight(itemName) * itemAmount;
                float invWeight      = CharactersInventory.GetCharacterItemWeight(charId, "inventory");
                float backpackWeight = CharactersInventory.GetCharacterItemWeight(charId, "backpack");
                if (invWeight + itemWeight > 15f && backpackWeight + itemWeight > Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
                {
                    HUDHandler.SendNotification(player, 3, 5000, $"Du hast nicht genug Platz in deinen Taschen."); return;
                }
                ServerHouses.RemoveServerHouseStorageItemAmount(houseId, itemName, itemAmount);
                //ToDo: Log Eintrag
                if (invWeight + itemWeight <= 15f)
                {
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast {itemName} ({itemAmount}x) aus dem Hauslager genommen (Lagerort: Inventar).");
                    CharactersInventory.AddCharacterItem(charId, itemName, itemAmount, "inventory");
                    return;
                }

                if (Characters.GetCharacterBackpack(charId) != "None" && backpackWeight + itemWeight <= Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
                {
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast {itemName} ({itemAmount}x) aus dem Hauslager genommen (Lagerort: Rucksack / Tasche).");
                    CharactersInventory.AddCharacterItem(charId, itemName, itemAmount, "backpack");
                    return;
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }
Exemple #22
0
        public async Task PlayerSearchTakeItem(ClassicPlayer player, int givenTargetCharId, string itemName, string itemLocation, int itemAmount)
        {
            try
            {
                if (player == null || !player.Exists || givenTargetCharId <= 0 || itemName == "" || itemAmount <= 0 || itemLocation == "")
                {
                    return;
                }
                int charId = player.CharacterId;
                if (charId <= 0)
                {
                    return;
                }
                if (player.HasPlayerHandcuffs() || player.HasPlayerRopeCuffs())
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Wie willst du das mit Handschellen/Fesseln machen?"); return;
                }
                var targetPlayer = Alt.Server.GetPlayers().ToList().FirstOrDefault(x => x.GetCharacterMetaId() == (ulong)givenTargetCharId);
                int targetCharId = (int)targetPlayer.GetCharacterMetaId();
                if (targetCharId != givenTargetCharId)
                {
                    return;
                }
                if (targetPlayer == null || !targetPlayer.Exists)
                {
                    return;
                }
                if (!player.Position.IsInRange(targetPlayer.Position, 3f))
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Fehler: Du bist zuweit vom Spieler entfernt."); return;
                }
                if (!targetPlayer.HasPlayerHandcuffs() && !targetPlayer.HasPlayerRopeCuffs())
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Der Spieler ist nicht gefesselt."); return;
                }
                if (!ServerItems.IsItemDroppable(itemName) || !ServerItems.IsItemGiveable(itemName))
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Fehler: Diesen Gegenstand kannst du nicht entfernen."); return;
                }
                if (!CharactersInventory.ExistCharacterItem(targetCharId, itemName, itemLocation))
                {
                    HUDHandler.SendNotification(player, 4, 5000, "Fehler: Dieser Gegenstand existiert nicht mehr."); return;
                }
                if (CharactersInventory.IsItemActive(targetPlayer, itemName))
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Ausgerüstete Gegenstände können nicht entwendet werden."); return;
                }
                if (CharactersInventory.GetCharacterItemAmount(targetCharId, itemName, itemLocation) < itemAmount)
                {
                    HUDHandler.SendNotification(player, 3, 5000, "Fehler: Soviele Gegenstände hat der Spieler davon nicht."); return;
                }
                float itemWeight     = ServerItems.GetItemWeight(itemName) * itemAmount;
                float invWeight      = CharactersInventory.GetCharacterItemWeight(charId, "inventory");
                float backpackWeight = CharactersInventory.GetCharacterItemWeight(charId, "backpack");
                if (invWeight + itemWeight > 15f && backpackWeight + itemWeight > Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
                {
                    HUDHandler.SendNotification(player, 3, 5000, $"Du hast nicht genug Platz in deinen Taschen."); return;
                }
                CharactersInventory.RemoveCharacterItemAmount(targetCharId, itemName, itemAmount, itemLocation);
                if (invWeight + itemWeight <= 15f || itemName == "Bargeld" || itemWeight == 0f)
                {
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast der Person {itemName} ({itemAmount}x) entwendet. (Lagerort: Inventar).");
                    HUDHandler.SendNotification(targetPlayer, 2, 5000, $"Dir wurde der Gegenstand {itemName} ({itemAmount}x) aus dem Inventar entwendet.");
                    CharactersInventory.AddCharacterItem(charId, itemName, itemAmount, "inventory");
                    return;
                }

                if (Characters.GetCharacterBackpack(charId) != "None" && backpackWeight + itemWeight <= Characters.GetCharacterBackpackSize(Characters.GetCharacterBackpack(charId)))
                {
                    HUDHandler.SendNotification(player, 2, 5000, $"Du hast der Person {itemName} ({itemAmount}x) entwendet. (Lagerort: Rucksack/Tasche).");
                    HUDHandler.SendNotification(targetPlayer, 2, 5000, $"Dir wurde der Gegenstand {itemName} ({itemAmount}x) aus dem Rucksack entwendet.");
                    CharactersInventory.AddCharacterItem(charId, itemName, itemAmount, "backpack");
                    return;
                }
            }
            catch (Exception e)
            {
                Alt.Log($"{e}");
            }
        }