using GTA;
using System;
using System.IO;
using System.Windows.Forms;
using GTA.Native;
using GTA.Math;

public class MaskAlwaysOn : Script
{
    private Prop mask;
    private bool maskOn = false;
    public MaskAlwaysOn()
    {
        KeyUp += OnKeyUp;
    }

    void OnKeyUp(object sender, KeyEventArgs e)
    {
        Ped playerPed = Game.Player.Character;
        if (e.KeyCode == Keys.NumPad7)
        {
            if (maskOn)
            {
                if (mask != null)
                {
                    mask.Detach();
                    mask.Delete();
                }
                maskOn = false;
            }
            else
            {
                mask = World.CreateProp(new Model("prop_welding_mask_01"), Vector3.Zero, false, false);
                mask.FreezePosition = true;
                mask.IsInvincible = true;
                Function.Call(Hash.SET_ENTITY_PROOFS, mask, true, true, true, true, true, true, true, true);
                mask.AttachTo(playerPed, Function.Call<int>(Hash.GET_PED_BONE_INDEX, playerPed.Handle, Bone.FACIAL_facialRoot.GetHashCode()), new Vector3(0, .1f, 0), new Vector3(90 * 3, 0, 0));
                maskOn = true;
            }
        }
    }
}