forked from Simnation/Main
edit
This commit is contained in:
parent
be02d05ba8
commit
fc7ea910e9
35 changed files with 11992 additions and 1 deletions
|
@ -0,0 +1,88 @@
|
|||
---@type number | nil
|
||||
local cam = nil
|
||||
---@type table | nil
|
||||
local currentDialogue = nil
|
||||
|
||||
---@param ped number
|
||||
local createCam = function(ped)
|
||||
local coords = GetEntityCoords(ped, true)
|
||||
local x, y, z = coords.x + GetEntityForwardX(ped) * 1.2, coords.y + GetEntityForwardY(ped) * 1.2, coords.z + 0.52
|
||||
local camRot = GetEntityRotation(ped, 2)
|
||||
cam = CreateCamWithParams("DEFAULT_SCRIPTED_CAMERA", x, y, z, camRot.x, camRot.y, camRot.z + 181.0, GetGameplayCamFov(), false, 0)
|
||||
SetCamActive(cam, true)
|
||||
RenderScriptCams(true, true, 2000, true, true)
|
||||
end
|
||||
|
||||
local destroyCamera = function()
|
||||
RenderScriptCams(false, true, 2000, true, false)
|
||||
DestroyCam(cam, false)
|
||||
end
|
||||
|
||||
---@param data table
|
||||
local showDialogue = function(data)
|
||||
if data.ped then
|
||||
createCam(data.ped)
|
||||
end
|
||||
|
||||
for ok, ov in pairs(data.options) do
|
||||
if ov.canInteract == nil then ov.canInteract = true end
|
||||
end
|
||||
|
||||
currentDialogue = data
|
||||
|
||||
SetEntityAlpha(cache.ped, 0, true)
|
||||
|
||||
SendNUIMessage({
|
||||
action = 'dialogue',
|
||||
data = {
|
||||
label = data.label,
|
||||
speech = data.speech,
|
||||
options = data.options,
|
||||
}
|
||||
})
|
||||
SendNUIMessage({
|
||||
action = 'setVisibleDialogue',
|
||||
data = true
|
||||
})
|
||||
SetNuiFocus(true, true)
|
||||
end
|
||||
exports("showDialogue", showDialogue)
|
||||
|
||||
RegisterNuiCallback('executeAction', function(data, cb)
|
||||
if data.options then
|
||||
for ok, ov in pairs(currentDialogue.options) do
|
||||
if ov.id == data.id then
|
||||
if ov.action then
|
||||
ov.action()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if data.close then
|
||||
SendNUIMessage({
|
||||
action = 'setVisibleDialogue',
|
||||
data = false
|
||||
})
|
||||
SetNuiFocus(false, false)
|
||||
destroyCamera()
|
||||
ResetEntityAlpha(cache.ped)
|
||||
currentDialogue = nil
|
||||
end
|
||||
cb(true)
|
||||
end)
|
||||
|
||||
RegisterNuiCallback('hideFrame', function(data, cb)
|
||||
SendNUIMessage({
|
||||
action = data.name,
|
||||
data = false
|
||||
})
|
||||
SetNuiFocus(false, false)
|
||||
|
||||
if data.name then
|
||||
destroyCamera()
|
||||
ResetEntityAlpha(cache.ped)
|
||||
currentDialogue = nil
|
||||
end
|
||||
cb(true)
|
||||
end)
|
Loading…
Add table
Add a link
Reference in a new issue