Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
lone17k committed Apr 17, 2024
1 parent 6c6221d commit a3174fc
Show file tree
Hide file tree
Showing 8 changed files with 253 additions and 0 deletions.
37 changes: 37 additions & 0 deletions client/client.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@

local isNuiOpen = false

RegisterNetEvent('lone:openUpdateNui')
AddEventHandler('lone:openUpdateNui', function(updates)
SetNuiFocus(true, true)
SendNUIMessage({
type = 'loneopenNui',
servername = Config.Servername,
date = Config.date,
updates = updates
})
isNuiOpen = true
end)
TriggerEvent('chat:addSuggestion', '/updates', 'Shows the latest updates in the city')

RegisterNUICallback('closeNui', function()
SetNuiFocus(false, false)
isNuiOpen = false
end)

RegisterCommand('closeupdates', function()
if isNuiOpen then
SetNuiFocus(false, false)
isNuiOpen = false
end
end, false)

RegisterNetEvent('receiveUpdateList')
AddEventHandler('receiveUpdateList', function(updates)
SendNUIMessage({
type = 'updateList',
servername = Config.Servername,
date = Config.date,
updates = updates
})
end)
14 changes: 14 additions & 0 deletions config.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
--Made by lone with ❤️

Config = { }

Config.Servername = "Lone updates"

Config.date = "5/12/2023"

Config.updates = {
"Update 1: Added new feature.",
"Update 2: Fixed bugs.",
"Update 3: Server optimized"
-- Add more updates as needed
}
33 changes: 33 additions & 0 deletions fxmanifest.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
fx_version 'cerulean'
game 'gta5'
lua54 'yes'
author 'lone'
description 'Updates display made by Lone'
version '1.0.0'


shared_scripts {
'config.lua',
}

client_scripts {
'client/client.lua',
}

server_scripts {
'server/server.lua'
}

ui_page 'ui/index.html'

files {
'ui/index.html',
'ui/js/script.js',
'ui/css/*',
'ui/imgs/*',
}

escrow_ignore {
'config.lua',
}

13 changes: 13 additions & 0 deletions server/server.lua
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@


RegisterCommand('updates', function(source, args, rawCommand)
local playerId = source
TriggerClientEvent('lone:openUpdateNui', playerId, Config.updates)
end, false)



RegisterNetEvent('requestUpdateList')
AddEventHandler('requestUpdateList', function()
TriggerClientEvent('receiveUpdateList', source, Config.updates)
end)
80 changes: 80 additions & 0 deletions ui/css/index.css
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
/* style.css */

body {
margin: 0;
padding: 0;
font-family: Arial, sans-serif;
display: flex;
align-items: center;
justify-content: center;
height: 100vh;
}

#container {
text-align: center;
width: 30%;

}

@keyframes runningColorAnimation {
0% { box-shadow: #ff0000 0 0 20px; }
50% { box-shadow: rgb(255, 255, 255) 0 0 20px; }
75% { box-shadow: rgb(255, 0, 0) 0 0 20px;}
100% { box-shadow: #ffffff 0 0 20px; }
}


#updateNui {
background-color: #fff;
padding: 20px;
border-radius: 10px;
box-shadow: 0 0 10px rgba(0, 0, 0, 0.2);
z-index: 999;
text-align: center;
animation: runningColorAnimation 2s linear infinite;
}



#header {
display: flex;
align-items: center;
justify-content: space-between;
}

#serverLogo {
width: 30px;
height: 30px;
border-radius: 50%;
margin-right: 10px;
}

#serverName {
font-size: 18px;
font-weight: bold;
margin-right: 10px;
padding-left: 10px;
}


#closeButton {
background-color: #dc3545;
color: #fff;
border: none;
padding: 8px 12px;
border-radius: 5px;
cursor: pointer;
}

#updateList {
margin-top: 20px;
padding: 0;
list-style: none;
}

#updateList li {
background-color: #ddd;
margin-bottom: 10px;
padding: 10px;
border-radius: 5px;
}
Binary file added ui/imgs/server.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
27 changes: 27 additions & 0 deletions ui/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<!-- index.html -->

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="./css/index.css">
</head>
<body>
<div id="container">
<div id="updateNui" class="none">
<div id="header">
<img src="./imgs/server.gif" alt="Server Logo" id="serverLogo">
<div id="serverName">Server Name</div>
<div id="date">Date</div>
<button id="closeButton" onclick="closeNui()">Close</button>
</div>
<ul id="updateList">
<li>Test</li>
</ul>
</div>
</div>

<script src="./js/script.js"></script>
</body>
</html>
49 changes: 49 additions & 0 deletions ui/js/script.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
// script.js

var isNuiOpen = false;
document.getElementById('updateNui').style.display = 'none';

function closeNui() {
isNuiOpen = false;
document.getElementById('updateNui').style.display = 'none';
fetch(`https://${GetParentResourceName()}/closeNui`, {});
}

document.addEventListener('DOMContentLoaded', function () {
window.addEventListener('message', function (event) {
var data = event.data;

if (data.type === 'loneopenNui') {
updateNui(data);
document.getElementById('updateNui').style.display = 'block';

} else if (data.type === 'updateList') {
updateNui(data);
}
});

document.addEventListener('keydown', function (event) {

if (event.key === 'Escape' && isNuiOpen) {
closeNui();
}
});
});

function updateNui(data) {
updates = data.updates
var updateList = document.getElementById('updateList');
var servername = document.getElementById('serverName');
var date = document.getElementById('date');
isNuiOpen = true

servername.innerHTML = data.servername
date.innerHTML = data.date
updateList.innerHTML = '';

updates.forEach(function (update) {
var listItem = document.createElement('li');
listItem.textContent = update;
updateList.appendChild(listItem);
});
}

0 comments on commit a3174fc

Please sign in to comment.