I’m might have done it all wrong, but what I’ve done is I’ve made a lua script which opens the menu when I press E, it works without any problems. When I need to close the menu I can’t use the ingame controls to get the key so I’ve used document.body.onkeydown in my JS which also works and it’s closing the menu (setting the display to none) but the problem is I doesn’t disable SetNuiFocus.
I’m trying to use
$.post(‘http://testing/event’, JSON.stringify({}));
I’m not sure that’s the right URL.
the RegisterNUICallback is located in testing/client.lua
it is. inside the testing folder is a the __resource.lua and the client.lua and then there’s another folder called nui and that’s where I have the css ,js and html.
The only thing I can think of is that the URL is wrong
I’ve been trying stuff for a while now. the nui callback never gets called.
Am I understanding this right?
$.post(‘http://testing/event’, JSON.stringify({}));
this should run whatever is in the closeGui() function right?
Also, I am not sure if Lua allows the use of { } for functions. I think it tries to interpret it as a table. I could be wrong about that. I haven’t used Lua recently.
I forgot to change it back to RegisterNUICallback('event', function(data, cb) closeGui() cb('ok') end)
before making the post.
I was already doing this and it’s not working
Are there any errors in your F8 console? Try putting console.log("hello") after the $.post line to see if it is getting that far. Does your resource name/folder have a capital letter in it?
Thank you, the problem was a capital letter in the resource name, when I first wrote the post the name was testing but later I changed it to testMenu. I would have told you I changed the name but didn’t think that it mattered.
Well, it seems to work now