Want to learn Lua

Can someone please recommend me guides for LUA for a beginner that has no prior experience in programming

2 Likes

Below I will leave the link to everything I used when I started at fiveM

  1. Native functions for Notepad++
    [Dev Tool / Release] Lua Native Function Code Hints in Notepad++ (v3.0)

  2. fivem documentation
    https://wiki.fivem.net/wiki/Main_Page

  3. native references to .lua script
    https://runtime.fivem.net/doc/reference.html

  4. All color for script drawtext in lua
    [How to] Use colors in lua scripting

  5. This help you for create a basic script
    [How-To] Create a basic script

  6. VIDEOS
    https://www.youtube.com/watch?v=GVnIRt77ePk
    https://www.youtube.com/watch?v=S4eNl1rA1Ns
    https://www.youtube.com/watch?v=0LiaEDui2vE

So … this is it. Good luck and welcome.

18 Likes

http://holowczak.com/programming-concepts-tutorial-programmers/

Covers basics concepts of “programming”. Use the Lua documentation to find the equivalent of a concept

https://www.lua.org/docs.html

2 Likes

Also once you actually get into scripting for FiveM this will be a life saver.

1 Like

Cheers guys @JinkLeft @Syntasu @KiKoZl

1 Like

Or you can use this [Dev Tool / Release] Lua Native Function Code Hints in Notepad++ (v3.0) (my personal favorite)

I watched all the videos but it still doesnt really help. Does someone use some sort of studio to create scripts to help them or no? I wish someone would create a how to code in FiveM

2 Likes

Well if you want to create scripts in C++/C# then yeah you’ll need Visual Studio. But if you just want to create Lua scripts then no you only need notepad (notepad++, brackets, atom, or any other text editor will do) and take scripts from these forums and mess around with them, get a local test server and see what you can make. The hardest part is actually coming up with ideas for new scripts, after that it’s just googling until you find what you need, piece by piece.

Well you obviously haven’t searched the forums then, there’s loads scattered across the forums but most can be found in #development:tutorials

2 Likes

can somone explain me the Register Event Handler,Event handler commands?

or can anyone explain me this code local spawnPos = vector3(686.245, 577.950, 130.461)

AddEventHandler(‘onClientGameTypeStart’, function()
exports.spawnmanager:setAutoSpawnCallback(function()
exports.spawnmanager:spawnPlayer({
x = spawnPos.x,
y = spawnPos.y,
z = spawnPos.z,
model = ‘a_m_m_skater_01’
}, function()
TriggerEvent(‘chat:addMessage’, {
args = { ‘Welcome to the party!~’ }
})
end)
end)

exports.spawnmanager:setAutoSpawn(true)
exports.spawnmanager:forceRespawn()

end)

How accurate is this since it was posted in 17?

i wanna know too

1 Like

Sorry for the really really really really late response.

But that code will spawn you at the position you have entered.
In example.
local spawnPos = vector3(686.245, 577.950, 130.461)
That string of numbers (686.245 and so on), would be your coordinates of where you would like to spawn.

The eventhandler:
AddEventHandler(‘onClientGameTypeStart’, function()

means, that when your game starts, it will execute the following: (code)

exports.spawnmanager:spawnPlayer({
x = spawnPos.x,
y = spawnPos.y,
z = spawnPos.z,
model = ‘a_m_m_skater_01’
}, function()

This set of code provided above ^^ will actually tell the server to spawn you at the vectors you told earlier, and will also spawn you as the selected model. In this case, being the a_m_m_skater_01. Which is a default model for FiveM spawn-ins.

There is also a TriggerEvent(‘chat:addMessage’') code. (There is no end bracket for that code, just using it for purpose).

This will trigger a Client Sided Event, in this case being adding a message to the chatbox, after the argument was fulfilled. ‘Welcome to the party!’. Which was the arguement.

and finally, the
end)
end)
which is just the closing out of any open subscripts, and allowing you to test ot your code!

Regards,
Zach

Also again, sorry for the really late response again :smile: