/// <summary>
        /// Updates or creates a resource based on the resource identifier. The PUT operation is used to update or create a resource by identifier.  If the resource doesn't exist, the resource will be created using that identifier.  Additionally, natural key values cannot be changed using this operation, and will not be modified in the database.  If the resource &quot;id&quot; is provided in the JSON body, it will be ignored as well.
        /// </summary>
        /// <param name="id">A resource identifier specifying the resource to be updated.</param>
        /// <param name="IfMatch">The ETag header value used to prevent the PUT from updating a resource modified by another consumer.</param>
        /// <param name="body">The JSON representation of the &quot;weaponDescriptor&quot; resource to be updated.</param>
        /// <returns>A RestSharp <see cref="IRestResponse"/> instance containing the API response details.</returns>
        public IRestResponse PutWeaponDescriptor(string id, string IfMatch, WeaponDescriptor body)
        {
            var request = new RestRequest("/weaponDescriptors/{id}", Method.PUT);

            request.RequestFormat = DataFormat.Json;

            request.AddUrlSegment("id", id);
            // verify required params are set
            if (id == null || body == null)
            {
                throw new ArgumentException("API method call is missing required parameters");
            }
            request.AddHeader("If-Match", IfMatch);
            request.AddBody(body);
            var response = client.Execute(request);

            var location = response.Headers.FirstOrDefault(x => x.Name == "Location");

            if (location != null && !string.IsNullOrWhiteSpace(location.Value.ToString()))
            {
                body.id = location.Value.ToString().Split('/').Last();
            }
            return(response);
        }
示例#2
0
    /// <summary>
    /// Initialises all of the descriptors on this weapon, including all inherited weapon types
    /// </summary>
    protected virtual void InitialiseDescriptors()
    {
        this.weaponDesc = WeaponDescManager.instance.GetDescOfType( this.weaponType );

        // Find all fields in this type
        FieldInfo[] fields = this.GetType().GetFields();
        foreach ( FieldInfo field in fields )
        {
            // If that field is a pointer to a type of weapon descriptor, then set it
            System.Type fieldType = field.FieldType;
            if ( fieldType.IsSubclassOf( typeof(WeaponDescriptor) ) )
            {
                field.SetValue( this, this.weaponDesc );
            }
        }
    }
示例#3
0
        private void DoMagic()
        {
            Player player = Game.LocalPlayer;
            Ped    pc     = player.Character;

            if (CleanPlayer)
            {
                pc.ClearBlood();
            }
            if (FillHealth)
            {
                pc.Health = pc.MaxHealth;
            }
            if (FillArmour)
            {
                pc.Armor = 100;
            }

            if ((!OnlyRepairPoliceVehicles && pc.IsInAnyVehicle(false)) || (OnlyRepairPoliceVehicles && pc.IsInAnyPoliceVehicle))
            {
                if (RepairVehicle)
                {
                    pc.CurrentVehicle.Repair();
                }
                if (CleanVehicle)
                {
                    pc.CurrentVehicle.DirtLevel = 0f;
                }
            }

            // Add weapons

            pc.Inventory.Weapons.Clear();
            if (GiveFlashlight)
            {
                pc.Inventory.GiveFlashlight();
            }

            foreach (string s in WeaponPool.Split(','))
            {
                WeaponAsset wep        = new WeaponAsset();
                string[]    weaponData = s.Split('|');
                for (int x = 0; x < weaponData.Length; x++)
                {
                    string w = weaponData[x];

                    /*
                     * WEAPON_UNARMED WEAPON_ANIMAL WEAPON_COUGAR WEAPON_KNIFE WEAPON_NIGHTSTICK WEAPON_HAMMER WEAPON_BAT WEAPON_GOLFCLUB WEAPON_CROWBAR WEAPON_PISTOL WEAPON_COMBATPISTOL WEAPON_APPISTOL WEAPON_PISTOL50
                     * WEAPON_MICROSMG WEAPON_SMG WEAPON_ASSAULTSMG WEAPON_ASSAULTRIFLE WEAPON_CARBINERIFLE WEAPON_ADVANCEDRIFLE WEAPON_MG WEAPON_COMBATMG WEAPON_PUMPSHOTGUN WEAPON_SAWNOFFSHOTGUN WEAPON_ASSAULTSHOTGUN
                     * WEAPON_BULLPUPSHOTGUN WEAPON_STUNGUN WEAPON_SNIPERRIFLE WEAPON_HEAVYSNIPER WEAPON_REMOTESNIPER WEAPON_GRENADELAUNCHER WEAPON_GRENADELAUNCHER_SMOKE WEAPON_RPG WEAPON_PASSENGER_ROCKET
                     * WEAPON_AIRSTRIKE_ROCKET WEAPON_STINGER WEAPON_MINIGUN WEAPON_GRENADE WEAPON_STICKYBOMB WEAPON_SMOKEGRENADE WEAPON_BZGAS WEAPON_MOLOTOV WEAPON_FIREEXTINGUISHER WEAPON_PETROLCAN WEAPON_DIGISCANNER
                     * WEAPON_BRIEFCASE WEAPON_BRIEFCASE_02 WEAPON_BALL WEAPON_FLARE WEAPON_VEHICLE_ROCKET WEAPON_BARBED_WIRE WEAPON_DROWNING WEAPON_DROWNING_IN_VEHICLE WEAPON_BLEEDING WEAPON_ELECTRIC_FENCE
                     * WEAPON_EXPLOSION WEAPON_FALL WEAPON_EXHAUSTION WEAPON_HIT_BY_WATER_CANNON WEAPON_RAMMED_BY_CAR WEAPON_RUN_OVER_BY_CAR WEAPON_HELI_CRASH WEAPON_FIRE WEAPON_ANIMAL_RETRIEVER WEAPON_SMALL_DOG
                     * WEAPON_TIGER_SHARK WEAPON_HAMMERHEAD_SHARK WEAPON_KILLER_WHALE WEAPON_BOAR WEAPON_PIG WEAPON_COYOTE WEAPON_DEER WEAPON_HEN WEAPON_RABBIT WEAPON_CAT WEAPON_COW WEAPON_BIRD_CRAP
                     */
                    if (x == 0)
                    {
                        Game.Console.Print($"Attempting to add weapon {w} to player");
                        wep = new WeaponAsset(w);
#if DEBUG
                        Game.Console.Print($"{wep.Hash} // {wep.IsValid} // {wep.IsLoaded}");
#endif
                        if (!wep.IsValid)
                        {
                            continue;
                        }
                        if (!wep.IsLoaded)
                        {
                            wep.LoadAndWait();
                        }
                        WeaponDescriptor wd = new WeaponDescriptor(wep);
                        pc.Inventory.GiveNewWeapon(wep, (InfiniteAmmo ? short.MaxValue : /*(short)(wd.MagazineSize * (short)15)*/ AmmoCount), false);
                        continue;
                    }
                    Game.Console.Print($"Attempting to add component {w} to weapon");
                    pc.Inventory.AddComponentToWeapon(wep, w);
                }
            }

            Game.DisplayNotification("AlfredoRedux has completed tasks.");
        }