LUA coding help

Hey, im fairly new to coding, and i just have a question. I’m ready to hop into scripting for fivem, but there is some stuff that im wondering about.

What does this Citizen.CreateThread(function()
Citizen.CreateThread(function() --What does this do?
    while true do --what does this mean? there is no set boolean so?
FiveM Native Reference?

https://runtime.fivem.net/doc/reference.html

How i’m i supposed to use this native reference?

Script help

local playerIdentifiers --[[ table of string ]] = GetPlayerIdentifiers(playerID --[[ int ]])

Here. What does [] these mean, and i’m i sopposed to use this in the line of code? and what does “int” stand for?

I hope i didnt ask to many things but i have already done the simple script that is on the forums, but no one ever explains how to use the FiveM Wiki to create an script here!

Thank you!

CreateThread is away of create a coroutine.
A coroutine is like normal function, it will execute the code. However it does not have to “complete” or run all the way to the end.

A coroutine can “yield”, that is a coroutine saying “I am done with whatever I was doing” and the system will then continue what it was doing before the coroutine.

Next time around, it will continue/resume the coroutine where it left off, until it yet again will run into a yield.
In this case the “yield” is known as “Citizen.Wait(0)”

A coroutine has similar functionality as a thread, but instead of executing it in parallel, it will execute it one by one.

More information:
Definition of a thread (good to know the general concept).
Explain like i’m 5 entry

You can call these methods in the LUA code. For instance if you want to get the player ped, you can write “PlayerPedId()” as described in the native documentation

Note that you need to use the right names, PLAYER_PED_ID wont work, it needs to be:

  • One word, no underscored
  • Capital letter for each word.

ADD_MINIMAP_OVERLAY -> AddMinimapOverlay
CANCEL_EVENT -> CancelEvent

The [] are just a way of documenting. I would advice looking GetPlayerIdentifiers up in the native references.

It can be called like local ids = GetPlayerIdentifiers(playerid).

int means a interger value, more information here.

2 Likes

thank you for your reply!