type callback = (data: CallbackData) => void;
interface CallbackData {
id: string; // Unique dialog ID, used to open dialogs
ped: Entity;
coords: vector3;
}
Dialog Function
Function that should be passed to dialog options dialog . You will have two functions to control your dialog flow, create and close.
If you set the dialog button action to close you don't need to handle that action; it will be automatically managed by the script.
local dialogFlow = function(create, close)
create(options, function(action)
if action == 'action_1' then
close()
return
end
create(options2, function(action2)
if action2 == 'action_44444' then
-- do some stuff or create another menu
end
end)
end)
end
type create = (options: DialogOptions, callback: CallbackFunction) => void
type CallbackFunction = (action: string) => void;
type close = () => void;
interface DialogOptions {
message: string;
buttons: DialogButton[];
typeWriter: {
enabled: boolean;
duration?: number; // in miliseconds
// Players will not be able to click any buttons until typewriter is finished.
disableButtons: boolean;
}
}
interface DialogButton {
text: string;
action: string;
}
RemovePedDialog / Remove
exports['sx-ped-dialog']:Remove(dialogId)
dialogId: string
Function used to delete the ped and completely remove everything that was created when adding that ped.
OpenDialogMenu / Open
exports['sx-ped-dialog']:Open(dialogId)
dialogId: string
Function to trigger dialog menu flow.
CloseMenu / Close
exports['sx-ped-dialog']:Close()
Function to close any open dialog.
Action event
Script also sends client side event when player clicks on the action.