forked from Simnation/Main
edit
This commit is contained in:
parent
be02d05ba8
commit
fc7ea910e9
35 changed files with 11992 additions and 1 deletions
20
resources/[tools]/mt_lib/modules/createBlip/client.lua
Normal file
20
resources/[tools]/mt_lib/modules/createBlip/client.lua
Normal file
|
@ -0,0 +1,20 @@
|
|||
---@param coords table
|
||||
---@param sprite number
|
||||
---@param display number
|
||||
---@param scale number
|
||||
---@param color number
|
||||
---@param label string
|
||||
---@return integer
|
||||
local createBlip = function(coords, sprite, display, scale, color, label)
|
||||
local blip = AddBlipForCoord(coords.x, coords.y, coords.z)
|
||||
SetBlipSprite(blip, sprite)
|
||||
SetBlipDisplay(blip, display)
|
||||
SetBlipAsShortRange(blip, true)
|
||||
SetBlipScale(blip, scale)
|
||||
SetBlipColour(blip, color)
|
||||
BeginTextCommandSetBlipName("STRING")
|
||||
AddTextComponentSubstringPlayerName(label)
|
||||
EndTextCommandSetBlipName(blip)
|
||||
return blip
|
||||
end
|
||||
exports("createBlip", createBlip)
|
24
resources/[tools]/mt_lib/modules/createPed/client.lua
Normal file
24
resources/[tools]/mt_lib/modules/createPed/client.lua
Normal file
|
@ -0,0 +1,24 @@
|
|||
---@param coords table
|
||||
---@param model string
|
||||
---@param anim table
|
||||
local createPed = function(coords, model, anim)
|
||||
lib.requestModel(model, 5)
|
||||
local ped = CreatePed(4, GetHashKey(model), coords.x, coords.y, coords.z, coords.w, false, true)
|
||||
if DoesEntityExist(ped) then
|
||||
SetEntityHeading(ped, coords.w)
|
||||
FreezeEntityPosition(ped, true)
|
||||
SetEntityInvincible(ped, true)
|
||||
SetBlockingOfNonTemporaryEvents(ped, true)
|
||||
if anim.scenario then
|
||||
TaskStartScenarioInPlace(ped, anim.scenario, 0, true)
|
||||
elseif anim.dict and anim.clip then
|
||||
lib.requestAnimDict(anim.dict, 5)
|
||||
TaskPlayAnim(ped, anim.dict, anim.clip, 8.0, 0.0, -1, 1, 0.0, 0, 0, 0)
|
||||
end
|
||||
return ped
|
||||
else
|
||||
print("Failed to create ped: " .. model)
|
||||
return nil
|
||||
end
|
||||
end
|
||||
exports("createPed", createPed)
|
17
resources/[tools]/mt_lib/modules/createProp/client.lua
Normal file
17
resources/[tools]/mt_lib/modules/createProp/client.lua
Normal file
|
@ -0,0 +1,17 @@
|
|||
---@param model string
|
||||
---@param coords table
|
||||
---@param heading number
|
||||
---@return integer | nil
|
||||
local createProp = function(model, coords, heading)
|
||||
lib.requestModel(model, 5)
|
||||
local prop = CreateObject(GetHashKey(model), coords.x, coords.y, coords.z, false, false, false)
|
||||
if DoesEntityExist(prop) then
|
||||
SetEntityHeading(prop, heading)
|
||||
FreezeEntityPosition(prop, true)
|
||||
return prop
|
||||
else
|
||||
print("Failed to create prop: " .. model)
|
||||
return nil
|
||||
end
|
||||
end
|
||||
exports("createProp", createProp)
|
|
@ -0,0 +1,43 @@
|
|||
local points = {}
|
||||
|
||||
---@param id string
|
||||
---@param coords table
|
||||
---@param distance number
|
||||
---@param label string
|
||||
---@param key number
|
||||
---@param keyLabel string
|
||||
---@param onClick function
|
||||
---@param canInteract function | boolean
|
||||
local createInteractionPoint = function(id, coords, distance, label, key, keyLabel, onClick, canInteract)
|
||||
points[id] = lib.points.new({
|
||||
coords = coords,
|
||||
distance = distance,
|
||||
onEnter = function()
|
||||
if not canInteract then return end
|
||||
exports.mt_lib:showTextUI(label, keyLabel, 'bottom')
|
||||
end,
|
||||
onExit = function()
|
||||
exports.mt_lib:hideTextUI()
|
||||
end,
|
||||
nearby = function()
|
||||
if canInteract and IsControlJustPressed(0, key) then
|
||||
onClick()
|
||||
end
|
||||
end
|
||||
})
|
||||
end
|
||||
exports("createInteractionPoint", createInteractionPoint)
|
||||
|
||||
---@param id string
|
||||
local removeInteractionPoint = function(id)
|
||||
if not points[id] then return end
|
||||
points[id]:remove()
|
||||
exports.mt_lib:hideTextUI()
|
||||
end
|
||||
exports("removeInteractionPoint", removeInteractionPoint)
|
||||
|
||||
---@return table | nil
|
||||
local getCreatedPoints = function()
|
||||
return points
|
||||
end
|
||||
exports("getCreatedPoints", getCreatedPoints)
|
|
@ -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)
|
|
@ -0,0 +1,24 @@
|
|||
---@param title string
|
||||
---@param text string
|
||||
local showMissionStatus = function(title, text)
|
||||
SendNUIMessage({
|
||||
action = 'missionStatus',
|
||||
data = {
|
||||
title = title,
|
||||
text = text,
|
||||
}
|
||||
})
|
||||
SendNUIMessage({
|
||||
action = 'setVisibleMissionStatus',
|
||||
data = true
|
||||
})
|
||||
end
|
||||
exports("showMissionStatus", showMissionStatus)
|
||||
|
||||
local hideMissionStatus = function()
|
||||
SendNUIMessage({
|
||||
action = 'setVisibleMissionStatus',
|
||||
data = false
|
||||
})
|
||||
end
|
||||
exports("hideMissionStatus", hideMissionStatus)
|
26
resources/[tools]/mt_lib/modules/interface/textUI/client.lua
Normal file
26
resources/[tools]/mt_lib/modules/interface/textUI/client.lua
Normal file
|
@ -0,0 +1,26 @@
|
|||
---@param label string
|
||||
---@param key string
|
||||
---@param position string
|
||||
local showTextUI = function(label, key, position)
|
||||
SendNUIMessage({
|
||||
action = 'textUI',
|
||||
data = {
|
||||
label = label,
|
||||
key = key,
|
||||
position = position,
|
||||
}
|
||||
})
|
||||
SendNUIMessage({
|
||||
action = 'setVisibleTextUI',
|
||||
data = true
|
||||
})
|
||||
end
|
||||
exports("showTextUI", showTextUI)
|
||||
|
||||
local hideTextUI = function()
|
||||
SendNUIMessage({
|
||||
action = 'setVisibleTextUI',
|
||||
data = false
|
||||
})
|
||||
end
|
||||
exports("hideTextUI", hideTextUI)
|
39
resources/[tools]/mt_lib/modules/interface/timer/client.lua
Normal file
39
resources/[tools]/mt_lib/modules/interface/timer/client.lua
Normal file
|
@ -0,0 +1,39 @@
|
|||
local currentTimerOnFinish = nil
|
||||
|
||||
---@param label string
|
||||
---@param time number
|
||||
---@param position string
|
||||
---@param onFinish function
|
||||
local showTimer = function(label, time, position, onFinish)
|
||||
currentTimerOnFinish = onFinish
|
||||
SendNUIMessage({
|
||||
action = 'timer',
|
||||
data = {
|
||||
label = label,
|
||||
time = time,
|
||||
position = position,
|
||||
}
|
||||
})
|
||||
SendNUIMessage({
|
||||
action = 'setVisibleTimer',
|
||||
data = true
|
||||
})
|
||||
end
|
||||
exports("showTimer", showTimer)
|
||||
|
||||
local hideTimer = function()
|
||||
SendNUIMessage({
|
||||
action = 'setVisibleTimer',
|
||||
data = false
|
||||
})
|
||||
currentTimerOnFinish = nil
|
||||
end
|
||||
exports("hideTimer", hideTimer)
|
||||
|
||||
RegisterNuiCallback('finishTimer', function(data, cb)
|
||||
if currentTimerOnFinish then
|
||||
currentTimerOnFinish()
|
||||
hideTimer()
|
||||
end
|
||||
cb(true)
|
||||
end)
|
Loading…
Add table
Add a link
Reference in a new issue