Hi,
I have a problem. I saw on the FiveM Documentation that there is a TypeScript file with the definitions of FiveM natives but i wonder how the hell i am supposed to use it? I know that I’m probably so dumb but I tried to google it and looked everywhere but there is really small amount of information about how to get it to work. Can somebody write me step-by-step instruction what to do to have those automatic completions in Sublime Text 3 or other editor? Thanks in advance!
// Edit:
After all I’ve finally made it to work so i decided to write an instruction how to setup JavaScript FiveM natives autocompletion in Visual Studio Code for other people:
1. Install Node.js
2. Install Visual Studio Code
3. Now run cmd.exe as Administrator and write those two commands:
npm install -g typescript
and
npm install -g typings
4. Now run cmd.exe and using “cd” go to your FiveM server data (this one with resources folder and server start file)
(It could be other folder but i prefer this one becouse it’s easy to access)
5. Create new directory and name it as you want. (You can create it normally by GUI or type mkdir in cmd)
6. Go to this directory using “cd”
7. Now being in this directory type “typings init” in your cmd.
8. It should create you an empty typings.json file.
9. Now in the same directory, you have to paste a few commands:
typings install file: PATH TO YOUR INDEX.D.TS FILE IN FIVEM SERVER DIRECTORY --save --global
In my case:
typings install file:C:\Users\karos64\Desktop\FiveM\citizen\scripting\v8\index.d.ts --save --global
Now you just want to paste the same command only changing the last file, we need to change index.d.ts to:
natives_0193d0af.d.ts
natives_server.d.ts
natives_blank.d.ts
natives_universal.d.ts
So in total you need to type 5 commands!
If you don’t get any errors in cmd during that everything will be fine!
10. Now go to your Visual Studio Code and to your existing (or create new) .js file. (This one in your resource folder, client or server side JS)
11. All you have to do is to paste this line at the top of your script! It has to be the first line!
/// <reference path="<PATH TO YOUR INDEX.D.TS FILE IN YOUR DIRECTORY>" />
I created an “autocompletion” folder in my FiveM server data folder so in my case the path look like:
“C:\Users\karos64\Desktop\FiveM Server Data\autocompletion\typings\index.d.ts”
12. That’s all! You should have FiveM natives autocompletion in your VSC! But don’t forget to add this one line at the beggining of every JavaScript file!