Exemplo n.º 1
0
        /// <summary>
        /// Creates an input box for the user to input text using the keyboard.
        /// </summary>
        /// <param name="windowTitle">The title of the input box window.</param>
        /// <param name="maxLength">The maximum length of text input allowed.</param>
        /// <param name="defaultText">The default text.</param>
        /// <returns>The <see cref="string"/> of what the user entered or <see cref="string.Empty"/> if the user canceled.</returns>
        public static string GetUserInput(WindowTitle windowTitle, string defaultText, int maxLength)
        {
            Input.PauseKeyboardEvents(true);

            Function.Call(Hash.DISPLAY_ONSCREEN_KEYBOARD, true, _windowTitles[(int)windowTitle], MemoryAccess.NullString, defaultText, MemoryAccess.NullString, MemoryAccess.NullString, MemoryAccess.NullString, maxLength + 1);

            while (Function.Call <int>(Hash.UPDATE_ONSCREEN_KEYBOARD) == 0)
            {
                Script.YieldExecuting();
            }

            Input.PauseKeyboardEvents(false);

            return(Function.Call <string>(Hash.GET_ONSCREEN_KEYBOARD_RESULT));
        }
Exemplo n.º 2
0
        /// <summary>
        /// Creates an input box for enabling a user to input text using the keyboard
        /// </summary>
        /// <param name="windowTitle">The Title of the Window.</param>
        /// <param name="defaultText">The default text.</param>
        /// <param name="maxLength">The maximum length of input allowed</param>
        /// <returns>The <see cref="string"/> of what the user entered, If the user cancelled <see cref="string.Empty"/> is returned</returns>
        public static string GetUserInput(WindowTitle windowTitle, string defaultText, int maxLength)
        {
            Input.PauseKeyboardEvents(true);

            // int p0, char* windowTitle, char* p2, char* defaultText, char* defaultConcat1, char* defaultConcat2, char* defaultConcat3, int maxInputLength
            Function.Call(Hash.DISPLAY_ONSCREEN_KEYBOARD, true, windowTitle.ToString(), string.Empty, defaultText, string.Empty, string.Empty, string.Empty, maxLength + 1);

            while (Function.Call <int>(Hash.UPDATE_ONSCREEN_KEYBOARD) == 0)
            {
                Script.YieldExecuting();
            }

            Input.PauseKeyboardEvents(false);

            return(Function.Call <string>(Hash.GET_ONSCREEN_KEYBOARD_RESULT));
        }
Exemplo n.º 3
0
        public bool Request(int timeout)
        {
            Request();

            DateTime endtime = timeout >= 0 ? DateTime.UtcNow + new TimeSpan(0, 0, 0, 0, timeout) : DateTime.MaxValue;

            while (!IsLoaded)
            {
                Script.YieldExecuting();

                if (DateTime.UtcNow >= endtime)
                {
                    return(false);
                }
            }

            return(true);
        }
Exemplo n.º 4
0
        public void PlayAnimation(string animDict, string animName, float blendInSpeed, float blendOutSpeed, int duration, AnimationFlags flags, float playbackRate)
        {
            Function.Call(Hash.REQUEST_ANIM_DICT, animDict);

            DateTime endtime = DateTime.UtcNow + new TimeSpan(0, 0, 0, 0, 1000);

            while (!Function.Call <bool>(Hash.HAS_ANIM_DICT_LOADED, animDict))
            {
                Script.YieldExecuting();

                if (DateTime.UtcNow >= endtime)
                {
                    return;
                }
            }

            Function.Call(Hash.TASK_PLAY_ANIM, _ped.Handle, animDict, animName, blendInSpeed, blendOutSpeed, duration, flags, playbackRate, 0, 0, 0);
        }
Exemplo n.º 5
0
 public bool RequestAdditionTextFile(int timeout = 1000)
 {
     if (!Function.Call <bool>(Hash.HAS_THIS_ADDITIONAL_TEXT_LOADED, "mod_mnu", 10))
     {
         Function.Call(Hash.CLEAR_ADDITIONAL_TEXT, 10, true);
         Function.Call(Hash.REQUEST_ADDITIONAL_TEXT, "mod_mnu", 10);
         int end = Game.GameTime + timeout;
         {
             while (Game.GameTime < end)
             {
                 if (Function.Call <bool>(Hash.HAS_THIS_ADDITIONAL_TEXT_LOADED, "mod_mnu", 10))
                 {
                     return(true);
                 }
                 Script.YieldExecuting();
             }
             return(false);
         }
     }
     return(true);
 }