Problem with chat/console input

I do not know what category to put this. Usually, my posts just get nuked, so if it’s in the wrong place, will someone let me know? Since this is obviously something wrong with my server setup, I am putting it here.

When I am in the chat / terminal / command line part of the game (I do not mean the F8 console, I mean when I press T and can enter commands.) My avatar punches when I hit “R,” goes ragdoll when I press any command with a “U,” my phone comes up when I press “M” the pause screen comes up when I press anything with a “P” in it. I also move around when I hit WASD.

I hope you get the idea. It’s sub-optimal if I am trying to type anything into the terminal.

I understand this is normal behavior, but I want it to STOP when I am in the terminal screen. You can imagine the chaos when typing /tpm or if I want to use the /eup command.

I am vaguely familiar with DisableControlAction commands, like what would be used if an avatar is handcuffed, but I am not sure that is applicable here. And if it is, where is the script that fires up the terminal/chat window

Terminal? You mean the normal game chat??

Because the normal chat should block all inputs while typing. Are you using the default chat resource? If no, then you should.

DisableAllControlActions(0) running in a loop should do the trick, but then again…normal chat already does that.

1 Like

Yes, exactly. As far as I know, I am using the default chat. To be sure, I grabbed the latest from the cfx-server-data GitHub repo. The only thing that added is an esx_rpchat that got installed with this build of ESX Legacy. That is supposed to only change names in the chat to use character names set up in ESX. Do you think that loop set up in the client script for esx_rpchat will do the trick?

Try disabling the esx_rpchat first to see if it causes the problem.

… why are you all assuming this is something script-related?

chat does the following in cl_chat.lua:

    if chatInputActivating then
      if not IsControlPressed(0, isRDR and `INPUT_MP_TEXT_CHAT_ALL` or 245) then
        SetNuiFocus(true)

The SetNuiFocus call should mean any further input won’t be passed to the game at all from platform code, and as SetNuiFocus sets a state per resource, this would mean something in chat is setting it to false, which should not happen until the overlay is closed.


@DaveGaffer Does this happen on any other server, such as the testing server (connect https://fivem.net/2372/), or in any other place NUi focus is used?

Actually, I have only seen this on my dev server. I don’t play on many others, and I am building one now that I may or may not make public. I assumed that perhaps it was something I was experimenting with that was making these issues happen.

I’ll test it out on a couple of servers in a few hours (currently at dialysis) and report back. But my question still remains on my (localhost) dev server.

So if the NUI focus is supposed to take over keyboard controls, then why is this happening locally?

Had same “issue” once, probably you are setting somewhere this native to true SetNuiFocusKeepInput - FiveM Natives @ Cfx.re Docs Not sure if that’s intended or not, but if any of your code sets this native to true, then all NUI’s are affected, not the only one resource that is calling this native.

Son of a gun! Yeah, I did a search, I have four resources’ scripts that use this native. So, @ grzybeek, should I make sure that each one of them put this native back into the false condition when they are finished?

One of those resources is Linden Inventory. I am confident it’s not that one, but I will check to be sure. Two of the resources have a NUI-based menu. I will triple check that those are shutting up when they are supposed to as well.

I suspect the problem child is qtarget I am using that “third eye” in a lot of places around my city. I want to make it so a player has to look at things and find ways to interact with their surroundings. A brief backstory:

My background in scripting (what little of it there is) comes from playing and making resources that work with Linden Labs’ Second Life®. In SL, you move your mouse cursor around to investigate objects. The ALT key in combination with the mouse helps SL players explore the world around them.

I am trying to build the same sort of immersive experience just in FiveM. The GTA universe, and the platform as a whole, provides me an opportunity to build the same sort of world without the complications of building it with blocks of plywood (sorry, SL!)

While FiveM, while does not give players the same camera zoom feature we enjoy in SL, we can get a cursor change that tells us if something is scripted and can be used or manipulated in some way by using bt-target or qtarget in our resources.

I suspect having that “eye” always looking may be part of the problem? How do I insure that that SetNuiFocusKeepInput native is set to false as long as the ALT ley has been released and true only when pressed?

Thanks for pointing this out. I want to get this all solved before I start publishing these resources to my (hopefully someday) public server. It’s important to my vision of an immersive world.

I’m going to connect to some other servers now that I am home to see if I can duplicate this issue somewhere other than my localhost.

Yeah, probably one of these resources doesn’t set it to false after closing NUI, you would have to look through code and add this native with false when NUI is closing.

@nta or someone who made PR with this native would have to tell if that’s intended way of this native to work, like, why native is affecting nui from different resource? But is there a way to tell which nui it should affect? not sure about this

I’m not sure if this can be changed compatibly enough, the focus changes themselves already took a long time to get to not break random scripts acting wrongly, potentially someone’s server relies on this being set even when another resource has focus active. :confused:

Doubt it’s ‘intended’, the focus natives were originally super simple and not expecting resources to badly manage this, the keep-input thing probably the same.

OK, sounds too complex for my addled brain. What about this. Is there a way to yank back the correct control of text input at least when the chat/terminal is activated upon pressing “T” and typing? Even that little bit will help me.

I understand this is normal behavior, but I want it to STOP when I am in the terminal screen

It isn’t “normal behaviour” at all. As others have pointed out, there is another resource that is ‘hijacking’ the chat resource and setting the NUI focus to false. Also, I think someone else pointed this out already, but what you’re talking about is the chat window, not the terminal screen :slight_smile:

If I was in your position, I’d try to find the culprit resource that is causing the issue and disable the part where it’s setting the NUI focus to false. Once I’ve confirmed that the chat window is now behaving normally, I’d then look for ways to only set NUI focus to false when the chat window is not open.

Here’s a potential solution: Send an export call to your culprit resource to stop the NUI focus from setting to false when your chat window opens and then another export call when the chat window closes to set the culprit resource back to default.

I meant the single keybind commands, not what it’s doing in the terminal, just to be clear :slight_smile:

Here’s a potential solution: Send an export call to your culprit resource to stop the NUI focus from setting to false when your chat window opens and then another export call when the chat window closes to set the culprit resource back to default.

What I need is to learn how to set up a proper debugging environment. I have seen this on videos where people are modding and developing, a much more detailed log of EVERYTHING that’s going on, but I have no idea how to make that happen. Ideally, I’d have a separate window with a log tailed or a live console. I have three monitors, so when I am messing with something I usually have a terminal open and I can watch the logs. But I have no idea how to do this in FiveM.

If I could see what’s going on, like you say an export that tells me when that native is true or false, that would be the shit.

@DaveGaffer By default, errors will be thrown in the terminal (for client-sided errors) and console (for server-sided errors).

They’re usually informative enough to give you a good idea on where the issue is being caused so you can take a look and fix it manually.

You can go a step further by printing relevant messages to the terminal and console via the “print” function. If you print something on a client script, it’ll show up in the terminal (access it in-game by F8) and if you print something on a server script it’ll show up in the console.

I have seen cases where I have failures with no errors at all. So it may be prudent, at least while debugging, to add print statements at each step to make sure things are working. Good plan.

Is there a way to get a console window without using the web panel? Like to just ssh into the thing and just have a command prompt and console? I’m kind of a Linux geek, so that sort of environment works for me. Secondary, just running tail -f on a relevant log file would work, I just do not know which log files or where they live.

Oh, you’re not using Windows to host your server?

In that case, I’m not sure exactly what the workaround is. On a Windows server/PC the command prompt automatically opens after you run your server, you can get a prettier looking GUI using command “svgui” in the command prompt (if you’re using the latest server artefacts).

No, I am. I am just usually a Linux guy. My desktop PC is my dev server and it is Windows 10. I still use a lot of command line stuff, I have a couple Linux machines, a VPS, several Raspberry Pi devices.

I was just thinking if I had a dedicated, floatable console window that I could keep an eye on rather than a bloated txadmin panel in a browser, it would be easier for my workflow. Since it’s what I am used to and all. Hard to shake two decades of Linux. :slight_smile:

In txAdmin, you can disable quiet mode to see output.

Apparently there are some changes in the native, too, I need to read up. There’s a way that only holds input while the resource has focus. Since I am only dealing with four resources, I’ll have to chase it down and make the changes. Thanks, y’all, for the help. Expect more stupid questions from an old man out of his depth.:smile:

Did anyone sort this ? Im admin of a city and i got thr same issue it was fine and suddenly i type N and my car menu comes up also