Ejemplo n.º 1
0
        public override void onImageMount(ShapeBase obj, int slot, float dt)
        {
            GameConnection client = obj["client"];

            string ammoName = string.Empty;
            ammoName = this["ammo"].getName();

            int currentammo = 0;
            int ammountinClips = 0;
            if (isField("clip"))
                {
                if (obj.getInventory(this["ammo"]).AsBool())
                    {
                    obj.setImageAmmo(slot, true);
                    currentammo = obj.getInventory(this["ammo"]);
                    }
                else if (obj.getInventory(this["clip"]) > 0)
                    {
                    obj.setInventory(this["ammo"], this["ammo.maxInventory"].AsInt());
                    obj.setImageAmmo(slot, true);
                    currentammo = this["ammo.maxInventory"].AsInt();
                    ammountinClips += obj["remaining" + ammoName].AsInt();
                    }
                else
                    currentammo = obj["remaining" + ammoName].AsInt();

                ammountinClips = obj.getInventory(this["clip"]);
                ammountinClips *= this["ammo.maxInventory"].AsInt();

                if ((obj["client"] != string.Empty) && !obj["isAiControlled"].AsBool())
                    client.refreshWeaponHud(currentammo, this["item.previewImage"], this["item.reticle"], this["item.zoomReticle"], ammountinClips);
                }
            else if (this["ammo"] != string.Empty)
                {
                if (obj.getInventory(this["ammo"]).AsBool())
                    {
                    obj.setImageAmmo(slot, true);
                    currentammo = obj.getInventory(this["ammo"]);
                    }
                else
                    currentammo = 0;

                if (obj["client"] != string.Empty && !obj["isAiControlled"].AsBool())
                    client.refreshWeaponHud(1, this["item.previewImage"], this["item.reticle"], this["item.zoomReticle"], currentammo);
                }
        }
Ejemplo n.º 2
0
        public virtual void reloadAmmoClip(ShapeBase obj, int slot)
        {
            if (this != obj.getMountedImage(slot))
                return;

            if (!this.isField("clip"))
                return;

            if (obj.getInventory(this["clip"]) > 0)
                {
                obj.decInventory(this["clip"], 1);
                obj.setInventory(this["ammo"], this["ammo.maxInventory"].AsInt());

                obj.setImageAmmo(slot, true);
                }
            else
                {
                int amountInPocket = obj["remaining" + ((Item) this["ammo"]).getName()].AsInt();
                if (amountInPocket > 0)
                    {
                    obj["remaining" + ((Item) this["ammo"]).getName()] = "0";

                    obj.setInventory(this["ammo"], amountInPocket);
                    obj.setImageAmmo(slot, true);
                    }
                }
        }