IC-Computer: Schreibtisch, Fenster und Apps
Ein Computer im Spiel. Man tritt an ein Terminal, drueckt E, und bekommt eine
Oberflaeche mit Mail, Browser, Adressbuch, Kalender und weiteren Anwendungen.
Andere Resources haengen sich als App ein.
Auf ESX umgestellt:
- Fuenf harte Abhaengigkeiten zeigten auf Resources, die es hier nicht gibt.
Eine fehlende Abhaengigkeit verhindert den Start vollstaendig - die
Resource waere nie hochgekommen.
- Die Bruecke zum Framework neu geschrieben; Charakterdaten, Aktenverwaltung
und Immobilien ausgebaut, weil die zugehoerigen Systeme fehlen.
- pc_live_devices fehlte im Schema, wird vom Code aber gelesen. Ohne die
Tabelle ist kein fester PC ansprechbar. Ein PC braucht ausserdem zwei
Eintraege mit derselben Kennung: Standort in der Datenbank, Kamerafahrt in
der config.lua.
Mail ueberarbeitet:
- Postfaecher haengen an einer Anmeldung statt an der Person. Mehrere Leute
koennen dasselbe Firmenpostfach gleichzeitig offen haben.
- Ordner gehoeren zum Postfach, nicht zur Person. Eine Mail an ein geteiltes
Postfach wird je Empfaenger einmal gespeichert; damit das Einsortieren
trotzdem fuer alle gilt, tragen alle Kopien einer Zustellung dieselbe
Kennung. Gelesen und geloescht bleibt persoenlich - das ist keine
Eigenschaft der Nachricht, sondern der Person.
- Signaturen gehoeren ebenfalls zum Postfach.
- Kalender koennen privat, geteilt oder oeffentlich sein. Ein oeffentlicher
Termin haengt bewusst auch an einem Postfach, sonst koennte ihn spaeter
niemand mehr aendern oder absagen.
Neue Apps: Webhosting, Bleeter und dessen Verwaltung.
Behoben:
- prompt(), confirm() und alert() froren das NUI ein. FiveMs CEF hat keinen
Handler fuer die eingebauten Browserdialoge - der Aufruf oeffnet nichts und
kehrt nie zurueck. Ersetzt durch eigene Dialoge.
- Die Fenster tragen data-wid, keine id. Wer sie mit getElementById sucht,
schreibt ins Leere und das Fenster bleibt leer.
Enthaelt README.md mit Einrichtung und PLUGINS.md: eine Anleitung, wie man eine
eigene App baut und einhaengt, mit vollstaendigem Beispiel von der Tabelle bis
zum Schreibtischsymbol.
This commit is contained in:
commit
be502d2834
46 changed files with 13119 additions and 0 deletions
73
client/bleeter.lua
Normal file
73
client/bleeter.lua
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
-- pc-live | Bruecke zu Bleeter
|
||||
--
|
||||
-- Bleeter lief hier zunaechst als iframe, dessen Nachrichten hin- und
|
||||
-- zurueckgereicht wurden. Das ging schief: SetNuiFocus gilt global fuer den
|
||||
-- Client, und zwei Resourcen, die den Fokus beanspruchen, sperren die Maus aus.
|
||||
--
|
||||
-- Jetzt spricht der PC direkt mit dem Server von Bleeter – wie jede andere
|
||||
-- App auch. Bleeter selbst bleibt unberuehrt und oeffnet weiterhin sein
|
||||
-- eigenes Fenster ueber /bleeter.
|
||||
--
|
||||
-- Wie bei ic-web steht die Liste erlaubter Aktionen fest, sonst koennte das
|
||||
-- NUI jedes beliebige Serverereignis ausloesen.
|
||||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
local OPS = {
|
||||
-- Anzeigen und mitmachen
|
||||
requestBootstrap = 'bleeter:server:requestBootstrap',
|
||||
registerAccount = 'bleeter:server:registerAccount',
|
||||
checkHandle = 'bleeter:server:checkHandle',
|
||||
setActiveProfile = 'bleeter:server:setActiveProfile',
|
||||
createPost = 'bleeter:server:createPost',
|
||||
togglePostLike = 'bleeter:server:togglePostLike',
|
||||
deleteOwnPost = 'bleeter:server:deleteOwnPost',
|
||||
createComment = 'bleeter:server:createComment',
|
||||
deleteOwnComment = 'bleeter:server:deleteOwnComment',
|
||||
followProfile = 'bleeter:server:followProfile',
|
||||
unfollowProfile = 'bleeter:server:unfollowProfile',
|
||||
updateProfile = 'bleeter:server:updateProfile',
|
||||
uploadMedia = 'bleeter:server:uploadMedia',
|
||||
createMarketplaceEntry = 'bleeter:server:createMarketplaceEntry',
|
||||
deleteMarketplaceEntry = 'bleeter:server:deleteMarketplaceEntry',
|
||||
createEvent = 'bleeter:server:createEvent',
|
||||
deleteEvent = 'bleeter:server:deleteEvent',
|
||||
|
||||
-- Verwaltung
|
||||
listBusinessProfiles = 'bleeter:server:listBusinessProfiles',
|
||||
createBusinessProfile = 'bleeter:server:createBusinessProfile',
|
||||
listProfileMembers = 'bleeter:server:listProfileMembers',
|
||||
listCandidates = 'bleeter:server:listCandidates',
|
||||
setProfileMember = 'bleeter:server:setProfileMember',
|
||||
}
|
||||
|
||||
RegisterNUICallback('bleeter', function(data, cb)
|
||||
cb({})
|
||||
|
||||
local event = OPS[tostring(data.op or '')]
|
||||
if not event then return end
|
||||
|
||||
if data.payload ~= nil then
|
||||
TriggerServerEvent(event, data.payload)
|
||||
else
|
||||
TriggerServerEvent(event)
|
||||
end
|
||||
end)
|
||||
|
||||
-- Der Server schickt alles ueber dieses eine Ereignis: den vollstaendigen
|
||||
-- Zustand und die Antworten der Verwaltung. Beides geht unveraendert ins NUI,
|
||||
-- dort wird unterschieden.
|
||||
RegisterNetEvent('bleeter:client:data', function(message)
|
||||
if type(message) ~= 'table' then return end
|
||||
SendNUIMessage({ action = 'bleeter_data', data = message })
|
||||
end)
|
||||
|
||||
RegisterNetEvent('bleeter:client:notify', function(payload)
|
||||
SendNUIMessage({ action = 'bleeter_notify', data = payload or {} })
|
||||
end)
|
||||
|
||||
-- Antwort auf einen Bilder-Upload. Bleeter laedt die Datei zu ImgBB hoch und
|
||||
-- meldet die fertige Adresse zurueck.
|
||||
RegisterNetEvent('bleeter:client:mediaUploaded', function(payload)
|
||||
SendNUIMessage({ action = 'bleeter_uploaded', data = payload or {} })
|
||||
end)
|
||||
45
client/camera.lua
Normal file
45
client/camera.lua
Normal file
|
|
@ -0,0 +1,45 @@
|
|||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
-- Camera system
|
||||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
Camera = {}
|
||||
|
||||
local _cam = nil
|
||||
|
||||
--- Dolly to a point in front of the PC, looking at the screen.
|
||||
---@param pcCoords vector3
|
||||
---@param pcHeading number
|
||||
function Camera.FocusPC(pcCoords, pcHeading)
|
||||
if not Config.CameraOnOpen then return end
|
||||
if _cam then Camera.Restore() end
|
||||
|
||||
-- Position cam slightly behind and above the PC position (facing forward)
|
||||
local rad = math.rad(pcHeading)
|
||||
local offset = 0.6
|
||||
local cx = pcCoords.x + math.sin(rad) * offset
|
||||
local cy = pcCoords.y - math.cos(rad) * offset
|
||||
local cz = pcCoords.z + 0.55
|
||||
|
||||
_cam = CreateCameraWithParams(
|
||||
"DEFAULT_SCRIPTED_CAMERA",
|
||||
cx, cy, cz,
|
||||
0.0, 0.0, 0.0,
|
||||
60.0, false, 2
|
||||
)
|
||||
SetCamActive(_cam, true)
|
||||
RenderScriptCams(true, true, 600, true, false)
|
||||
|
||||
-- Point at screen face
|
||||
local tx = pcCoords.x - math.sin(rad) * 0.3
|
||||
local ty = pcCoords.y + math.cos(rad) * 0.3
|
||||
local tz = pcCoords.z + 0.5
|
||||
PointCamAtCoord(_cam, tx, ty, tz)
|
||||
end
|
||||
|
||||
--- Return to player camera.
|
||||
function Camera.Restore()
|
||||
if not _cam then return end
|
||||
RenderScriptCams(false, true, 500, true, false)
|
||||
DestroyCam(_cam, false)
|
||||
_cam = nil
|
||||
end
|
||||
163
client/interaction.lua
Normal file
163
client/interaction.lua
Normal file
|
|
@ -0,0 +1,163 @@
|
|||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
-- Interaction system – proximity detection, key prompt
|
||||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
Interaction = {}
|
||||
|
||||
local _nearbyPC = nil -- current nearby PC config or nil
|
||||
local _inSession = false
|
||||
local _camCfg = nil -- aktive PC-Kamera-Config (coords/heading) oder nil (mobil)
|
||||
local _pcs = {} -- keyed by id, populated from server
|
||||
|
||||
-- Sync-Liste vom Server empfangen
|
||||
RegisterNetEvent('pc-live:client:syncDevices', function(list)
|
||||
_pcs = {}
|
||||
for _, pc in ipairs(list) do
|
||||
pc.coords = vector3(pc.coords.x, pc.coords.y, pc.coords.z)
|
||||
_pcs[pc.id] = pc
|
||||
end
|
||||
end)
|
||||
|
||||
-- Device-Liste beim Start anfordern
|
||||
AddEventHandler('onClientResourceStart', function(res)
|
||||
if res == GetCurrentResourceName() then
|
||||
TriggerServerEvent('pc-live:server:requestDevices')
|
||||
end
|
||||
end)
|
||||
|
||||
local function DrawText3D(x, y, z, text)
|
||||
local onScreen, sx, sy = World3dToScreen2d(x, y, z)
|
||||
if not onScreen then return end
|
||||
SetTextScale(0.0, 0.45)
|
||||
SetTextFont(4)
|
||||
SetTextProportional(1)
|
||||
SetTextColour(255, 255, 255, 215)
|
||||
SetTextEntry("STRING")
|
||||
SetTextCentre(true)
|
||||
AddTextComponentString(text)
|
||||
DrawText(sx, sy)
|
||||
end
|
||||
|
||||
local function DrawRect2D(x, y, width, height, r, g, b, a)
|
||||
DrawRect(x, y, width, height, r, g, b, a)
|
||||
end
|
||||
|
||||
--- Main proximity loop.
|
||||
function Interaction.StartLoop()
|
||||
CreateThread(function()
|
||||
while true do
|
||||
local sleep = 1000
|
||||
if not _inSession then
|
||||
local ped = PlayerPedId()
|
||||
local coords = GetEntityCoords(ped)
|
||||
|
||||
local found = nil
|
||||
for _, pc in pairs(_pcs) do
|
||||
local dist = #(coords - pc.coords)
|
||||
if dist < Config.InteractRange + 8.0 then
|
||||
sleep = 0
|
||||
if dist < Config.InteractRange then
|
||||
found = pc
|
||||
break
|
||||
end
|
||||
end
|
||||
end
|
||||
_nearbyPC = found
|
||||
else
|
||||
_nearbyPC = nil
|
||||
end
|
||||
Wait(sleep)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
--- Draw prompt and handle key.
|
||||
function Interaction.StartPromptLoop()
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(0)
|
||||
if _nearbyPC and not _inSession then
|
||||
-- Draw 3D label
|
||||
DrawText3D(
|
||||
_nearbyPC.coords.x,
|
||||
_nearbyPC.coords.y,
|
||||
_nearbyPC.coords.z + 1.1,
|
||||
("[E] %s"):format(_nearbyPC.label)
|
||||
)
|
||||
|
||||
if IsControlJustReleased(0, Config.InteractKey) then
|
||||
Interaction.Open(_nearbyPC)
|
||||
end
|
||||
end
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
--- Open PC – request session from server.
|
||||
---@param pc table
|
||||
function Interaction.Open(pc)
|
||||
if _inSession then return end
|
||||
TriggerServerEvent('pc-live:server:openPC', pc.id)
|
||||
end
|
||||
|
||||
--- Called when the session starts (from server confirmation).
|
||||
---@param data table
|
||||
function Interaction.OnSessionStart(data)
|
||||
_inSession = true
|
||||
_nearbyPC = nil
|
||||
|
||||
-- PC-Config finden; mobile Terminals (Streifenwagen) haben keinen Standort/Kamera.
|
||||
local pcCfg
|
||||
for _, pc in ipairs(Config.PCs) do
|
||||
if pc.id == data.pcId then pcCfg = pc; break end
|
||||
end
|
||||
local isMobile = pcCfg and pcCfg.mobile
|
||||
|
||||
if Config.FreezeOnOpen and not isMobile then
|
||||
FreezeEntityPosition(PlayerPedId(), true)
|
||||
end
|
||||
|
||||
if pcCfg and not isMobile then
|
||||
_camCfg = { coords = pcCfg.coords, heading = pcCfg.heading }
|
||||
Camera.FocusPC(pcCfg.coords, pcCfg.heading)
|
||||
else
|
||||
_camCfg = nil
|
||||
end
|
||||
end
|
||||
|
||||
-- Interaktionsmodus: PC-Kamera lösen (Gameplay-Kamera zurück -> umsehen möglich)
|
||||
-- bzw. wieder auf den PC richten, wenn man zurückkehrt.
|
||||
function Interaction.EnterInteract()
|
||||
if _camCfg then Camera.Restore() end
|
||||
end
|
||||
function Interaction.ExitInteract()
|
||||
if _camCfg then Camera.FocusPC(_camCfg.coords, _camCfg.heading) end
|
||||
end
|
||||
|
||||
--- Öffnet ein mobiles Terminal (z.B. Streifenwagen-PC) – kein Standort/Distanz nötig.
|
||||
---@param pcId string|nil
|
||||
function Interaction.OpenMobile(pcId)
|
||||
if _inSession then return end
|
||||
TriggerServerEvent('pc-live:server:openPC', pcId or 'police_mobile')
|
||||
end
|
||||
|
||||
-- Wird vom M-Menü (core-interaction) im Einsatzfahrzeug getriggert.
|
||||
AddEventHandler('pc-live:openMobileTerminal', function(pcId)
|
||||
Interaction.OpenMobile(pcId)
|
||||
end)
|
||||
|
||||
--- Called when closing the session.
|
||||
function Interaction.OnSessionClose()
|
||||
_inSession = false
|
||||
|
||||
if Config.FreezeOnOpen then
|
||||
FreezeEntityPosition(PlayerPedId(), false)
|
||||
end
|
||||
|
||||
Camera.Restore()
|
||||
_camCfg = nil
|
||||
TriggerServerEvent('pc-live:server:closePC')
|
||||
end
|
||||
|
||||
Interaction.StartLoop()
|
||||
Interaction.StartPromptLoop()
|
||||
141
client/main.lua
Normal file
141
client/main.lua
Normal file
|
|
@ -0,0 +1,141 @@
|
|||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
-- Client Main – event listeners, glue
|
||||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
Bridge = Bridge or {}
|
||||
|
||||
-- ── Server → Client events ───────────────────────────────────────────────────
|
||||
|
||||
-- Session granted by server
|
||||
RegisterNetEvent('pc-live:client:sessionStart', function(data)
|
||||
Interaction.OnSessionStart(data)
|
||||
-- Add accent color to data
|
||||
data.accentColor = Config.AccentColor
|
||||
NUIBridge.Boot(data)
|
||||
end)
|
||||
|
||||
-- Desktop app list update
|
||||
RegisterNetEvent('pc-live:client:installedApps', function(apps)
|
||||
NUIBridge.SetInstalledApps(apps)
|
||||
end)
|
||||
|
||||
-- Mail
|
||||
RegisterNetEvent('pc-live:client:inboxData', function(rows, folders)
|
||||
NUIBridge.SetInbox(rows, folders)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('pc-live:client:mailContent', function(mail)
|
||||
NUIBridge.SetMailContent(mail)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('pc-live:client:mailSent', function()
|
||||
NUIBridge.MailSent()
|
||||
end)
|
||||
|
||||
RegisterNetEvent('pc-live:client:mailDeleted', function(id)
|
||||
NUIBridge.MailDeleted(id)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('pc-live:client:newMailNotify', function()
|
||||
NUIBridge.NewMailNotify()
|
||||
end)
|
||||
|
||||
RegisterNetEvent('pc-live:client:mailMoved', function(mailId, folderId)
|
||||
SendNUIMessage({ action = 'mailMoved', data = { id = mailId, folderId = folderId } })
|
||||
end)
|
||||
|
||||
RegisterNetEvent('pc-live:client:sentData', function(rows)
|
||||
SendNUIMessage({ action = 'setSent', data = rows })
|
||||
end)
|
||||
|
||||
RegisterNetEvent('pc-live:client:folderCreated', function(folder)
|
||||
SendNUIMessage({ action = 'folderCreated', data = folder })
|
||||
end)
|
||||
|
||||
RegisterNetEvent('pc-live:client:folderDeleted', function(folderId, address)
|
||||
SendNUIMessage({ action = 'folderDeleted', data = { id = folderId, address = address or '' } })
|
||||
end)
|
||||
|
||||
RegisterNetEvent('pc-live:client:folderMailsData', function(folderId, rows)
|
||||
SendNUIMessage({ action = 'folderMailsData', data = { folderId = folderId, rows = rows } })
|
||||
end)
|
||||
|
||||
-- Calendar
|
||||
RegisterNetEvent('pc-live:client:calendarData', function(rows)
|
||||
SendNUIMessage({ action = 'calendarData', data = rows })
|
||||
end)
|
||||
|
||||
RegisterNetEvent('pc-live:client:calendarEventAdded', function(ev)
|
||||
SendNUIMessage({ action = 'calendarEventAdded', data = ev })
|
||||
end)
|
||||
|
||||
RegisterNetEvent('pc-live:client:calendarEventUpdated', function(ev)
|
||||
SendNUIMessage({ action = 'calendarEventUpdated', data = ev })
|
||||
end)
|
||||
|
||||
RegisterNetEvent('pc-live:client:calendarEventDeleted', function(id)
|
||||
SendNUIMessage({ action = 'calendarEventDeleted', data = { id = id } })
|
||||
end)
|
||||
|
||||
-- Contacts
|
||||
RegisterNetEvent('pc-live:client:contactsData', function(rows)
|
||||
SendNUIMessage({ action = 'contactsData', data = rows })
|
||||
end)
|
||||
|
||||
RegisterNetEvent('pc-live:client:contactAdded', function(c)
|
||||
SendNUIMessage({ action = 'contactAdded', data = c })
|
||||
end)
|
||||
|
||||
RegisterNetEvent('pc-live:client:contactUpdated', function(c)
|
||||
SendNUIMessage({ action = 'contactUpdated', data = c })
|
||||
end)
|
||||
|
||||
RegisterNetEvent('pc-live:client:contactDeleted', function(id)
|
||||
SendNUIMessage({ action = 'contactDeleted', data = { id = id } })
|
||||
end)
|
||||
|
||||
-- Geteilte Postfächer
|
||||
RegisterNetEvent('pc-live:client:foldersData', function(address, folders)
|
||||
SendNUIMessage({ action = 'foldersData', data = { address = address, folders = folders } })
|
||||
end)
|
||||
|
||||
RegisterNetEvent('pc-live:client:signatureSaved', function(ok, err)
|
||||
SendNUIMessage({ action = 'signatureSaved', data = { ok = ok, error = err } })
|
||||
end)
|
||||
|
||||
RegisterNetEvent('pc-live:client:sharedMailboxes', function(mailboxes, personalAddr, personalSig)
|
||||
SendNUIMessage({ action = 'sharedMailboxes', data = {
|
||||
mailboxes = mailboxes, personalAddress = personalAddr,
|
||||
personalSignature = personalSig or '',
|
||||
} })
|
||||
end)
|
||||
|
||||
-- Store
|
||||
RegisterNetEvent('pc-live:client:storeData', function(apps)
|
||||
NUIBridge.SetStoreList(apps)
|
||||
end)
|
||||
|
||||
-- Disable attack controls while PC is open (prevents character punching on mouse click)
|
||||
CreateThread(function()
|
||||
while true do
|
||||
Wait(0)
|
||||
if IsNuiFocused() then
|
||||
DisableControlAction(0, 24, true) -- Attack (left click)
|
||||
DisableControlAction(0, 25, true) -- Aim (right click)
|
||||
DisableControlAction(0, 140, true) -- Melee Attack Light
|
||||
DisableControlAction(0, 141, true) -- Melee Attack Heavy
|
||||
DisableControlAction(0, 142, true) -- Melee Attack Alternate
|
||||
DisableControlAction(0, 143, true) -- Melee Attack 2
|
||||
end
|
||||
end
|
||||
end)
|
||||
|
||||
Utils.Log("Client main loaded.")
|
||||
|
||||
RegisterNetEvent('pc-live:client:mailAddressStatus', function(hasAddress, address, realms)
|
||||
NUIBridge.MailAddressStatus(hasAddress, address, realms)
|
||||
end)
|
||||
|
||||
RegisterNetEvent('pc-live:client:mailCreateResult', function(success, err, address)
|
||||
NUIBridge.MailCreateResult(success, err, address)
|
||||
end)
|
||||
315
client/nui.lua
Normal file
315
client/nui.lua
Normal file
|
|
@ -0,0 +1,315 @@
|
|||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
-- NUI bridge – all SendNUIMessage / RegisterNUICallback calls
|
||||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
NUIBridge = {}
|
||||
|
||||
local pcOpen = false -- ist der PC gerade offen? (für Interaktionsmodus-Taste)
|
||||
|
||||
local function Send(action, data)
|
||||
SendNUIMessage({ action = action, data = data or {} })
|
||||
end
|
||||
|
||||
-- ── Outbound (Lua -> NUI) ───────────────────────────────────────────────────
|
||||
|
||||
function NUIBridge.Boot(sessionData)
|
||||
SetNuiFocus(true, true)
|
||||
pcOpen = true
|
||||
Send("boot", sessionData)
|
||||
end
|
||||
|
||||
function NUIBridge.SetInstalledApps(apps)
|
||||
Send("setInstalledApps", apps)
|
||||
end
|
||||
|
||||
function NUIBridge.SetInbox(mails, folders)
|
||||
Send("setInbox", { mails = mails, folders = folders or {} })
|
||||
end
|
||||
|
||||
function NUIBridge.MailAddressStatus(hasAddress, address, realms)
|
||||
Send("mailAddressStatus", { hasAddress = hasAddress, address = address, realms = realms or {} })
|
||||
end
|
||||
|
||||
function NUIBridge.MailCreateResult(success, err, address)
|
||||
Send("mailCreateResult", { success = success, error = err, address = address })
|
||||
end
|
||||
|
||||
function NUIBridge.SetMailContent(mail)
|
||||
Send("setMailContent", mail)
|
||||
end
|
||||
|
||||
function NUIBridge.MailSent()
|
||||
Send("mailSent")
|
||||
end
|
||||
|
||||
function NUIBridge.MailDeleted(id)
|
||||
Send("mailDeleted", { id = id })
|
||||
end
|
||||
|
||||
function NUIBridge.SetStoreList(apps)
|
||||
Send("setStoreList", apps)
|
||||
end
|
||||
|
||||
function NUIBridge.NewMailNotify()
|
||||
Send("newMailNotify")
|
||||
end
|
||||
|
||||
function NUIBridge.Close()
|
||||
SetNuiFocus(false, false)
|
||||
pcOpen = false
|
||||
Send("close")
|
||||
end
|
||||
|
||||
-- Interaktionsmodus: NUI-Fokus vom PC lösen (Spiel-Interaktion) bzw. zurückholen.
|
||||
RegisterNUICallback('setFocus', function(data, cb)
|
||||
local focus = data and data.focus and true or false
|
||||
SetNuiFocus(focus, focus)
|
||||
if focus then
|
||||
if Interaction and Interaction.ExitInteract then Interaction.ExitInteract() end
|
||||
else
|
||||
if Interaction and Interaction.EnterInteract then Interaction.EnterInteract() end
|
||||
end
|
||||
cb({})
|
||||
end)
|
||||
|
||||
-- Taste (Standard: END, in den FiveM-Einstellungen umbelegbar), um aus dem
|
||||
-- Interaktionsmodus wieder zum PC (Fokus) zurückzukehren.
|
||||
RegisterCommand('pclive_refocus', function()
|
||||
if pcOpen then
|
||||
SetNuiFocus(true, true)
|
||||
if Interaction and Interaction.ExitInteract then Interaction.ExitInteract() end
|
||||
Send('exitInteract')
|
||||
end
|
||||
end, false)
|
||||
RegisterKeyMapping('pclive_refocus', 'PC-Live: Zurück zum PC (Fokus)', 'keyboard', 'END')
|
||||
|
||||
function NUIBridge.SetAccentColor(color)
|
||||
Send("setAccentColor", { color = color })
|
||||
end
|
||||
|
||||
-- ── Inbound (NUI -> Lua) ────────────────────────────────────────────────────
|
||||
|
||||
RegisterNUICallback('closePC', function(data, cb)
|
||||
NUIBridge.Close()
|
||||
Interaction.OnSessionClose()
|
||||
cb({})
|
||||
end)
|
||||
|
||||
-- Mail
|
||||
RegisterNUICallback('checkMailAddress', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:checkMailAddress')
|
||||
cb({})
|
||||
end)
|
||||
|
||||
RegisterNUICallback('createMailAddress', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:createMailAddress', data.username)
|
||||
cb({})
|
||||
end)
|
||||
|
||||
RegisterNUICallback('getInbox', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:getInbox')
|
||||
cb({})
|
||||
end)
|
||||
|
||||
RegisterNUICallback('readMail', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:readMail', tonumber(data.id))
|
||||
cb({})
|
||||
end)
|
||||
|
||||
RegisterNUICallback('sendMail', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:sendMail', {
|
||||
to = tostring(data.to or ""),
|
||||
subject = tostring(data.subject or ""),
|
||||
body = tostring(data.body or ""),
|
||||
fromMailbox = tostring(data.fromMailbox or ""),
|
||||
})
|
||||
cb({})
|
||||
end)
|
||||
|
||||
RegisterNUICallback('setSignature', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:setSignature',
|
||||
tostring(data.address or ""), tostring(data.signature or ""))
|
||||
cb({})
|
||||
end)
|
||||
|
||||
RegisterNUICallback('getSharedMailboxes', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:getSharedMailboxes')
|
||||
cb({})
|
||||
end)
|
||||
|
||||
RegisterNUICallback('deleteMail', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:deleteMail', tonumber(data.id))
|
||||
cb({})
|
||||
end)
|
||||
|
||||
RegisterNUICallback('getSent', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:getSent')
|
||||
cb({})
|
||||
end)
|
||||
|
||||
RegisterNUICallback('getFolders', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:getFolders', tostring(data.address or ""))
|
||||
cb({})
|
||||
end)
|
||||
|
||||
RegisterNUICallback('getFolderMails', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:getFolderMails', tonumber(data.folderId),
|
||||
tostring(data.address or ""))
|
||||
cb({})
|
||||
end)
|
||||
|
||||
RegisterNUICallback('createFolder', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:createFolder', tostring(data.name or ""),
|
||||
tostring(data.address or ""))
|
||||
cb({})
|
||||
end)
|
||||
|
||||
RegisterNUICallback('deleteFolder', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:deleteFolder', tonumber(data.id),
|
||||
tostring(data.address or ""))
|
||||
cb({})
|
||||
end)
|
||||
|
||||
RegisterNUICallback('moveMail', function(data, cb)
|
||||
local folderId = data.folderId ~= nil and tonumber(data.folderId) or nil
|
||||
TriggerServerEvent('pc-live:server:moveMail', tonumber(data.id), folderId,
|
||||
tostring(data.address or ""))
|
||||
cb({})
|
||||
end)
|
||||
|
||||
-- Calendar
|
||||
RegisterNUICallback('getCalendar', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:getCalendar')
|
||||
cb({})
|
||||
end)
|
||||
|
||||
RegisterNUICallback('addCalendarEvent', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:addCalendarEvent', data)
|
||||
cb({})
|
||||
end)
|
||||
|
||||
RegisterNUICallback('updateCalendarEvent', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:updateCalendarEvent', tonumber(data.id), data)
|
||||
cb({})
|
||||
end)
|
||||
|
||||
RegisterNUICallback('deleteCalendarEvent', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:deleteCalendarEvent', tonumber(data.id))
|
||||
cb({})
|
||||
end)
|
||||
|
||||
-- Contacts
|
||||
RegisterNUICallback('getContacts', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:getContacts')
|
||||
cb({})
|
||||
end)
|
||||
|
||||
RegisterNUICallback('addContact', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:addContact', data)
|
||||
cb({})
|
||||
end)
|
||||
|
||||
RegisterNUICallback('updateContact', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:updateContact', tonumber(data.id), data)
|
||||
cb({})
|
||||
end)
|
||||
|
||||
RegisterNUICallback('deleteContact', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:deleteContact', tonumber(data.id))
|
||||
cb({})
|
||||
end)
|
||||
|
||||
-- Store
|
||||
RegisterNUICallback('getStore', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:getStore')
|
||||
cb({})
|
||||
end)
|
||||
|
||||
RegisterNUICallback('installApp', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:installApp', tostring(data.appId or ""))
|
||||
cb({})
|
||||
end)
|
||||
|
||||
RegisterNUICallback('uninstallApp', function(data, cb)
|
||||
TriggerServerEvent('pc-live:server:uninstallApp', tostring(data.appId or ""))
|
||||
cb({})
|
||||
end)
|
||||
|
||||
-- Browser – IC pages fetched locally from config
|
||||
RegisterNUICallback('getBrowserPage', function(data, cb)
|
||||
local slug = tostring(data.slug or "home")
|
||||
local page = Config.ICPages[slug]
|
||||
cb({ found = page ~= nil, page = page, slug = slug })
|
||||
end)
|
||||
|
||||
-- ── IC-Verwaltung ────────────────────────────────────────────────────────────
|
||||
|
||||
-- Relay messages from ic-verwaltung to pc-live NUI (→ iframe postMessage)
|
||||
AddEventHandler('ic-verwaltung:relayToPC', function(msg)
|
||||
SendNUIMessage({ action = 'ic_verwaltung_relay', data = msg })
|
||||
end)
|
||||
|
||||
RegisterNUICallback('openIcVerwaltung', function(data, cb)
|
||||
cb({})
|
||||
-- Open ic-verwaltung in pcMode: no focus changes, UI relayed via postMessage
|
||||
TriggerEvent('ic-verwaltung:openForPC')
|
||||
end)
|
||||
|
||||
RegisterNUICallback('closeIcVerwaltung', function(data, cb)
|
||||
cb({})
|
||||
-- Forward close action into ic-verwaltung (user closed the PC window)
|
||||
TriggerEvent('ic-verwaltung:closeFromPC')
|
||||
end)
|
||||
|
||||
-- ── Parkuhr Integration ──────────────────────────────────────────────────────
|
||||
|
||||
local _pendingParkuhrCb = nil
|
||||
|
||||
-- Antwort vom Parkuhr-Server empfangen und an NUI weiterleiten
|
||||
RegisterNetEvent('parkuhr:panelData', function(payload)
|
||||
if _pendingParkuhrCb then
|
||||
_pendingParkuhrCb(payload or { devices = {}, typeTariffs = {}, currency = "$" })
|
||||
_pendingParkuhrCb = nil
|
||||
end
|
||||
end)
|
||||
|
||||
RegisterNUICallback('getParkuhrPanel', function(data, cb)
|
||||
_pendingParkuhrCb = cb
|
||||
TriggerServerEvent('parkuhr:requestPanelData')
|
||||
end)
|
||||
|
||||
RegisterNUICallback('saveParkuhrTariff', function(data, cb)
|
||||
TriggerServerEvent('parkuhr:saveTariff',
|
||||
tonumber(data.deviceId),
|
||||
tonumber(data.duration),
|
||||
tonumber(data.price)
|
||||
)
|
||||
cb({})
|
||||
end)
|
||||
|
||||
RegisterNUICallback('deleteParkuhrTariff', function(data, cb)
|
||||
TriggerServerEvent('parkuhr:deleteTariff',
|
||||
tonumber(data.deviceId),
|
||||
tonumber(data.duration)
|
||||
)
|
||||
cb({})
|
||||
end)
|
||||
|
||||
-- ── PBS Dashboard ────────────────────────────────────────────────────────────
|
||||
|
||||
RegisterNUICallback('getPbsUrl', function(data, cb)
|
||||
cb({ url = GetConvar('pbs_web_url', 'http://localhost:4088') })
|
||||
end)
|
||||
|
||||
-- ── Bleeter App ───────────────────────────────────────────────────────────────
|
||||
|
||||
RegisterNUICallback('openBleeter', function(data, cb)
|
||||
local mode = (data and data.mode) or 'desktop'
|
||||
-- PC bleibt offen; Bleeter öffnet sich als Overlay darüber
|
||||
if exports['bleeter'] then
|
||||
exports['bleeter']:OpenBleeter(mode)
|
||||
else
|
||||
TriggerEvent('bleeter:client:open')
|
||||
end
|
||||
cb({ ok = true })
|
||||
end)
|
||||
73
client/webhosting.lua
Normal file
73
client/webhosting.lua
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
-- pc-live | Bruecke zu ic-web
|
||||
--
|
||||
-- Das NUI kann nur Callbacks der eigenen Resource aufrufen. Diese Datei
|
||||
-- uebersetzt sie in Netzwerkereignisse von ic-web und schiebt die Antwort
|
||||
-- ueber die Anfrage-Id zurueck ins NUI.
|
||||
--
|
||||
-- Die Liste erlaubter Aktionen steht hier bewusst fest: sonst koennte das NUI
|
||||
-- jedes beliebige Serverereignis ausloesen.
|
||||
--
|
||||
-- Passwoerter laufen hier durch, werden aber weder gespeichert noch
|
||||
-- protokolliert – nur weitergereicht.
|
||||
-- ─────────────────────────────────────────────────────────────────────────────
|
||||
|
||||
local OPS = {
|
||||
-- Anmeldung
|
||||
login = 'ic-web:server:login',
|
||||
logout = 'ic-web:server:logout',
|
||||
session = 'ic-web:server:session',
|
||||
changePassword = 'ic-web:server:changePassword',
|
||||
-- Postfaecher im Mailclient
|
||||
openMailbox = 'ic-web:server:openMailbox',
|
||||
closeMailbox = 'ic-web:server:closeMailbox',
|
||||
listMailboxes = 'ic-web:server:listMailboxes',
|
||||
-- Seiten
|
||||
getSite = 'ic-web:server:getSite',
|
||||
listMine = 'ic-web:server:listMine',
|
||||
getEditable = 'ic-web:server:getEditable',
|
||||
savePage = 'ic-web:server:savePage',
|
||||
deletePage = 'ic-web:server:deletePage',
|
||||
updateSite = 'ic-web:server:updateSite',
|
||||
report = 'ic-web:server:report',
|
||||
register = 'ic-web:server:register',
|
||||
-- Zugaenge
|
||||
listAccounts = 'ic-web:server:listAccounts',
|
||||
createAccount = 'ic-web:server:createAccount',
|
||||
setAccountPassword = 'ic-web:server:setAccountPassword',
|
||||
setAccountActive = 'ic-web:server:setAccountActive',
|
||||
setAccountRole = 'ic-web:server:setAccountRole',
|
||||
deleteAccount = 'ic-web:server:deleteAccount',
|
||||
-- Anbieterebene
|
||||
adminListSites = 'ic-web:server:adminListSites',
|
||||
adminListAccounts = 'ic-web:server:adminListAccounts',
|
||||
adminListJobs = 'ic-web:server:adminListJobs',
|
||||
adminRegister = 'ic-web:server:adminRegister',
|
||||
adminSetBlocked = 'ic-web:server:adminSetBlocked',
|
||||
adminSetOwner = 'ic-web:server:adminSetOwner',
|
||||
adminDeleteSite = 'ic-web:server:adminDeleteSite',
|
||||
adminListReports = 'ic-web:server:adminListReports',
|
||||
adminSetReportStatus = 'ic-web:server:adminSetReportStatus',
|
||||
}
|
||||
|
||||
RegisterNUICallback('icweb', function(data, cb)
|
||||
cb({})
|
||||
|
||||
local event = OPS[tostring(data.op or '')]
|
||||
if not event then return end
|
||||
|
||||
local reqId = tostring(data.reqId or '')
|
||||
if reqId == '' then return end
|
||||
|
||||
-- args kommt als JSON-Array an; leere Stellen schickt das NUI als ''.
|
||||
local args = data.args or {}
|
||||
TriggerServerEvent(event, reqId,
|
||||
args[1], args[2], args[3], args[4], args[5], args[6])
|
||||
end)
|
||||
|
||||
RegisterNetEvent('ic-web:client:response', function(reqId, payload)
|
||||
SendNUIMessage({
|
||||
action = 'icweb_response',
|
||||
data = { reqId = reqId, payload = payload },
|
||||
})
|
||||
end)
|
||||
Loading…
Add table
Add a link
Reference in a new issue