FiveM Lua Stubs

FiveM Lua Stubs (for developers)

Docs are in the README of the GitHub or:

How to use?

These docs are only for Visual Studio Code and sumneko’s Lua language server, for other editors/servers your mileage may vary.

How to add the stubs globally

  • Open Visual Studio Code
  • Click View -> Extensions or (Ctrl + Shift + X)
  • Lua -> Cogwheel (Bottom Right) -> Extension Settings
  • Scroll down until you see “Lua › Workspace: Library”
  • Click Edit in settings.json
  • Add the following within the braces:
"Lua.workspace.library": {
    "C:/fivemstubs": true,
},

Where C:/fivemstubs is the path to the stubs on your disk.

How to add the stubs to your workspace

  • Open the workspace for your project you want to add the stubs too
  • Press Ctrl + Shift + P
  • Type in open worksp and press enter on the Open Workspace Setting (JSON)
  • Add the following within the braces:
"Lua.workspace.library": {
    "C:/fivemstubs": true,
},

Additional Tip

If you’re using FiveM’s FXServer you should add the following path to the libraries list: C:/server/citizen/scripting/lua where server is the folder which contains FXServer.exe

Download/Source

You can see the source code here: https://github.com/jamie-34254/fivem_lua_stubs
You can download it on the GitHub here: https://github.com/jamie-34254/fivem_lua_stubs/releases (stubs.zip)

Support

Support will be given for the stub generator, missing or unexpected behaviour from the stubs but not for anything else.

20 Likes

very interesting, thanks!

3 Likes

very, very nice work!

1 Like

Top job sir!

3 Likes

Really good work, glad to see something like this, I thought about this idea a while back but completely forgot about it, heh. Nice to see its presence though.

Cool work, congrats.

I’m not sure what is this but if it is, this is AWESOME!

So basically you can see the output of the code while hovering over a function? Will install it!

No, that is not how it works.

Finally! Thanks dude

… but these are 90%+ the same as the codegen output from the repo itself. :confused:

for comparison:

might be these IDE tools don’t like Global. prefix aliasing or such but really it’s nearly the same as core codegen, and @return is what LDoc specifies, not @returns

2 Likes

Looks good

Yeah… I hadn’t noticed the codegen output from the repo would spit out something I could use with my editor. I’d just been using the natives site (which is great btw) and decided I wanted something in my editor, noticed the JSON files and wrote the shitty generator.

I’m not sure if the Lua language server I’m using supports the Global prefix, but I do know it has issues with library files more then a 1000 lines, it makes it super slow unfortunately (hence why I am splitting them)

Please don’t take any offence to my tool, thank you for your work on FiveM and the tooling you’ve written around GTA.

Thank you for this, it helps a lot!

1 Like

good release.

Lool good

For some reason I can’t for the life of me get this to work. All the FiveM functions aren’t declared and I don’t get any FiveM function Code Completion/Snippets when typing

I’ve installed the Lua extension by sumneko.
I go under the Extension Settings, find Lua > Workspace: Library and edit the settings.json
My entire settings.json is as follows:

{
    "Lua.workspace.library": {
        "C:/VSCodeStubs/fivemstubs": true
    }
}

I have the stubs in C:/VSCodeStubs/fivemstubs (screenshot of folder contents)

I’ve reloaded VSCode many times (I even completely reinstalled VS Code, including deleting any configuration and settings files from AppData, etc, thinking maybe its an issue with VS Code itself)

I just can’t figure out whats wrong (and I reckon its something small that I’ve just completely missed). Anyone else run into this?

That’s really weird, Does auto complete work? If not - maybe try enabling the debug options in the extension or VSCode to see what’s going on under the hood. I don’t see anything obvious wrong, sorry :confused:

i got 1:1 the same issue like alberto2345.
cant find any debug option here.