Skip to content

Commit 6ea7cb0

Browse files
committed
Add initial implementation of vending machine script for FiveM
1 parent e4d60f3 commit 6ea7cb0

File tree

6 files changed

+983
-0
lines changed

6 files changed

+983
-0
lines changed

NUI/NUI.html

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<!DOCTYPE html>
2+
<html lang="en">
3+
<head>
4+
<meta charset="UTF-8">
5+
<title>Vending Machine</title>
6+
</head>
7+
<body>
8+
<div id="vending-container">
9+
<h1>Elige un producto</h1>
10+
<div id="items-list"></div>
11+
<button id="close-btn">Cerrar</button>
12+
</div>
13+
14+
<script>
15+
window.addEventListener('message', function (event) {
16+
var data = event.data;
17+
18+
if (data.action == 'open') {
19+
document.getElementById('vending-container').style.display = 'block';
20+
var itemsList = document.getElementById('items-list');
21+
itemsList.innerHTML = '';
22+
23+
data.items.forEach(function (item) {
24+
var itemDiv = document.createElement('div');
25+
itemDiv.textContent = item.label + ' - $' + item.price;
26+
itemDiv.onclick = function () {
27+
fetch('https://muhaddil-machines/selectItem', {
28+
method: 'POST',
29+
headers: {
30+
'Content-Type': 'application/json',
31+
},
32+
body: JSON.stringify({
33+
itemName: item.name,
34+
itemPrice: item.price,
35+
machineName: data.machineName
36+
})
37+
}).then(res => res.json());
38+
};
39+
itemsList.appendChild(itemDiv);
40+
});
41+
} else if (data.action == 'close') {
42+
document.getElementById('vending-container').style.display = 'none';
43+
}
44+
});
45+
46+
document.getElementById('close-btn').onclick = function () {
47+
fetch('https://muhaddil-machines/close', {
48+
method: 'POST',
49+
});
50+
};
51+
</script>
52+
</body>
53+
</html>

0 commit comments

Comments
 (0)