Пример #1
0
        public static void CreateItemsDroped(string Name, int Amount, int?Ammo)
        {
            Vector3 PlayerCoords  = GetEntityCoords(PlayerPedId(), true);
            float   PlayerHeading = GetEntityHeading(PlayerPedId());
            int     Object        = CreateObject(GetHashKey("prop_big_bag_01"), PlayerCoords.X, PlayerCoords.Y, PlayerCoords.Z - 1f, false, false, true);

            SetEntityHeading(Object, PlayerHeading);
            SetEntityCollision(Object, false, false);

            dynamic Drop = new ExpandoObject();

            if (Enum.IsDefined(typeof(Weapon.Hash), Name))
            {
                Drop.Coords = GetEntityCoords(Object, false);
                Drop.Name   = Name;
                Drop.Amount = 1;
                Drop.Ammo   = Ammo;
            }
            else
            {
                Drop.Coords = GetEntityCoords(Object, false);
                Drop.Name   = Name;
                Drop.Amount = Amount;
                Drop.Ammo   = 0;
            }

            bool found = false;

            foreach (var i in ItemsDroped.Keys)
            {
                float Distance = Vdist(Drop.Coords.X, Drop.Coords.Y, Drop.Coords.Z, ItemsDroped[i.ToString()].Coords.X, ItemsDroped[i.ToString()].Coords.Y, ItemsDroped[i.ToString()].Coords.Z);

                if (Distance < 1.2f)
                {
                    DeleteObject(ref Object);
                    Drop.Coords = ItemsDroped[i.ToString()].Coords;

                    if (!Enum.IsDefined(typeof(Weapon.Hash), Name))
                    {
                        if (ItemsDroped[i.ToString()].Name == Name)
                        {
                            ItemsDroped[i.ToString()].Amount += Amount;
                            found = true;
                            break;
                        }
                    }
                }
            }
            if (!found)
            {
                ItemsDroped.Add(ItemsDropedID.ToString(), Drop);
                ItemsDropedID += 1;
            }

            TriggerServerEvent("Inventory:UpdateItemsDroped", ItemsDroped, ItemsDropedID);

            LootNUI(true);
        }
Пример #2
0
        private void UpdateItemLootablee(string ID)
        {
            foreach (var i in ItemsDroped.Keys)
            {
                if (i.ToString() == ID)
                {
                    ItemsDroped[i.ToString()].Amount -= 1;
                    break;
                }
            }
            if (ItemsDroped[ID].Amount < 1)
            {
                ItemsDroped.Remove(ID);
            }

            TriggerServerEvent("Inventory:UpdateItemsDroped", ItemsDroped, ItemsDropedID);

            UpdateLootNUI();
            RemoveObjectDrop();
        }