How to start with natives?

Hi, I need some help with fiveM natives. I know Lua as a programing language. I have difficulties with fiveM natives since there are so many of them it feels like a new program language. What’s the best way to learn them or find the ones you need? Experimenting with them or? Thanks in advance!

Hello, nice to hear that you want to learn to program in FiveM, the best way to find natives is by using the native reference, there you can search, sort, and read the documentation and see examples regarding all the natives. (Not every single native has a lot of or any documentation, but a lot of them have self-explanatory names)

Now, as an example, let’s say you want to add a blip on the map, well then you type “blip” into the search field (not with the quotation marks), and a lot of things come up, but the ones on top are AddBlipForArea, AddBlipForCoord etc. These are used to add blips as their name implies. Now scrolling through the list you can also find natives like SetBlipColour etc., these can be used to style blips for example (again as their names implies).

When it comes to learning them I would generally advise people to just try to make small and simple scripts to experiment with different natives and then read through other people’s code to see how they have done it.
(Super generic advice I know, but it does work)

1 Like

Thanks a lot! That’s what I started doing today. Must say it gets easier with time.

May I ask if You have time? How would You use statebag natives? I am trying to use It with create object so players can use that object(gas propane tank) to take kerosine from it with item with ox target. I am stuck on state bags. Thanks in Advance I just can’t find example of use on statebags

I started to write a lot of stuff in my post here, but I think it would be better to send you to already existing guides and documentation on this subject.

FiveM documentation: State bags - Cfx.re Docs
Youtube video: How to use State Bags | FiveM Lua Master Series - YouTube
Guide: How to use State Bags