Functions
CreatePedDialog / Create
Function used to create ped dialog.
exports['sx-ped-dialog']:Create(options, callback)
interface PedOptions {
ped_model: string;
ped_name: string;
ped_group?: string;
interaction?: {
useKeyInteractions: boolean;
showLabelOverHead: boolean;
distCanInteract: number; // float
distShowLabel: number; // float
textOverHead?: string;
interactionText?: string;
};
cam: {
enabled: boolean;
offset?: vector3;
fov?: number; // float
pointZOffset?: number; // float
};
pos: {
coords: vector3,
heading: number; // float
};
blip?: {
sprite: number;
color: number;
scale: number; // float
name: string;
shortRange: boolean;
},
animations: {
idleAnim?: {
dict?: string;
name?: string;
scenario?: string;
};
openAnim?: {
dict?: string;
name?: string;
scenario?: string;
// If you don't specify duration animation will be cancelled when player closes menu.
duration?: number; // In miliseconds
};
closeAnim?: {
dict?: string;
name?: string;
scenario?: string;
// Specify duration when to reset back to idle animation
duration: number;
};
};
// Will be explained below
dialog?: (create: Function, close: Function) => void;
}
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.
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.
AddEventHandler('sx-ped-dialog:dialogAction', function(dialogId, action)
-- Handle action here.
end)
Last updated