Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/floydya/rebar-confirm-dialog
Rebar plugin for asking player to accept/decline an action
https://github.com/floydya/rebar-confirm-dialog
Last synced: about 1 month ago
JSON representation
Rebar plugin for asking player to accept/decline an action
- Host: GitHub
- URL: https://github.com/floydya/rebar-confirm-dialog
- Owner: floydya
- Created: 2024-07-19T12:13:38.000Z (5 months ago)
- Default Branch: main
- Last Pushed: 2024-07-21T10:59:16.000Z (5 months ago)
- Last Synced: 2024-10-12T13:10:55.534Z (2 months ago)
- Language: TypeScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Confirm Dialog for Rebar
The Confirm Dialog plugin provides a way to display a confirmation dialog and handle the user's response. The plugin also has a timeout feature and the option to trigger a "NO" response on it.
## Installation
1. [Download](https://github.com/floydya/rebar-confirm-dialog/archive/refs/heads/main.zip) the repo.
2. Put the directory into `src/plugins` folder of your Rebar project.
3. That's all, folks!## Usage
```typescript
const useConfirmDialog = Rebar.useApi().get('confirm-dialog');const created = useConfirmDialog(player).create({
title: 'Hello',
message: 'Do you want to continue?',
callback: (player: alt.Player, result: boolean) => {
if (result) {
// User pressed Y.
} else {
// User pressed N.
}
},
showTime: 10 * 1000, // 10 seconds
});// This will let you know if confirmation dialog was created for player.
// The only scenario, when you can get `false` - player already has an active dialog.
console.log(created);useConfirmDialog(player).create({
title: 'Hello',
message: 'Any other message',
callback: (player: alt.Player, result: boolean) => {
if (result) {
console.log("Player answered 'YES'");
} else {
console.log("Player answered 'NO' or dialog timed out.");
}
},
// By default, it will just destroy the dialog,
// but if you want to trigger "NO" result, use this:
triggerNoOnTimeout: true,
});
```### Default dialog show time could be configured with ENV variable:
```
CONFIRM_DIALOG_DEFAULT_SHOW_TIME=15000
```> [!NOTE]
> By default it equals to 10 seconds(10000).