private void getLoadout(dynamic loadout)
        {
            Debug.WriteLine(API.PlayerPedId().ToString());
            foreach (var row in loadout)
            {
                JArray                   componentes = Newtonsoft.Json.JsonConvert.DeserializeObject(row.components.ToString());
                JObject                  amunitions  = Newtonsoft.Json.JsonConvert.DeserializeObject(row.ammo.ToString());
                List <string>            components  = new List <string>();
                Dictionary <string, int> ammos       = new Dictionary <string, int>();
                foreach (JToken componente in componentes)
                {
                    components.Add(componente.ToString());
                }

                foreach (JProperty amunition in amunitions.Properties())
                {
                    ammos.Add(amunition.Name, int.Parse(amunition.Value.ToString()));
                }
                Debug.WriteLine(row.used.ToString());
                bool auused = false;
                if (row.used == 1)
                {
                    auused = true;
                }
                WeaponClass auxweapon = new WeaponClass(int.Parse(row.id.ToString()), row.identifier.ToString(), row.name.ToString(), ammos, components, auused);
                userWeapons.Add(auxweapon.getId(), auxweapon);
                if (auxweapon.getUsed())
                {
                    Utils.useWeapon(auxweapon.getId());
                }
            }
        }
Beispiel #2
0
        private void NUIDropItem(ExpandoObject obj)
        {
            Dictionary <string, dynamic> aux = Utils.expandoProcessing(obj);
            string itemname = aux["item"];
            string type     = aux["type"].ToString();

            Debug.WriteLine(type);
            Debug.WriteLine(itemname);
            if (type == "item_money")
            {
                TriggerServerEvent("vorpinventory:serverDropMoney", double.Parse(aux["number"].ToString()));
                Debug.WriteLine("Soltando dinero");
                Debug.WriteLine("Soltando dinero");
            }
            else if (type == "item_standard")
            {
                if (int.Parse(aux["number"].ToString()) > 0 && vorp_inventoryClient.useritems[itemname].getCount() >= int.Parse(aux["number"].ToString()))
                {
                    TriggerServerEvent("vorpinventory:serverDropItem", itemname, int.Parse(aux["number"].ToString()), 1);
                    vorp_inventoryClient.useritems[itemname].quitCount(int.Parse(aux["number"].ToString()));
                    //Debug.Write(vorp_inventoryClient.useritems[itemname].getCount().ToString());
                    if (vorp_inventoryClient.useritems[itemname].getCount() == 0)
                    {
                        vorp_inventoryClient.useritems.Remove(itemname);
                    }
                }
            }
            else
            {
                //Function.Call((Hash) 0x4899CB088EDF59B8, API.PlayerPedId(), (uint) int.Parse(aux["hash"]),false,false);
                Debug.WriteLine("Tirando Arma");
                Debug.WriteLine(aux["id"].ToString());
                TriggerServerEvent("vorpinventory:serverDropWeapon", int.Parse(aux["id"].ToString()));
                if (vorp_inventoryClient.userWeapons.ContainsKey(int.Parse(aux["id"].ToString())))
                {
                    WeaponClass wp = vorp_inventoryClient.userWeapons[int.Parse(aux["id"].ToString())];
                    if (wp.getUsed())
                    {
                        wp.setUsed(false);
                        API.RemoveWeaponFromPed(API.PlayerPedId(), (uint)API.GetHashKey(wp.getName()),
                                                true, 0);
                    }
                    vorp_inventoryClient.userWeapons.Remove(int.Parse(aux["id"].ToString()));
                }
            }
            LoadInv();
        }
Beispiel #3
0
        public async Task dropallPlease()
        {
            await Delay(200);

            if (GetConfig.Config["DropOnRespawn"]["Items"].ToObject <bool>())
            {
                Dictionary <string, ItemClass> items = vorp_inventoryClient.useritems.ToDictionary(p => p.Key, p => p.Value);
                foreach (var item in items.Values)
                {
                    TriggerServerEvent("vorpinventory:serverDropItem", item.getName(), item.getCount(), 1);
                    vorp_inventoryClient.useritems[item.getName()].quitCount(item.getCount());
                    //Debug.Write(vorp_inventoryClient.useritems[itemname].getCount().ToString());
                    if (vorp_inventoryClient.useritems[item.getName()].getCount() == 0)
                    {
                        vorp_inventoryClient.useritems.Remove(item.getName());
                    }
                    await Delay(200);
                }
            }

            if (GetConfig.Config["DropOnRespawn"]["Weapons"].ToObject <bool>())
            {
                Dictionary <int, WeaponClass> weapons = vorp_inventoryClient.userWeapons.ToDictionary(p => p.Key, p => p.Value);
                foreach (var weapon in weapons)
                {
                    TriggerServerEvent("vorpinventory:serverDropWeapon", weapon.Key);
                    if (vorp_inventoryClient.userWeapons.ContainsKey(weapon.Key))
                    {
                        WeaponClass wp = vorp_inventoryClient.userWeapons[weapon.Key];
                        if (wp.getUsed())
                        {
                            wp.setUsed(false);
                            API.RemoveWeaponFromPed(API.PlayerPedId(), (uint)API.GetHashKey(wp.getName()),
                                                    true, 0);
                        }
                        vorp_inventoryClient.userWeapons.Remove(weapon.Key);
                    }
                    await Delay(200);
                }
            }
            await Delay(800);

            dropAll = false;
        }