Jump to content

Recommended Posts

Posted (edited)

PepperyUnsteadyHermitcrab-size_restricte

This function aims to simplify mp.game.gameplay.displayOnscreenKeyboard usage by doing all the work for you and returning a promise.

 

Options

title: Title shown on the input box. Default: empty string

defaultText: Default value of the input box. Default: empty string

maxLength: Obvious enough, maximum length of the input. Default: 32

showMaxLength: If true, will display max length on title. Default: false

trimResult: Removes whitespace from the player's input. Default: true

rejectIfEmpty: If true, empty input causes promise rejection instead of resolving with an empty string. Default: true

timeout: If higher than 0, input box will close & promise will be rejected with the reason "timeout" if the player fails to write something in specified milliseconds. Default: 0

 

Rejection reasons

empty: When the player didn't write anything, needs rejectIfEmpty option to be true.

cancelled: When the player closes the input box.

keyboard_not_active: No idea on this one, it was in the native description so it's supported.

timeout: When the player fails to write something in the specified time, needs timeout option to be set.

 

Download

The function and example is on GitHub Gist: https://gist.github.com/root-cause/5137a2b71c922bd24534462595b84a0f

 

Notes

- Needs RAGE Multiplayer 1.1 and above since it uses GXT API.

Edited by rootcause
  • Like 2
  • Mask 1
  • Confused 1
  • 5 months later...

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...