[help] Login NUI interface

Hi everybody,

I’m new here and I try to create my own module. I have do many searches and it’s time to try !

I want to create an HTML UI where user can enter there login and password. I have create the page, create all scripts but the HTML doesn’t show and I don’t know why.

There is my code :

AddEventHandler('onPlayerJoining', function(playerId, name)
    SetNuiFocus(true);
    loginScreenShow = true;
end)

My HTML page I declared in the resource file :

ui_page 'html/login.html'

client_script 'cl_login.lua'
server_script 'sv_login.lua'

files {
  'html/login.js'
}

My JS doesn’t have error when opened in Chrome and HTML is correctly showed. No error on the server console.
I think it’s a very stupid things, but I don’t know what is it !

Other question, can I found logs in client side ?

Thanks a lot.

Muadhib

This may help you…

Thanks for your answer.
I’ve tried this module but it’s not working on my server.
Is it working on your’s?
My player is not visible, I can’t move but no ui is showed.

check your server console, what does it say?

I’ll look at a different way to do this

Ok, I solve my problem. It’s seems I have foget html/login.html in files group in __resource.lua.

ui_page 'html/login.html'

client_script 'cl_login.lua'
server_script 'sv_login.lua'

files {
  'html/login.html',
  'html/login.js'
}

Know, I just want to have mouse in my page. I have found this : UI with mouse input
But, is it up to date ? Is there a newer method to do this ?
For know, it’s not working but I’m just starting.

@muadhib @jdc4992 Hey guys, I’m trying to build an interface.
Do you know where can I find logs from JS files ?

Open it in your web browser and press f12 look at the console, if it works on your web browser it should work in game

Thanks for your answer,but I know pretty well how to debug on a browser.
What I am looking for is to log somewhere the data from events sent through NUI but Client Side.

Should console.log() write to citizen log files ?

Or many it’s just I don’t know how to display multiple ui_pages as the same time… Any suggestion is welcome.

thx in advance :wink:

console.log() will output what you want, just obviously include your data variable with it

I’ve tried to log from my JS and even from the HTML directly, I know for a fact the HTML is loaded in-game, I see events from NUI into client logs but my JS never catches them :frowning:

Switch to PM and I’ll try and help by looking at your code, if we get a fix we can post it here to help people in future.

I must stop for tonight but I’ll share everything tomorrow if I can get through this or not.
Thx for offering your help. see you tommorow

1 Like

Hi Rudz,

I don’t found any exist solution to log in the client Side (maybe a future feature ? :wink: ). To have all data I want, I’m using somes trics :

  • Add a div#console always show in my HTML code and append somes rows inside.
  • Use injection in my page to separate NUI interface and logical JS source. Like this, I can use my page in outer of FiveM and debug all this with a mock LUA/NUI interface.
  • Use SendServerEvent to log in the server console

I hope it’s help you.
Sorry for my bad english, it’s morning here and it’s difficult to wake up lol.

1 Like

Hi @muadhib, thanks for your support.

  • Add a div#console always show in my HTML code and append somes rows inside. --> THIS is a TERRIFIC trick ! THX (I’m just upset I didn’t think about it !)
    I’ll try all those soon.

Thx again !!! English is pretty good (says the frog that I am XD )