So, as the title states, I’m looking to use my LUA Variable in my HTML. Any help would be greatly appreciated, I’m sure it’s a simple fix but I have no idea lol. Cheers!
main.lua:
RegisterNetEvent('nui:on')
AddEventHandler('nui:on', function()
SendNUIMessage({
type = "ui",
display = true,
test = "test"
})
end)
listener.js:
$(function(){
window.onload = (e) => {
/* 'links' the js with the Nui message from main.lua */
window.addEventListener('message', (event) => {
//document.querySelector("#logo").innerHTML = " "
var test = document.getElementById(event.data.test).innerHTML;
var item = event.data;
if (item !== undefined && item.type === "ui") {
/* if the display is true, it will show */
if (item.display === true) {
$("#container").show();
/* if the display is false, it will hide */
} else{
$("#container").hide();
}
}
});
};
});
index.html:
<html>
<head>
<link rel="stylesheet" href="reset.css" type="text/css">
<link rel="stylesheet" href="style.css" type="text/css">
<script src="nui://game/ui/jquery.js" type="text/javascript"></script>
<script src="./listener.js" type="text/javascript"></script>
<script src="../config.js" type="text/javascript"></script>
</head>
<body>
<div id="container">
<div>
<p id="test"></p>
</div>
</div>
</body>
</html>