JS: RegisterCommand not working

Hello,

I’m trying to create Javascript FiveM server but can’t even use the basic functions…

In client script have

RegisterCommand('mytest', () => {
    SetDisplay(true);
});

After typing says “Is not a valid command”.
If error server not shows it and no debugging available.

fxmanifest have files included

client_scripts "client/main.js"
ui_page "ui/index.html"

and resource is loaded

Any suggestions? Or what could cause this?

Documentation states it is for client and server side use

With Lua it works fine. JS what so ever works only on server side and client side is missing.
Why documentation is missleading or the feature not implemented on client side as well ?

And curious what could cause server not showing any errors?

It should work fine on ‘client side’.

If it’s a client script, of course server would not show any errors.

However…

Why are you specifying client_scripts (with s) but only a single script?

It should work fine on ‘client side’

It should, but on fresh server it doesn’t

If it’s a client script, of course server would not show any errors.
Why Lua then registers RegisterCommand from client script and JS not ?
And shouldn’t front end or something fail as well? or go through compiler?

Why are you specifying client_scripts(withs) but only a single script?
Because it will be using multiple files later on, doesn’t matter for array do I send one or x amount of strings

Just tested, works fine. You did something wrong it seems.

If using it in chat /hellojs ? :confused: as supposed to work

That doesn’t matter. Chat execute the same command in the end. And there can’t be issues with chat resource unless you did some changes. But yeah, it works too.

There’s no reason to guess what exactly you did wrong, just send related resource files so we can point mistake out quickly.

Sorry guys :confused: , figured all out now… starting from client_scripts.
As watching yt (might got it worse) and it used sendsnuimessage with type: 'ui' while in js you specify type which you will listen for which had to be type: 'message'

Even coding experience gets to do silly mistakes…

Thanks for pointing things out for start :slight_smile: and now got it working