Project Init, no html

This commit is contained in:
2025-11-12 22:00:22 +01:00
parent 2e6f8bde3d
commit 9889acfe7b
8 changed files with 92 additions and 0 deletions

40
client.lua Normal file
View File

@@ -0,0 +1,40 @@
local phoneOpen = false
RegisterCommand('togglephone', function()
phoneOpen = not phoneOpen
SetNuiFocus(phoneOpen, phoneOpen)
SendNUIMessage({ action = 'toggle', open = phoneOpen })
end, false)
RegisterKeyMapping('togglephone', 'Toggle Phone', 'keyboard', 'M')
RegisterNUICallback('close', function(data, cb)
phoneOpen = false
SetNuiFocus(false, false)
SendNUIMessage({ action = 'toggle', open = false })
cb('ok')
end)
RegisterNUICallback('sendMessage', function(data, cb)
if type(data.message) == 'string' then
TriggerServerEvent('gbcore-phone:sendMessage', data.message)
cb({ stauts = 'sent' })
else
cb({ status = 'error' })
end
end)
RegisterNetEvent('gbcore-phone:receiveMessage')
AddEventHandler('gbcore-phone:receiveMessage', function(sourceId, msg)
SendNUIMessage({ action = 'receiveMessage', from = sourceeId, message = msg })
end)
Citizen.CreateThread(function()
while true do
Citizen.Wait(0)
if phoneOpen then
DisableControlAction(0, 1, true)
DisableControlAction(0, 2, true)
end
end
end)

18
fxmanifest.lua Normal file
View File

@@ -0,0 +1,18 @@
fx_version 'cerulean'
game 'gta5'
author 'GB-Core'
description 'Standalone mobile phone'
version '1.0.0'
ui_page 'html/index.html'
files {
'html/index.html',
'html/style.css',
'html/app.js',
'html/img/apps/*'
}
client_script 'client.lua'
server_script 'server.lua'

0
html/app.js Normal file
View File

BIN
html/img/apps/contacts.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 19 KiB

BIN
html/img/apps/messages.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 22 KiB

14
html/index.html Normal file
View File

@@ -0,0 +1,14 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Phone</title>
<link rel="stylesheet" href="style.css">
<script src="https://cdn.jsdelivr.net/npm/@tailwindcss/browser@4"></script>
</head>
<body>
<script src="app.js"></script>
</body>
</html>

0
html/style.css Normal file
View File

20
server.lua Normal file
View File

@@ -0,0 +1,20 @@
local lastMessage = {}
RegisterServerEvent('gbcore-phone:sendMessage')
AddEventHandler('gbcore-phone:sendMessage', function(message)
local src = source
table.insert(lastMessages, { from = src, text = message, time = os.time() })
for _, id in ipairs(GetPlayers()) do
TriggerClientEvent('gbcore-phone:receiveMessage', id, src, message)
end
end)
RegisterCommand('phonehistory', function(source, args, raw)
if source == 0 then
for i, m in ipairs(lastMessages) do
print(i, m.from, m.text, os.date("%Y-%m-%d %H:%M:%S", m.time))
end
else
TriggerClientEvent('chat:addMessage', source, { args = { '[PHONE]', 'History printed to server console (admin)' } })
end
end, true)