mirror of
https://github.com/darksaid98/overextended.github.io.git
synced 2026-12-01 22:21:48 +00:00
* refactor: Add h1 headers to all pages missing it * refactor: missed example h3 * change hooks example heading to bold text --------- Co-authored-by: Luke <[email protected]>
113 lines
2.5 KiB
Plaintext
113 lines
2.5 KiB
Plaintext
---
|
|
title: Alert Dialog
|
|
---
|
|
|
|
import { Tabs, Tab } from 'nextra-theme-docs';
|
|
import { Callout } from 'nextra/components';
|
|
|
|
# Alert Dialog
|
|
|
|
Simple alert dialog that can display a message to the player.
|
|
Returns whether the player pressed the confirm button or canceled the dialog.
|
|
|
|
## lib.alertDialog
|
|
|
|
<Tabs items={["Lua", "JS"]}>
|
|
<Tab>
|
|
<Tabs items={["Client", "Server"]}>
|
|
<Tab>
|
|
```lua
|
|
lib.alertDialog(data)
|
|
```
|
|
</Tab>
|
|
<Tab>
|
|
```lua
|
|
TriggerClientEvent('ox_lib:alertDialog', source, data)
|
|
```
|
|
</Tab>
|
|
</Tabs>
|
|
</Tab>
|
|
<Tab>
|
|
<Callout>
|
|
This function is **asynchronous** requiring you to do a `.then` callback on the promise or make your function `async`.
|
|
</Callout>
|
|
|
|
```ts
|
|
import lib from '@overextended/ox_lib/client';
|
|
|
|
lib.alertDialog(data);
|
|
```
|
|
</Tab>
|
|
</Tabs>
|
|
|
|
- data: `table` (`object`)
|
|
- header: `string`
|
|
- Dialog title.
|
|
- content: `string`
|
|
- Dialog body content, supports markdown.
|
|
- centered?: `boolean`
|
|
- Centers the dialog vertically and horizontally.
|
|
- cancel?: `boolean`
|
|
- Displays a cancel button (ESC is still available if this is not defined).
|
|
- size?: `'xs'` or `'sm'` or `'md'` or `'lg'` or `'xl'`
|
|
- overflow?: `boolean`
|
|
- labels?: `table`
|
|
- Allows you to define the displayed labels for cancel and/or confirm buttons.
|
|
- cancel?: `string`
|
|
- confirm?: `string`
|
|
|
|
Returns `'confirm'` if the player pressed the confirm button, otherwise if the player pressed the cancel button
|
|
or has exited the dialog with ESC the return will be `'cancel'`.
|
|
|
|
## lib.closeAlertDialog
|
|
|
|
Force closes the active alert dialog and sets its return data as `nil`
|
|
|
|
<Tabs items={["Lua", "JS"]}>
|
|
<Tab>
|
|
```lua
|
|
lib.closeAlertDialog()
|
|
```
|
|
</Tab>
|
|
<Tab>
|
|
```ts
|
|
import lib from '@overextended/ox_lib/client';
|
|
|
|
lib.closeAlertDialog();
|
|
```
|
|
</Tab>
|
|
</Tabs>
|
|
|
|
## Example
|
|
|
|
<Tabs items={["Lua", "JS"]}>
|
|
<Tab>
|
|
```lua
|
|
local alert = lib.alertDialog({
|
|
header = 'Hello there',
|
|
content = 'General Kenobi \n Markdown support!',
|
|
centered = true,
|
|
cancel = true
|
|
})
|
|
|
|
print(alert)
|
|
```
|
|
</Tab>
|
|
<Tab>
|
|
```ts
|
|
import lib from '@overextended/ox_lib/client';
|
|
|
|
const alert = await lib.alertDialog({
|
|
header: 'Hello there',
|
|
content: 'General Kenobi \n Markdown support!',
|
|
centered: true,
|
|
cancel: true,
|
|
});
|
|
|
|
console.log(alert);
|
|
```
|
|
</Tab>
|
|
</Tabs>
|
|
|
|

|